diff --git a/doc/src/sgml/advanced.sgml b/doc/src/sgml/advanced.sgml
index ae5f3fac75..9ef9abf07d 100644
--- a/doc/src/sgml/advanced.sgml
+++ b/doc/src/sgml/advanced.sgml
@@ -247,7 +247,13 @@ COMMIT;
is sometimes called a transaction block.
+
+ Issuing ROLLBACK is only mandatory if you wish to end an otherwise
+ successfully executed transaction by rolling back its work. Issuing
+ COMMIT on an aborted transaction will cause a rollback to occur
+ anyways.
+
Some client libraries issue BEGIN and COMMIT
commands automatically, so that you might get the effect of transaction
@@ -256,14 +262,16 @@ COMMIT;
+ Sub-Transactions via Savepoints
+
It's possible to control the statements in a transaction in a more
granular fashion through the use of savepoints. Savepoints
allow you to selectively discard parts of the transaction, while
committing the rest. After defining a savepoint with
- SAVEPOINT, you can if needed roll back to the savepoint
+ SAVEPOINT, you can roll back to the savepoint
with ROLLBACK TO. All the transaction's database changes
- between defining the savepoint and rolling back to it are discarded, but
+ between defining the savepoint and rolling back to it are discarded while
changes earlier than the savepoint are kept.
@@ -272,8 +280,8 @@ COMMIT;
roll back to it several times. Conversely, if you are sure you won't need
to roll back to a particular savepoint again, it can be released, so the
system can free some resources. Keep in mind that either releasing or
- rolling back to a savepoint
- will automatically release all savepoints that were defined after it.
+ rolling back to a savepoint will automatically release or rollback,
+ respectively, all savepoints that were defined after it.
diff --git a/doc/src/sgml/ref/begin.sgml b/doc/src/sgml/ref/begin.sgml
index c23bbfb4e7..7cdd272974 100644
--- a/doc/src/sgml/ref/begin.sgml
+++ b/doc/src/sgml/ref/begin.sgml
@@ -49,6 +49,14 @@ BEGIN [ WORK | TRANSACTION ] [ transaction_mode
+ Sub-transactions are created using .
+ These are of particular use for client software to use when executing
+ user-supplied SQL statements and want to provide try/catch behavior.
+ See the advanced tutorial section
+ to learn how tranasctions and sub-transactions work in practice.
+
+
+
Statements are executed more quickly in a transaction block, because
transaction start/commit requires significant CPU and disk
activity. Execution of multiple statements inside a transaction is
diff --git a/doc/src/sgml/ref/commit.sgml b/doc/src/sgml/ref/commit.sgml
index b2e8d5d180..8bb368b771 100644
--- a/doc/src/sgml/ref/commit.sgml
+++ b/doc/src/sgml/ref/commit.sgml
@@ -29,9 +29,11 @@ COMMIT [ WORK | TRANSACTION ]
Description
- COMMIT commits the current transaction. All
+ COMMIT ends the current transaction. All
changes made by the transaction become visible to others
- and are guaranteed to be durable if a crash occurs.
+ and are guaranteed to be durable if a crash occurs. However,
+ if the transaction has failed a
+ will be processed instead.
diff --git a/doc/src/sgml/ref/savepoint.sgml b/doc/src/sgml/ref/savepoint.sgml
index 87243b1d20..66cee63966 100644
--- a/doc/src/sgml/ref/savepoint.sgml
+++ b/doc/src/sgml/ref/savepoint.sgml
@@ -41,7 +41,8 @@ SAVEPOINT savepoint_name
A savepoint is a special mark inside a transaction that allows all commands
that are executed after it was established to be rolled back, restoring
- the transaction state to what it was at the time of the savepoint.
+ the transaction state to what it was at the time of the savepoint. It can be
+ thought of as a kind of a pseudo sub-transaction.
@@ -74,6 +75,11 @@ SAVEPOINT savepoint_name
Savepoints can only be established when inside a transaction block.
There can be multiple savepoints defined within a transaction.
+
+
+ psql makes use of savepoints to implment its
+ ON_ERROR_ROLLBACK behavior.
+