Re: PL/Python: Fix return in the middle of PG_TRY() block.

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Nathan Bossart <nathandbossart(at)gmail(dot)com>
Cc: Xing Guo <higuoxing(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: PL/Python: Fix return in the middle of PG_TRY() block.
Date: 2023-01-13 01:45:59
Message-ID: Y8C3137zhciaQoRz@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Jan 12, 2023 at 10:44:33AM -0800, Nathan Bossart wrote:
> There's another "return" later on in this PG_TRY block. I wonder if it's
> possible to detect this sort of thing at compile time.

Note also:
src/pl/tcl/pltcl.c- * PG_CATCH();
src/pl/tcl/pltcl.c- * {
src/pl/tcl/pltcl.c- * pltcl_subtrans_abort(interp, oldcontext, oldowner);
src/pl/tcl/pltcl.c- * return TCL_ERROR;
src/pl/tcl/pltcl.c- * }

This is documented once, repeated twice:
src/pl/plpython/plpy_spi.c- * PG_CATCH();
src/pl/plpython/plpy_spi.c- * {
src/pl/plpython/plpy_spi.c- * <do cleanup>
src/pl/plpython/plpy_spi.c- * PLy_spi_subtransaction_abort(oldcontext, oldowner);
src/pl/plpython/plpy_spi.c- * return NULL;
src/pl/plpython/plpy_spi.c- * }

I don't quite get why this would be a sane thing to do here when
aborting a subtransaction in pl/python, but my experience with this
code is limited.
--
Michael

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Amin 2023-01-13 01:48:59 Get relid for a relation
Previous Message David G. Johnston 2023-01-13 01:15:50 Re: pgsql: Add new GUC createrole_self_grant.