@@ -21,7 +21,7 @@ PostgreSQL documentation
2121
2222 <refnamediv>
2323 <refname>RELEASE SAVEPOINT</refname>
24- <refpurpose>release a previously defined savepoint</refpurpose>
24+ <refpurpose>destroy a previously defined savepoint</refpurpose>
2525 </refnamediv>
2626
2727 <refsynopsisdiv>
@@ -34,13 +34,23 @@ RELEASE [ SAVEPOINT ] <replaceable>savepoint_name</replaceable>
3434 <title>Description</title>
3535
3636 <para>
37- <command>RELEASE SAVEPOINT</command> releases the named savepoint and
38- all active savepoints that were created after the named savepoint,
39- and frees their resources. All changes made since the creation of
40- the savepoint that didn't already get rolled back are merged into
41- the transaction or savepoint that was active when the named savepoint
42- was created. Changes made after <command>RELEASE SAVEPOINT</command>
43- will also be part of this active transaction or savepoint.
37+ <command>RELEASE SAVEPOINT</command> destroys a savepoint previously defined
38+ in the current transaction.
39+ </para>
40+
41+ <para>
42+ Destroying a savepoint makes it unavailable as a rollback point,
43+ but it has no other user visible behavior. It does not undo the
44+ effects of commands executed after the savepoint was established.
45+ (To do that, see <xref linkend="sql-rollback-to"/>.)
46+ Destroying a savepoint when
47+ it is no longer needed allows the system to reclaim some resources
48+ earlier than transaction end.
49+ </para>
50+
51+ <para>
52+ <command>RELEASE SAVEPOINT</command> also destroys all savepoints that were
53+ established after the named savepoint was established.
4454 </para>
4555 </refsect1>
4656
@@ -52,7 +62,7 @@ RELEASE [ SAVEPOINT ] <replaceable>savepoint_name</replaceable>
5262 <term><replaceable>savepoint_name</replaceable></term>
5363 <listitem>
5464 <para>
55- The name of the savepoint torelease .
65+ The name of the savepoint todestroy .
5666 </para>
5767 </listitem>
5868 </varlistentry>
@@ -68,7 +78,7 @@ RELEASE [ SAVEPOINT ] <replaceable>savepoint_name</replaceable>
6878
6979 <para>
7080 It is not possible to release a savepoint when the transaction is in
71- an aborted state; to do that, use <xref linkend="sql-rollback-to"/> .
81+ an aborted state.
7282 </para>
7383
7484 <para>
@@ -83,7 +93,7 @@ RELEASE [ SAVEPOINT ] <replaceable>savepoint_name</replaceable>
8393 <title>Examples</title>
8494
8595 <para>
86- To establish and laterrelease a savepoint:
96+ To establish and laterdestroy a savepoint:
8797<programlisting>
8898BEGIN;
8999 INSERT INTO table1 VALUES (3);
@@ -94,36 +104,6 @@ COMMIT;
94104</programlisting>
95105 The above transaction will insert both 3 and 4.
96106 </para>
97-
98- <para>
99- A more complex example with multiple nested subtransactions:
100- <programlisting>
101- BEGIN;
102- INSERT INTO table1 VALUES (1);
103- SAVEPOINT sp1;
104- INSERT INTO table1 VALUES (2);
105- SAVEPOINT sp2;
106- INSERT INTO table1 VALUES (3);
107- RELEASE SAVEPOINT sp2;
108- INSERT INTO table1 VALUES (4))); -- generates an error
109- </programlisting>
110- In this example, the application requests the release of the savepoint
111- <literal>sp2</literal>, which inserted 3. This changes the insert's
112- transaction context to <literal>sp1</literal>. When the statement
113- attempting to insert value 4 generates an error, the insertion of 2 and
114- 4 are lost because they are in the same, now-rolled back savepoint,
115- and value 3 is in the same transaction context. The application can
116- now only choose one of these two commands, since all other commands
117- will be ignored:
118- <programlisting>
119- ROLLBACK;
120- ROLLBACK TO SAVEPOINT sp1;
121- </programlisting>
122- Choosing <command>ROLLBACK</command> will abort everything, including
123- value 1, whereas <command>ROLLBACK TO SAVEPOINT sp1</command> will retain
124- value 1 and allow the transaction to continue.
125- </para>
126-
127107 </refsect1>
128108
129109 <refsect1>