diff options
Diffstat (limited to 'src/pl/plpython/expected')
| -rw-r--r-- | src/pl/plpython/expected/plpython_setof.out | 29 | ||||
| -rw-r--r-- | src/pl/plpython/expected/plpython_spi.out | 15 |
2 files changed, 44 insertions, 0 deletions
diff --git a/src/pl/plpython/expected/plpython_setof.out b/src/pl/plpython/expected/plpython_setof.out index 62b8a454a35..308d2abb7f3 100644 --- a/src/pl/plpython/expected/plpython_setof.out +++ b/src/pl/plpython/expected/plpython_setof.out @@ -124,6 +124,35 @@ SELECT test_setof_spi_in_iterator(); World (4 rows) +-- 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); + ugly +------ + 1 + 2 + 3 + 4 + 5 +(5 rows) + +-- interleaved execution of such a function +SELECT ugly(1,3), ugly(7,8); + ugly | ugly +------+------ + 1 | 7 + 2 | 8 + 3 | 7 + 1 | 8 + 2 | 7 + 3 | 8 +(6 rows) + -- returns set of named-composite-type tuples CREATE OR REPLACE FUNCTION get_user_records() RETURNS SETOF users diff --git a/src/pl/plpython/expected/plpython_spi.out b/src/pl/plpython/expected/plpython_spi.out index e715ee5393b..dbde36f8412 100644 --- a/src/pl/plpython/expected/plpython_spi.out +++ b/src/pl/plpython/expected/plpython_spi.out @@ -57,6 +57,15 @@ for r in rv: return seq ' LANGUAGE plpythonu; +CREATE FUNCTION spi_recursive_sum(a int) RETURNS int + AS +'r = 0 +if a > 1: + r = plpy.execute("SELECT spi_recursive_sum(%d) as a" % (a-1))[0]["a"] +return a + r +' + LANGUAGE plpythonu; +-- -- spi and nested calls -- select nested_call_one('pass this along'); @@ -112,6 +121,12 @@ SELECT join_sequences(sequences) FROM sequences ---------------- (0 rows) +SELECT spi_recursive_sum(10); + spi_recursive_sum +------------------- + 55 +(1 row) + -- -- plan and result objects -- |
