Re: Savepoints in plpgsql
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: "David G. Johnston" <david.g.johnston@gmail.com>
Cc: "splarv@ya.ru" <splarv@ya.ru>,
"pgsql-docs@lists.postgresql.org" <pgsql-docs@lists.postgresql.org>
Date: 2024-07-12T13:42:24Z
Lists: 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
Commits
-
Doc: minor improvements for plpgsql "Transaction Management" section.
- a0899c0a97d1 18.0 landed
- 34f457e99a86 17.0 landed