Thread: pgsql: PL/Python: Fix crash in functions returning SETOF and using SPI

pgsql: PL/Python: Fix crash in functions returning SETOF and using SPI

From
Peter Eisentraut
Date:
PL/Python: Fix crash in functions returning SETOF and using SPI

Allocate PLyResultObject.tupdesc in TopMemoryContext, because its
lifetime is the lifetime of the Python object and it shouldn't be
freed by some other memory context, such as one controlled by SPI.  We
trust that the Python object will clean up its own memory.

Before, this would crash the included regression test case by trying
to use memory that was already freed.

reported by Asif Naeem, analysis by Tom Lane

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/52aa334fcd5a9d230be7e8fb964d94c6c4e63dc7

Modified Files
--------------
src/pl/plpython/expected/plpython_setof.out |   16 ++++++++++++++++
src/pl/plpython/plpy_spi.c                  |   11 +++++++++++
src/pl/plpython/sql/plpython_setof.sql      |   12 ++++++++++++
3 files changed, 39 insertions(+), 0 deletions(-)