Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit85e3287

Browse files
committed
doc: clarify the behavior of identically-named savepoints
Original patch by David G. Johnston.Reported-by: David G. JohnstonDiscussion:https://postgr.es/m/CAKFQuwYQCxSSuSL18skCWG8QHFswOJ3hjovHsOZUE346i4OpVQ@mail.gmail.comBackpatch-through: 10
1 parentebf0604 commit85e3287

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

‎doc/src/sgml/ref/release_savepoint.sgml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,9 @@ RELEASE [ SAVEPOINT ] <replaceable>savepoint_name</replaceable>
8282
</para>
8383

8484
<para>
85-
If multiple savepoints have the same name, only the one that was most
86-
recently defined is released.
85+
If multiple savepoints have the same name, only the most recently defined
86+
unreleased one is released. Repeated commands will release progressively
87+
older savepoints.
8788
</para>
8889

8990
</refsect1>

‎doc/src/sgml/ref/savepoint.sgml

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ SAVEPOINT <replaceable>savepoint_name</replaceable>
5353
<term><replaceable>savepoint_name</replaceable></term>
5454
<listitem>
5555
<para>
56-
The name to give to the new savepoint.
56+
The name to give to the new savepoint. If savepoints with the
57+
same name already exist, they will be inaccessible until newer
58+
identically-named savepoints are released.
5759
</para>
5860
</listitem>
5961
</varlistentry>
@@ -106,6 +108,32 @@ COMMIT;
106108
</programlisting>
107109
The above transaction will insert both 3 and 4.
108110
</para>
111+
112+
<para>
113+
To use a single savepoint name:
114+
<programlisting>
115+
BEGIN;
116+
INSERT INTO table1 VALUES (1);
117+
SAVEPOINT my_savepoint;
118+
INSERT INTO table1 VALUES (2);
119+
SAVEPOINT my_savepoint;
120+
INSERT INTO table1 VALUES (3);
121+
122+
-- rollback to the second savepoint
123+
ROLLBACK TO SAVEPOINT my_savepoint;
124+
SELECT * FROM table1; -- shows rows 1 and 2
125+
126+
-- release the second savepoint
127+
RELEASE SAVEPOINT my_savepoint;
128+
129+
-- rollback to the first savepoint
130+
ROLLBACK TO SAVEPOINT my_savepoint;
131+
SELECT * FROM table1; -- shows only row 1
132+
COMMIT;
133+
</programlisting>
134+
The above transaction shows row 3 being rolled back first, then row 2.
135+
</para>
136+
109137
</refsect1>
110138

111139
<refsect1>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp