On Sun, Jun 26, 2022 at 09:14:56AM -0700, David G. Johnston wrote:
> So leave the "release" behavior implied from the rollback behavior?
>
> On the whole I'm slightly in favor of your proposed wording (mostly due to the
> better fitting of the ROLLBACK command, though at the omission of RELEASE...)
> but are you seeing anything beyond personal style as to why you feel one is
> better than the other? Is there some existing wording in the docs that I
> should be conforming to here?
I have developed the attached patch based on the discussion here. I
tried to simplify the language and example to clarify the intent.
I was confused why the first part of the patch added a mention of
releasing savepoints to the ROLLBACK TO manual page --- I have removed
that and improved the text in RELEASE SAVEPOINT.
--
Bruce Momjian <[email protected]> https://momjian.us
EDB https://enterprisedb.com
Indecision is a decision. Inaction is an action. Mark Batterson
diff --git a/doc/src/sgml/ref/release_savepoint.sgml b/doc/src/sgml/ref/release_savepoint.sgml
index 39665d28ef..daf8eb9a43 100644
--- a/doc/src/sgml/ref/release_savepoint.sgml
+++ b/doc/src/sgml/ref/release_savepoint.sgml
@@ -82,8 +82,9 @@ RELEASE [ SAVEPOINT ] <replaceable>savepoint_name</replaceable>
</para>
<para>
- If multiple savepoints have the same name, only the one that was most
- recently defined is released.
+ If multiple savepoints have the same name, only the most recently defined
+ unreleased one is released. Repeated commands will release progressively
+ older savepoints.
</para>
</refsect1>
diff --git a/doc/src/sgml/ref/savepoint.sgml b/doc/src/sgml/ref/savepoint.sgml
index b17342a1ee..f84ac3d167 100644
--- a/doc/src/sgml/ref/savepoint.sgml
+++ b/doc/src/sgml/ref/savepoint.sgml
@@ -53,7 +53,9 @@ SAVEPOINT <replaceable>savepoint_name</replaceable>
<term><replaceable>savepoint_name</replaceable></term>
<listitem>
<para>
- The name to give to the new savepoint.
+ The name to give to the new savepoint. If savepoints with the
+ same name already exist, they will be inaccessible until newer
+ identically-named savepoints are released.
</para>
</listitem>
</varlistentry>
@@ -106,6 +108,32 @@ COMMIT;
</programlisting>
The above transaction will insert both 3 and 4.
</para>
+
+ <para>
+ To use a single savepoint name:
+<programlisting>
+BEGIN;
+ INSERT INTO table1 VALUES (1);
+ SAVEPOINT my_savepoint;
+ INSERT INTO table1 VALUES (2);
+ SAVEPOINT my_savepoint;
+ INSERT INTO table1 VALUES (3);
+
+ -- rollback to the second savepoint
+ ROLLBACK TO SAVEPOINT my_savepoint;
+ SELECT * FROM table1; -- shows rows 1 and 2
+
+ -- release the second savepoint
+ RELEASE SAVEPOINT my_savepoint;
+
+ -- rollback to the first savepoint
+ ROLLBACK TO SAVEPOINT my_savepoint;
+ SELECT * FROM table1; -- shows only row 1
+COMMIT;
+</programlisting>
+ The above transaction shows row 3 being rolled back first, then row 2.
+ </para>
+
</refsect1>
<refsect1>