Обсуждение: PL/pgSQL — "commit" illegal in the executable section of a block statement that has an exception section

Поиск
Список
Период
Сортировка

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

От
Bryn Llewellyn
Дата:
I work for YugaByte, Inc (www.yugabyte.com). YugabyteDB re-uses the source code that implements the “upper half” of PostgreSQL Version 11.2. See here:


This means that the problem that the PostgreSQL issue I describe tracks affects users of YugabyteDB too.

I wrote up the problem here:


Please read my account and comment.

Peter Eisentraut, I hope that you’ll read this. I’m told that you're the authority for txn control in PL/pgSQL.

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

От
Christophe Pettus
Дата:

> On Sep 30, 2019, at 15:37, Bryn Llewellyn <bryn@yugabyte.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
semanticsshould COMMIT / ROLLBACK have inside of that?  Doing a COMMIT / ROLLBACK (at the database level) at that point
wouldlose 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
orROLLBACK inside a BEGIN/EXCEPTION/END block which retain the savepoint behavior of BEGIN/EXCEPTION/END? 
--
-- Christophe Pettus
   xof@thebuild.com