3B001
PostgreSQLERRORNotableSavepoint ExceptionHIGH confidence
invalid savepoint specification
What this means
SQLSTATE 3B001 is raised when a ROLLBACK TO SAVEPOINT or RELEASE SAVEPOINT command references a savepoint name that does not exist in the current transaction.
Why it happens
- 1ROLLBACK TO SAVEPOINT or RELEASE SAVEPOINT specifying a name that was never created in the current transaction
- 2Savepoint name created before the transaction was rolled back to an earlier point (removing the savepoint)
How to reproduce
ROLLBACK TO a non-existent savepoint.
trigger — this will error
trigger — this will error
BEGIN; SAVEPOINT sp1; ROLLBACK TO SAVEPOINT sp2; -- sp2 was never created
expected output
ERROR: no such savepoint "sp2"
Fix
Create the savepoint before rolling back to it
WHEN When using savepoints for partial transaction recovery.
Create the savepoint before rolling back to it
BEGIN; SAVEPOINT sp1; -- risky work ROLLBACK TO SAVEPOINT sp1; -- valid: sp1 was created RELEASE SAVEPOINT sp1; COMMIT;
Why this works
SAVEPOINT creates the savepoint; ROLLBACK TO restores it; RELEASE removes it. Always create before referencing.
Sources
Official documentation ↗
Class 3B — Savepoint Exception
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev