Re: PL/pgSQL — "commit" illegal in the executable section of a block statement that has an exception section

From: Christophe Pettus <xof(at)thebuild(dot)com>
To: Bryn Llewellyn <bryn(at)yugabyte(dot)com>
Cc: pgsql-hackers list <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: PL/pgSQL — "commit" illegal in the executable section of a block statement that has an exception section
Date: 2019-10-01 01:40:58
Message-ID: 54C2FEA5-86FF-4A3C-A84B-4470A6998ACA@thebuild.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On Sep 30, 2019, at 15:37, Bryn Llewellyn <bryn(at)yugabyte(dot)com> wrote:
> I wrote up the problem here:
>
> https://github.com/yugabyte/yugabyte-db/issues/2464

This is documented; it's the very last line of the page you reference in the Github issue:

A transaction cannot be ended inside a block with exception handlers.

Your discussion doesn't answer the specific issue: BEGIN/EXCEPTION/END in pl/pgSQL is implemented by savepoints. What semantics should COMMIT / ROLLBACK have inside of that? Doing a COMMIT / ROLLBACK (at the database level) at that point would lose the savepoints, which would break the BEGIN/EXCEPTION/END semantics.

It's not clear to me what the alternative semantics would be. Can you propose specific database behavior for a COMMIT or ROLLBACK inside a BEGIN/EXCEPTION/END block which retain the savepoint behavior of BEGIN/EXCEPTION/END?
--
-- Christophe Pettus
xof(at)thebuild(dot)com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Paul Guo 2019-10-01 02:08:10 Re: Two pg_rewind patches (auto generate recovery conf and ensure clean shutdown)
Previous Message Tom Lane 2019-10-01 01:40:06 Re: subscriptionCheck failures on nightjar