pgsql: PL/Python: Fix crash in functions returning SETOF and using SPI - Mailing list pgsql-committers

From Peter Eisentraut
Subject pgsql: PL/Python: Fix crash in functions returning SETOF and using SPI
Date
Msg-id E1SPdus-0005vg-0R@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
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(-)


pgsql-committers by date:

Previous
From: Peter Eisentraut
Date:
Subject: pgsql: Even more duplicate word removal, in the spirit of the season
Next
From: Peter Eisentraut
Date:
Subject: pgsql: PL/Python: Improve test coverage