aboutsummaryrefslogtreecommitdiff
path: root/src/pl/plpython/sql/plpython_setof.sql
diff options
context:
space:
mode:
Diffstat (limited to 'src/pl/plpython/sql/plpython_setof.sql')
-rw-r--r--src/pl/plpython/sql/plpython_setof.sql12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/pl/plpython/sql/plpython_setof.sql b/src/pl/plpython/sql/plpython_setof.sql
index fe034fba45e..16c2eef0ad6 100644
--- a/src/pl/plpython/sql/plpython_setof.sql
+++ b/src/pl/plpython/sql/plpython_setof.sql
@@ -63,6 +63,18 @@ SELECT test_setof_as_iterator(2, null);
SELECT test_setof_spi_in_iterator();
+-- set-returning function that modifies its parameters
+CREATE OR REPLACE FUNCTION ugly(x int, lim int) RETURNS SETOF int AS $$
+global x
+while x <= lim:
+ yield x
+ x = x + 1
+$$ LANGUAGE plpythonu;
+
+SELECT ugly(1, 5);
+
+-- interleaved execution of such a function
+SELECT ugly(1,3), ugly(7,8);
-- returns set of named-composite-type tuples
CREATE OR REPLACE FUNCTION get_user_records()