From: Dominique Devienne <ddevienne@gmail.com>
To: Erik Wienhold <ewie@ewie.name>
Cc: Lorusso Domenico <domenico.l76@gmail.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: rollback to savepoint issue
Date: Mon, 4 Sep 2023 16:22:54 +0200
Message-ID: <CAFCRh--7b92tMA1OSfnOp7pTu9O2rtSW1N-0HjWkn2XA-MeCUQ@mail.gmail.com> (raw)
In-Reply-To: <1341766181.156278.1693831501720@office.mailbox.org>
References: <CAJMpnG7DAcz4ckE_GGN4VkjaJvzVrdwCYwjH+ocLnVVYvb-fcQ@mail.gmail.com>
<1341766181.156278.1693831501720@office.mailbox.org>
On Mon, Sep 4, 2023 at 3:47 PM Erik Wienhold <ewie@ewie.name> wrote:
> On 04/09/2023 11:51 CEST Lorusso Domenico <domenico.l76@gmail.com> wrote:
> Transaction control is not possible in functions. Only in procedures
> (CALL)
> and DO blocks.
>
> > ERROR: syntax error at or near "to"
> > LINE 41: rollback to savepoint deleteAttribute;
>
> Use BEGIN ... EXCEPTION ... END instead of manual savepoints. [1]
>
> [1]
> https://www.postgresql.org/docs/current/plpgsql-porting.html#PLPGSQL-PORTING-EXCEPTIONS
Hi Erik. And experts at large. What's the underlying mechanism though? An
implicit SAVEPOINT?
The reason I'm asking, is that we are using explicit SAVEPOINTs in client
C/C++ code,
to "emulate" per-Statement "isolation", like other DBs have (Oracle,
SQLite), instead of
having to ROLLBACK the "whole" transaction.
Which means extra explicit round-trips to the server to establish and "move
along" the savepoint,
per command. Which I think is "expensive". So would anonymous DO blocks be
a better solution?
If BEGIN/EXCEPTION uses an "implicit" / "hidden" SAVEPOINT, would that
still be better then?
And if we switch to anon DO+EXCEPTION blocks, is it just as easy to bind to
the inner SQL command(s)?
Sorry if my questions are a little vague. This is an area that's still
fuzzy for me, I'm not versed in pgPL/SQL.
Finally, I've read "horror stories" about SAVEPOINTs, with
performance-cliffs when using them,
because if I recall correctly, there's only room in pages (?) to deal with
just a few efficiently,
before additional "storage" must be allocated somewhere else, leading to
contention. Does that
apply to that BEGIN+EXCEPTION mechanism too?
Thanks for any insights. --DD
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: ddevienne@gmail.com, ewie@ewie.name, domenico.l76@gmail.com
Subject: Re: rollback to savepoint issue
In-Reply-To: <CAFCRh--7b92tMA1OSfnOp7pTu9O2rtSW1N-0HjWkn2XA-MeCUQ@mail.gmail.com>
References: <CAJMpnG7DAcz4ckE_GGN4VkjaJvzVrdwCYwjH+ocLnVVYvb-fcQ@mail.gmail.com> <1341766181.156278.1693831501720@office.mailbox.org> <CAFCRh--7b92tMA1OSfnOp7pTu9O2rtSW1N-0HjWkn2XA-MeCUQ@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox