Tweak targetlist-SRF tests some more.
authorTom Lane <[email protected]>
Wed, 14 Sep 2016 23:48:42 +0000 (19:48 -0400)
committerTom Lane <[email protected]>
Wed, 14 Sep 2016 23:48:50 +0000 (19:48 -0400)
Seems like it would be good to have a test case documenting the
existing behavior for non-top-level SRFs.

src/test/regress/expected/tsrf.out
src/test/regress/sql/tsrf.sql

index e9bea411fd4b676e47d0e097b3d3dfd1bf0265f3..d9a5f137dc0117e8b463736610cd17e5b26ef5c9 100644 (file)
@@ -375,6 +375,17 @@ LINE 1: INSERT INTO fewmore VALUES(1) RETURNING generate_series(1,3)...
 -- nor standalone VALUES (but surely this is a bug?)
 VALUES(1, generate_series(1,2));
 ERROR:  set-valued function called in context that cannot accept a set
+-- We allow tSRFs that are not at top level
+SELECT int4mul(generate_series(1,2), 10);
+ int4mul 
+---------
+      10
+      20
+(2 rows)
+
+-- but SRFs in function RTEs must be at top level (annoying restriction)
+SELECT * FROM int4mul(generate_series(1,2), 10);
+ERROR:  set-valued function called in context that cannot accept a set
 -- DISTINCT ON is evaluated before tSRF evaluation if SRF is not
 -- referenced either in ORDER BY or in the DISTINCT ON list. The ORDER
 -- BY reference can be implicitly generated, if there's no other ORDER BY.
index b0dfc193acee6947fec2f5e4fee13d8f4adc9f79..4f854c8b83be11c40e8036ae4953d26ba98ab7d4 100644 (file)
@@ -80,6 +80,12 @@ INSERT INTO fewmore VALUES(1) RETURNING generate_series(1,3);
 -- nor standalone VALUES (but surely this is a bug?)
 VALUES(1, generate_series(1,2));
 
+-- We allow tSRFs that are not at top level
+SELECT int4mul(generate_series(1,2), 10);
+
+-- but SRFs in function RTEs must be at top level (annoying restriction)
+SELECT * FROM int4mul(generate_series(1,2), 10);
+
 -- DISTINCT ON is evaluated before tSRF evaluation if SRF is not
 -- referenced either in ORDER BY or in the DISTINCT ON list. The ORDER
 -- BY reference can be implicitly generated, if there's no other ORDER BY.