Re: Savepoints in plpgsql - Mailing list pgsql-docs

From Tom Lane
Subject Re: Savepoints in plpgsql
Date
Msg-id 2320320.1720791744@sss.pgh.pa.us
Whole thread Raw
In response to Re: Savepoints in plpgsql  ("David G. Johnston" <david.g.johnston@gmail.com>)
Responses Re: Savepoints in plpgsql
List pgsql-docs
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Thursday, July 11, 2024, PG Doc comments form <noreply@postgresql.org>
> wrote:
>> In this section nothing mentioned that a savepoint (a subtransaction) will
>> not work inside plpgsql.

> Correct, we prefer to just document how things work.  43.2 does mention
> that blocks form subtransactions.

It probably would be reasonable to mention something about this
in 43.8, if only to provide an excuse to cross-reference 43.6.8.
I'm imagining more or less

    PL/pgSQL does not support savepoints (SAVEPOINT/ROLLBACK TO
    SAVEPOINT/RELEASE SAVEPOINT commands).  Typical usage patterns
    for savepoints can be replaced by blocks with exception handlers
    (see 43.6.8).

I also notice the last para

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

which seems like it could be tied into that somehow.  Maybe eliminate
that as a separate para, and write

    PL/pgSQL does not support savepoints (SAVEPOINT/ROLLBACK TO
    SAVEPOINT/RELEASE SAVEPOINT commands).  Typical usage patterns
    for savepoints can be replaced by blocks with exception handlers
    (see 43.6.8).  Under the hood, a block with exception handlers
    forms a subtransaction, which means that transactions cannot
    be ended inside such a block.

            regards, tom lane



pgsql-docs by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: Savepoints in plpgsql
Next
From: PG Doc comments form
Date:
Subject: 13.2.1. Read Committed Isolation Level