diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2013-12-11 17:22:47 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2013-12-11 17:22:55 -0500 |
commit | 6bff0e7d92133d50c064d9f652f538891873aa32 (patch) | |
tree | b408c70ded811f4f591a54f8e28200b4e0cf073a /src/pl/plpython/sql/plpython_setof.sql | |
parent | cf589c9c1f5f7f89018684b763d74d7b02a2504b (diff) | |
download | postgresql-6bff0e7d92133d50c064d9f652f538891873aa32.tar.gz postgresql-6bff0e7d92133d50c064d9f652f538891873aa32.zip |
Add a regression test case for plpython function returning setof RECORD.
We had coverage for functions returning setof a named composite type,
but not for anonymous records, which is a somewhat different code path.
In view of recent crash report from Sergey Konoplev, this seems worth
testing, though I doubt there's any deterministic bug here today.
Diffstat (limited to 'src/pl/plpython/sql/plpython_setof.sql')
-rw-r--r-- | src/pl/plpython/sql/plpython_setof.sql | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/pl/plpython/sql/plpython_setof.sql b/src/pl/plpython/sql/plpython_setof.sql index 243f711dcc6..fe034fba45e 100644 --- a/src/pl/plpython/sql/plpython_setof.sql +++ b/src/pl/plpython/sql/plpython_setof.sql @@ -64,9 +64,7 @@ SELECT test_setof_as_iterator(2, null); SELECT test_setof_spi_in_iterator(); --- setof function with an SPI result set (used to crash because of --- memory management issues across multiple calls) - +-- returns set of named-composite-type tuples CREATE OR REPLACE FUNCTION get_user_records() RETURNS SETOF users AS $$ @@ -74,3 +72,14 @@ AS $$ $$ LANGUAGE plpythonu; SELECT get_user_records(); +SELECT * FROM get_user_records(); + +-- same, but returning set of RECORD +CREATE OR REPLACE FUNCTION get_user_records2() +RETURNS TABLE(fname text, lname text, username text, userid int) +AS $$ + return plpy.execute("SELECT * FROM users ORDER BY username") +$$ LANGUAGE plpythonu; + +SELECT get_user_records2(); +SELECT * FROM get_user_records2(); |