pl/python: fix ref leak on elog
Attached is a simple patch that fixes a minor problem in PL/Python: in
PLy_spi_execute_plan(), we invoke the input function for a Postgres data
type. If that function elog's (which is quite possible), PL/Python leaks
references to two temporary Python objects. The fix seems easy, albeit a
bit ugly: the reference count on one of the temporary objects can be
decremented before calling the function. A pointer that points into the
second object is passed to the input function itself, so we have to
PG_CATCH() the elog and decrement the refcount then.
Since the problem might actually occur in practice and the fix seems to
have little chance of inducing a regression, I'm thinking of applying
this to both HEAD and back branches. Barring any objections I'll do that
later today or early tomorrow.
-Neil
Attachments:
plpython_ref_leak-3.patchtext/x-patch; name=plpython_ref_leak-3.patch; x-mac-creator=0; x-mac-type=0Download+32-34
Neil Conway <neilc@samurai.com> writes:
Since the problem might actually occur in practice and the fix seems to
have little chance of inducing a regression, I'm thinking of applying
this to both HEAD and back branches. Barring any objections I'll do that
later today or early tomorrow.
Looks alright to me. I agree with backpatching as far back as we have
PG_TRY. The reason for the FIXME was that there wasn't any simple way
to fix it before that ...
regards, tom lane