| From: | PG Doc comments form <noreply(at)postgresql(dot)org> |
|---|---|
| To: | pgsql-docs(at)lists(dot)postgresql(dot)org |
| Cc: | sebastien(dot)flaesch(at)4js(dot)com |
| Subject: | Missing example for SAVEPOINT using the same savepoint name |
| Date: | 2022-04-11 16:00:08 |
| Message-ID: | 164969280899.834802.7458840197227864320@wrigleys.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-docs |
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 ....
| From | Date | Subject | |
|---|---|---|---|
| Next Message | David G. Johnston | 2022-04-12 03:21:49 | Re: Update wording of INSERT ON CONFLICT "rows proposed for insertion" |
| Previous Message | David G. Johnston | 2022-04-09 19:50:59 | Re: 41.3. Materialized Views: Create table should be create view? |