@@ -374,10 +374,11 @@ select sum(tenthous) as s1, sum(tenthous) + random()*0 as s2
374374-- end_ignore
375375create table limit_tbl(i int) distributed by (i);
376376insert into limit_tbl select * from generate_series(1, 3) i;
377+ create function f(i int) returns int language plpgsql as $$ begin return i; end; $$;
377378explain (verbose, costs off)
378- select (select a + random()*0 from generate_series(1, 4) a limit 1 offset limit_tbl.i) as r from limit_tbl order by r;
379- QUERY PLAN
380- ----------------------------------------------------------------------------------------------------------------
379+ select (select f(a) from generate_series(1, 4) a limit 1 offset limit_tbl.i) as r from limit_tbl order by r;
380+ QUERY PLAN
381+ -------------------------------------------------------------------------------------
381382 Gather Motion 3:1 (slice1; segments: 3)
382383 Output: ((SubPlan 1))
383384 Merge Key: ((SubPlan 1))
@@ -388,24 +389,25 @@ select (select a + random()*0 from generate_series(1, 4) a limit 1 offset limit_
388389 Output: (SubPlan 1)
389390 SubPlan 1
390391 -> Limit
391- Output: ((( a.a)::double precision + (random() * '0'::double precision) ))
392+ Output: (f( a.a))
392393 -> Materialize
393- Output: ((( a.a)::double precision + (random() * '0'::double precision) ))
394+ Output: (f( a.a))
394395 -> Broadcast Motion 1:3 (slice2; segments: 1)
395- Output: ((( a.a)::double precision + (random() * '0'::double precision) ))
396+ Output: (f( a.a))
396397 -> Function Scan on pg_catalog.generate_series a
397- Output: (( a.a)::double precision + (random() * '0'::double precision) )
398+ Output: f( a.a)
398399 Function Call: generate_series(1, 4)
399400 Optimizer: Postgres-based planner
400401 Settings: optimizer = 'off'
401402(20 rows)
402403
403- select (select a + random()*0 from generate_series(1, 4) a limit 1 offset limit_tbl.i) as r from limit_tbl order by r;
404+ select (select f(a) from generate_series(1, 4) a limit 1 offset limit_tbl.i) as r from limit_tbl order by r;
404405 r
405406---
406407 2
407408 3
408409 4
409410(3 rows)
410411
412+ drop function f(int);
411413drop table limit_tbl;
0 commit comments