From: | Mikhail Gribkov <youzhick(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org, peter(dot)eisentraut(at)enterprisedb(dot)com |
Subject: | Re: Nicely exiting PG_TRY and PG_CATCH |
Date: | 2022-10-20 16:39:08 |
Message-ID: | CAMEv5_sUmv6_Zm3-JBR7VTXH-uxJE+GF=p+0EY4=LZD8hsO6FQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
> Yeah, you can't return or goto out of the PG_TRY part.
So this is a problem if the check would ever work.
(Sorry for such a delayed answer.)
Then we need to fix it. Attached is a minimal patch, which changes nothing
except for correct PG_TRY exiting.
Isn't it better this way?
CCing to Peter Eisentraut, whose patch originally introduced these returns.
Peter, will such a patch work somehow against your initial idea?
--
best regards,
Mikhail A. Gribkov
e-mail: youzhick(at)gmail(dot)com
*http://www.flickr.com/photos/youzhick/albums
<http://www.flickr.com/photos/youzhick/albums>*
http://www.strava.com/athletes/5085772
phone: +7(916)604-71-12
Telegram: @youzhick
On Sat, Oct 8, 2022 at 12:19 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Mikhail Gribkov <youzhick(at)gmail(dot)com> writes:
> > Usually it's not a good idea to exit PG_TRY() block via return statement.
> > Otherwise it would leave PG_exception_stack global variable in a wrong
> > state and next ereport() will jump to some junk address.
>
> Yeah, you can't return or goto out of the PG_TRY part.
>
> > Another suspicious case is PG_CATCH block in jsonb_plpython.c:
>
> This should be OK. The PG_CATCH and PG_FINALLY macros are set up so that
> we've fully restored that state *before* we execute any of the
> error-handling code. It would be basically impossible to have a guarantee
> that CATCH blocks never throw errors; they'd be so restricted as to be
> near useless, like signal handlers.
>
> regards, tom lane
>
Attachment | Content-Type | Size |
---|---|---|
0001-Fix-returns-from-try.patch | application/x-patch | 1.4 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | sirisha chamarthi | 2022-10-20 16:40:24 | Re: Fix GetWALAvailability function code comments for WALAVAIL_REMOVED return value |
Previous Message | Robert Haas | 2022-10-20 16:18:30 | Re: Avoid memory leaks during base backups |