public inbox for [email protected]  
help / color / mirror / Atom feed
From: PG Doc comments form <[email protected]>
To: [email protected]
Cc: [email protected]
Subject: Missing example for SAVEPOINT using the same savepoint name
Date: Mon, 11 Apr 2022 16:00:08 +0000
Message-ID: <[email protected]> (raw)

The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/14/sql-savepoint.html
Description:

The "Compatibility" section deserves some code example to illustrate the
behavior when reusing the same savepoint name.

Maybe this could help:

CREATE TABLE tab1 ( pk INT, name VARCHAR(50) );
BEGIN;
INSERT INTO tab1 VALUES (101,'aaa');
SAVEPOINT mysp; /* mysp #1 */
UPDATE tab1 SET name = 'bbb' WHERE pk = 101;
SAVEPOINT mysp; /* mysp #2 */
UPDATE tab1 SET name = 'ccc' WHERE pk = 101;
ROLLBACK TO SAVEPOINT mysp; /* rolls back to mysp #2 */
SELECT * FROM tab1 ORDER BY pk;
RELEASE SAVEPOINT mysp; /* releases mysp #2 */
ROLLBACK TO SAVEPOINT mysp; /* rolls back to mysp #1 */
SELECT * FROM tab1 ORDER BY pk;
COMMIT;
DROP TABLE tab1;

First SELECT will show 101/bbb, second will show 101/aaa ....


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: Missing example for SAVEPOINT using the same savepoint name
  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