Re: Savepoints in plpgsql

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: "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:15:20
Message-ID: CAKFQuwZXC2dDsDMLg77kWO4c7aiFwEn5LS9Hc9p-iooHXK+Ecw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

On Thursday, July 11, 2024, PG Doc comments form <noreply(at)postgresql(dot)org>
wrote:

> The following documentation comment has been logged on the website:
>
> Page: https://www.postgresql.org/docs/16/plpgsql-transactions.html
> Description:
>
> https://www.postgresql.org/docs/current/plpgsql-transactions.html
>
> 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.

Also need to say, that "begin
> end" block with "exception" handler will implicitly save and release
> savepoints.
>

A savepoint is an SQL command giving you access to subtransactions.
Plpgsql doesn’t need or use it, it has a direct access to subtransactions
though in a limited/different way. In short, even if this worked this way
we wouldn’t document such an implementation detail.

I suppose we could draw analogies to savepoints, or maybe mention
subtransactions again in the procedure transactions chapter. Namely by
explaining why the last limitation on that page exists, which I presume is
related to subtransactions. But really that page is meant to show how
procedures can use commit/rollback to anffect the outer transaction unlike
all other plpgsql code which simply gets block-based subtransactions
management as previously described. It does this sufficiently and need not
be cluttered by subtransaction discussion in any meaningful detail.

David J.

In response to

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message Tom Lane 2024-07-12 13:42:24 Re: Savepoints in plpgsql
Previous Message PG Doc comments form 2024-07-12 05:52:24 Savepoints in plpgsql