Re: Savepoints in plpgsql

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: "splarv(at)ya(dot)ru" <splarv(at)ya(dot)ru>, "pgsql-docs(at)lists(dot)postgresql(dot)org" <pgsql-docs(at)lists(dot)postgresql(dot)org>
Subject: Re: Savepoints in plpgsql
Date: 2024-07-12 13:42:24
Message-ID: 2320320.1720791744@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

"David G. Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> writes:
> On Thursday, July 11, 2024, PG Doc comments form <noreply(at)postgresql(dot)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

In response to

Browse pgsql-docs by date

  From Date Subject
Next Message PG Doc comments form 2024-07-14 06:17:37 13.2.1. Read Committed Isolation Level
Previous Message David G. Johnston 2024-07-12 13:15:20 Re: Savepoints in plpgsql