4 ROLLBACK TO SAVEPOINT — roll back to a savepoint
8 ROLLBACK [ WORK | TRANSACTION ] TO [ SAVEPOINT ] savepoint_name
12 Roll back all commands that were executed after the savepoint was
13 established and then start a new subtransaction at the same transaction
14 level. The savepoint remains valid and can be rolled back to again
17 ROLLBACK TO SAVEPOINT implicitly destroys all savepoints that were
18 established after the named savepoint.
23 The savepoint to roll back to.
27 Use RELEASE SAVEPOINT to destroy a savepoint without discarding the
28 effects of commands executed after it was established.
30 Specifying a savepoint name that has not been established is an error.
32 Cursors have somewhat non-transactional behavior with respect to
33 savepoints. Any cursor that is opened inside a savepoint will be closed
34 when the savepoint is rolled back. If a previously opened cursor is
35 affected by a FETCH or MOVE command inside a savepoint that is later
36 rolled back, the cursor remains at the position that FETCH left it
37 pointing to (that is, the cursor motion caused by FETCH is not rolled
38 back). Closing a cursor is not undone by rolling back, either. However,
39 other side-effects caused by the cursor's query (such as side-effects
40 of volatile functions called by the query) are rolled back if they
41 occur during a savepoint that is later rolled back. A cursor whose
42 execution causes a transaction to abort is put in a cannot-execute
43 state, so while the transaction can be restored using ROLLBACK TO
44 SAVEPOINT, the cursor can no longer be used.
48 To undo the effects of the commands executed after my_savepoint was
50 ROLLBACK TO SAVEPOINT my_savepoint;
52 Cursor positions are not affected by savepoint rollback:
55 DECLARE foo CURSOR FOR SELECT 1 UNION SELECT 2;
64 ROLLBACK TO SAVEPOINT foo;
75 The SQL standard specifies that the key word SAVEPOINT is mandatory,
76 but PostgreSQL and Oracle allow it to be omitted. SQL allows only WORK,
77 not TRANSACTION, as a noise word after ROLLBACK. Also, SQL has an
78 optional clause AND [ NO ] CHAIN which is not currently supported by
79 PostgreSQL. Otherwise, this command conforms to the SQL standard.
83 BEGIN, COMMIT, RELEASE SAVEPOINT, ROLLBACK, SAVEPOINT