Hi there,
I can't make Python Generators to work reliably. According to the
documentation, this should work:
CREATE OR REPLACE FUNCTION foobar()
RETURNS SETOF text AS
$$
for s in ('Hello', 'World'):
plpy.execute('select 1')
yield s
$$
LANGUAGE 'plpythonu';
I get this error when calling the function:
test=# select foobar();
ERROR: error fetching next item from iterator
CONTEXT: PL/Python function "foobar"
When I remove the dummy plpy.execute() call, it works:
CREATE OR REPLACE FUNCTION foobar()
RETURNS SETOF text AS
$$
for s in ('Hello', 'World'):
yield s
$$
LANGUAGE 'plpythonu';
test=# select foobar();
foobar
--------
Hello
World
(2 rows)
Seems like calls to plpy.execute() conflict with generators. This is
the case both on versions 8.4.4 and 9.0.1.
All the best,
--
Jean-Baptiste Quenot
--
Sent via pgsql-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers