diff options
Diffstat (limited to 'src/pl/plpython/sql/plpython_setof.sql')
-rw-r--r-- | src/pl/plpython/sql/plpython_setof.sql | 12 |
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 4cfb10192c0..1a0472b7a3b 100644 --- a/src/pl/plpython/sql/plpython_setof.sql +++ b/src/pl/plpython/sql/plpython_setof.sql @@ -20,6 +20,13 @@ for i in range(count): return t $$ LANGUAGE plpython3u; +CREATE FUNCTION test_setof_as_set(count integer, content text) RETURNS SETOF text AS $$ +s = set() +for i in range(count): + s.add(content * (i + 1) if content is not None else None) +return s +$$ LANGUAGE plpython3u; + CREATE FUNCTION test_setof_as_iterator(count integer, content text) RETURNS SETOF text AS $$ class producer: def __init__ (self, icount, icontent): @@ -56,6 +63,11 @@ SELECT test_setof_as_tuple(1, 'tuple'); SELECT test_setof_as_tuple(2, 'tuple'); SELECT test_setof_as_tuple(2, null); +SELECT * FROM test_setof_as_set(0, 'set') ORDER BY 1; +SELECT * FROM test_setof_as_set(1, 'set') ORDER BY 1; +SELECT * FROM test_setof_as_set(2, 'set') ORDER BY 1; +SELECT * FROM test_setof_as_set(2, null) ORDER BY 1; + SELECT test_setof_as_iterator(0, 'list'); SELECT test_setof_as_iterator(1, 'list'); SELECT test_setof_as_iterator(2, 'list'); |