Bug in plpython's Python Generators - Mailing list pgsql-hackers

From Jean-Baptiste Quenot
Subject Bug in plpython's Python Generators
Date
Msg-id AANLkTimLMr-u89f7vf4AckB6xH=V3uf+PxraOg4XB4=o@mail.gmail.com
Whole thread Raw
Responses Re: Bug in plpython's Python Generators
List pgsql-hackers
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
--------HelloWorld
(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


pgsql-hackers by date:

Previous
From: Dimitri Fontaine
Date:
Subject: Re: pg_hba.conf host name wildcard support
Next
From: Marko Tiikkaja
Date:
Subject: Re: Review: Fix snapshot taking inconsistencies