@@ -53,7 +53,9 @@ SAVEPOINT <replaceable>savepoint_name</replaceable>
53
53
<term><replaceable>savepoint_name</replaceable></term>
54
54
<listitem>
55
55
<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.
57
59
</para>
58
60
</listitem>
59
61
</varlistentry>
@@ -106,6 +108,32 @@ COMMIT;
106
108
</programlisting>
107
109
The above transaction will insert both 3 and 4.
108
110
</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
+
109
137
</refsect1>
110
138
111
139
<refsect1>
0 commit comments