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 c1b3ef9306..7cdd272974 100644 --- a/doc/src/sgml/ref/begin.sgml +++ b/doc/src/sgml/ref/begin.sgml @@ -49,13 +49,11 @@ BEGIN [ WORK | TRANSACTION ] [ transaction_mode - Pseudo sub-transactions are created using . + 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 - where failures are ignored. The server cannot be configured to do this - automatically: all (sub-)transaction blocks either commit or rollback in their - entirety. A commit issued while the transaction has an active failure - is automatically converted into a . + 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.