summaryrefslogtreecommitdiff
path: root/src/pl/plpython/sql/plpython_function.sql
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2010-11-15 14:27:04 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2010-11-15 14:27:04 -0500
commit7508d9d87e7d506b3e56ba3e0a778efa33a17912 (patch)
treea488662e7e3ca803dda9109a878371fa25a1440c /src/pl/plpython/sql/plpython_function.sql
parent2519b8268be4d407325b1882dd58ba50914e9230 (diff)
Fix aboriginal mistake in plpython's set-returning-function support.
We must stay in the function's SPI context until done calling the iterator that returns the set result. Otherwise, any attempt to invoke SPI features in the python code called by the iterator will malfunction. Diagnosis and patch by Jan Urbanski, per bug report from Jean-Baptiste Quenot. Back-patch to 8.2; there was no support for SRFs in previous versions of plpython.
Diffstat (limited to 'src/pl/plpython/sql/plpython_function.sql')
-rw-r--r--src/pl/plpython/sql/plpython_function.sql9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/pl/plpython/sql/plpython_function.sql b/src/pl/plpython/sql/plpython_function.sql
index a1544f3c422..0872f1a3091 100644
--- a/src/pl/plpython/sql/plpython_function.sql
+++ b/src/pl/plpython/sql/plpython_function.sql
@@ -448,6 +448,15 @@ class producer:
return producer(count, content)
$$ LANGUAGE plpythonu;
+CREATE FUNCTION test_setof_spi_in_iterator() RETURNS SETOF text AS
+$$
+ for s in ('Hello', 'Brave', 'New', 'World'):
+ plpy.execute('select 1')
+ yield s
+ plpy.execute('select 2')
+$$
+LANGUAGE plpythonu;
+
--
-- Test returning tuples