Skip to content

Commit 0dac5b5

Browse files
committed
Tweak targetlist-SRF tests some more.
Seems like it would be good to have a test case documenting the existing behavior for non-top-level SRFs.
1 parent 6415ba5 commit 0dac5b5

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/test/regress/expected/tsrf.out

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,17 @@ LINE 1: INSERT INTO fewmore VALUES(1) RETURNING generate_series(1,3)...
375375
-- nor standalone VALUES (but surely this is a bug?)
376376
VALUES(1, generate_series(1,2));
377377
ERROR: set-valued function called in context that cannot accept a set
378+
-- We allow tSRFs that are not at top level
379+
SELECT int4mul(generate_series(1,2), 10);
380+
int4mul
381+
---------
382+
10
383+
20
384+
(2 rows)
385+
386+
-- but SRFs in function RTEs must be at top level (annoying restriction)
387+
SELECT * FROM int4mul(generate_series(1,2), 10);
388+
ERROR: set-valued function called in context that cannot accept a set
378389
-- DISTINCT ON is evaluated before tSRF evaluation if SRF is not
379390
-- referenced either in ORDER BY or in the DISTINCT ON list. The ORDER
380391
-- BY reference can be implicitly generated, if there's no other ORDER BY.

src/test/regress/sql/tsrf.sql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ INSERT INTO fewmore VALUES(1) RETURNING generate_series(1,3);
8080
-- nor standalone VALUES (but surely this is a bug?)
8181
VALUES(1, generate_series(1,2));
8282

83+
-- We allow tSRFs that are not at top level
84+
SELECT int4mul(generate_series(1,2), 10);
85+
86+
-- but SRFs in function RTEs must be at top level (annoying restriction)
87+
SELECT * FROM int4mul(generate_series(1,2), 10);
88+
8389
-- DISTINCT ON is evaluated before tSRF evaluation if SRF is not
8490
-- referenced either in ORDER BY or in the DISTINCT ON list. The ORDER
8591
-- BY reference can be implicitly generated, if there's no other ORDER BY.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy