summaryrefslogtreecommitdiff
path: root/src/pl/plpython/expected/plpython_setof.out
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2010-11-15 14:27:00 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2010-11-15 14:27:00 -0500
commite086197aaa8de484dafcb1cc991640980e252d70 (patch)
tree01bb0ce4bb715abff5062a9619c31981233dc151 /src/pl/plpython/expected/plpython_setof.out
parent102aeedfb9bf01b419563151846ebbd1f01f4a5f (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/expected/plpython_setof.out')
-rw-r--r--src/pl/plpython/expected/plpython_setof.out17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/pl/plpython/expected/plpython_setof.out b/src/pl/plpython/expected/plpython_setof.out
index ebf896df01f..ac9765fc882 100644
--- a/src/pl/plpython/expected/plpython_setof.out
+++ b/src/pl/plpython/expected/plpython_setof.out
@@ -31,6 +31,14 @@ class producer:
return self.icontent
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 set returning functions
SELECT test_setof_as_list(0, 'list');
test_setof_as_list
@@ -107,3 +115,12 @@ SELECT test_setof_as_iterator(2, null);
(2 rows)
+SELECT test_setof_spi_in_iterator();
+ test_setof_spi_in_iterator
+----------------------------
+ Hello
+ Brave
+ New
+ World
+(4 rows)
+