RELEASE_SAVEPOINT(7pg13)

πŸ“¦ version 13.23, in opensuse-leap 16.0

🌸 NAME 🌸

hey bestie πŸ’– this is the RELEASE_SAVEPOINT(7pg13) page from the PostgreSQL 13.23 Documentation, and it's literally about how to destroy a previously defined savepoint. no cap.


✨ SYNOPSIS ✨

RELEASE [ SAVEPOINT ] savepoint_name

πŸ’… DESCRIPTION πŸ’…

okay so RELEASE SAVEPOINT destroys a savepoint that you previously defined in the current transaction. iconic cleanup behavior, honestly.

Destroying a savepoint makes it unavailable as a rollback point, but it has no other user visible behavior. it does not undo the effects of commands executed after the savepoint was established. (to do that, see ROLLBACK TO SAVEPOINT (ROLLBACK_TO_SAVEPOINT(7)).) destroying a savepoint when it is no longer needed allows the system to reclaim some resources earlier than transaction end. love that for your resources 🫢

RELEASE SAVEPOINT also destroys all savepoints that were established after the named savepoint was established. yes bestie, it takes the whole little savepoint entourage with it πŸ’€


πŸŽ€ PARAMETERS πŸŽ€

  • savepoint_name β€” the name of the savepoint to destroy. that's the one, periodt.

πŸ¦‹ NOTES πŸ¦‹

  • specifying a savepoint name that was not previously defined is an error. rude? maybe. but valid.
  • it is not possible to release a savepoint when the transaction is in an aborted state. literally can't do it.
  • if multiple savepoints have the same name, only the most recently defined unreleased one is released. repeated commands will release progressively older savepoints. so it's giving "last in, first released" energy ✨

🌈 EXAMPLES 🌈

to establish and later destroy a savepoint:

BEGIN;
    INSERT INTO table1 VALUES (3);
    SAVEPOINT my_savepoint;
    INSERT INTO table1 VALUES (4);
    RELEASE SAVEPOINT my_savepoint;
COMMIT;

the above transaction will insert both 3 and 4. ate.


πŸ‘‘ COMPATIBILITY πŸ‘‘

this command conforms to the SQL standard. the standard specifies that the key word SAVEPOINT is mandatory, but PostgreSQL allows it to be omitted. PostgreSQL being flexible? we love to see it πŸ’–


🧚 SEE ALSO 🧚


and that's the PostgreSQL 13.23 docs, dated 2025, signing off πŸ’œβœ¨

πŸ“¦ where this page comes from