I'm studying Postgres by reading the docs, and section 3.4 says this:
"Keep in mind that either releasing or rolling back to a savepoint will automatically release all savepoints that were defined after it.
https://postgresql.org/docs/current/tutorial-transactions.html
Surely they mean "will automatically release OR ROLLBACK all savepoints"?
It would make no sense to release (which means commit) a savepoint that you're rolling back past, right?
Releasing a savepoint does not alter table data nor does it undo any work that is part of the current transaction: it just discards the information necessary to ROLLBACK
to that savepoint. Any savepoints that were created after the released savepoint are also released.
Performing a ROLLBACK TO SAVEPOINT
effectively restores the current transaction to the state that existed when the savepoint was defined; therefore, savepoints that were created after the ROLLBACK
savepoint are released because the transaction is no longer capable of restoring the state of those savepoints.
Performing a COMMIT
releases all savepoints.