Re: plpgsq_plugin's stmt_end() is not called when an error is caught

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, pavel(dot)stehule(at)gmail(dot)com, pgsql-hackers(at)postgresql(dot)org
Subject: Re: plpgsq_plugin's stmt_end() is not called when an error is caught
Date: 2022-12-15 16:18:04
Message-ID: CAKFQuwZYbWPF8eRpg158PUuOMqeW7u7EFJQxtR5mDyi-2p8vjQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Dec 15, 2022 at 8:49 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> writes:
> > I don't think we need additional PG_TRY() for that since exec_stmts()
> > is already called in PG_TRY() if there is an exception block. I meant
> > to call stmt_end() in PG_CATCH() in exec_stmt_block() (i.e. only when
> > an error is caught by the exception block). Currently, if an error is
> > caught, we call stmt_begin() and stmt_end() for statements executed
> > inside the exception block but call only stmt_begin() for the
> > statement that raised an error.
>
> I fail to see anything wrong with that. We never completed execution
> of the statement that raised an error, but calling stmt_end for it
> would imply that we did. I think changing this will break more things
> than it fixes, completely independently of whatever cost it would add.
>
> Or in other words: the initial complaint describes a bug in pg_hint_plan,
> not one in plpgsql.
>
>
The OP suggests needing something akin to a "finally" callback for
statement. While a fine feature request for plpgsql its absence doesn't
constitute a bug.

David J.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message vignesh C 2022-12-15 16:24:44 Re: Support logical replication of DDLs
Previous Message Justin Pryzby 2022-12-15 16:13:23 Re: [PATCH] psql: \dn+ to show size of each schema (and \dA+ for AMs)