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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Xing Guo <higuoxing(at)gmail(dot)com>
Cc: Nathan Bossart <nathandbossart(at)gmail(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: PL/Python: Fix return in the middle of PG_TRY() block.
Date: 2023-01-16 15:29:03
Message-ID: 1864041.1673882943@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Xing Guo <higuoxing(at)gmail(dot)com> writes:
> Are there any unsafe codes in pltcl.c? The return statement is in the
> PG_CATCH() block, I think the exception stack has been recovered in
> PG_CATCH block so the return statement in PG_CATCH block should be ok?

Yes, the stack has already been unwound at the start of a PG_CATCH
(or PG_FINALLY) block, so there is no reason to avoid returning
out of those.

In principle you could also mess things up with a "continue", "break",
or "goto" leading out of PG_TRY. That's probably far less likely
than "return", but I wonder whether Andres' compiler hack will
catch that.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David G. Johnston 2023-01-16 15:33:48 Re: pgsql: Add new GUC createrole_self_grant.
Previous Message Robert Haas 2023-01-16 15:26:18 Re: pgsql: Add new GUC createrole_self_grant.