public inbox for [email protected]
help / color / mirror / Atom feedFrom: Alvaro Herrera <[email protected]>
To: David G. Johnston <[email protected]>
Cc: PostgreSQL Hackers <[email protected]>
Subject: Re: Assorted small doc patches
Date: Thu, 21 Apr 2022 19:46:05 +0200
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAKFQuwby1aMsJDMeibaBaohgoaZhivAo4WcqHC1=9-GDZ3TSng@mail.gmail.com>
On 2022-Apr-20, David G. Johnston wrote:
> v0001-doc-savepoint-name-reuse (-docs, reply to user request for
> improvement)
> https://www.postgresql.org/message-id/CAKFQuwYzSb9OW5qTFgc0v9RWMN8bX83wpe8okQ7x6vtcmfA2KQ%40mail.gma...
This one is incorrect; rolling back to a savepoint does not remove the
savepoint, so if you ROLLBACK TO it again afterwards, you'll get the
same one again. In fact, Your proposed example doesn't work as your
comments intend.
The way to get the effect you show is to first RELEASE the second
savepoint, then roll back to the earliest one. Maybe like this:
BEGIN;
INSERT INTO table1 VALUES (1);
SAVEPOINT my_savepoint;
INSERT INTO table1 VALUES (2);
SAVEPOINT my_savepoint;
INSERT INTO table1 VALUES (3);
ROLLBACK TO SAVEPOINT my_savepoint;
SELECT * FROM table1; -- shows rows 1, 2
RELEASE SAVEPOINT my_savepoint; -- gets rid of the latest one without rolling back anything
ROLLBACK TO SAVEPOINT my_savepoint; -- rolls back to the earliest one
SELECT * FROM table1; -- just 1
COMMIT;
--
Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/
view thread (3+ messages)
reply
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 using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: Assorted small doc patches
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox