3B001ERRORTier 2 — Caution✅ HIGH confidenceinvalid savepoint specification
Category: Savepoint ExceptionVersions: All Postgres versions
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
BEGIN;
SAVEPOINT sp1;
ROLLBACK TO SAVEPOINT sp2; -- sp2 was never createdERROR: no such savepoint "sp2"
Fix 1: Create the savepoint before rolling back to it
When using savepoints for partial transaction recovery.
fix
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 docs: https://www.postgresql.org/docs/current/errcodes-appendix.html
🔧 Source ref: Class 3B — Savepoint Exception
Confidence assessment
✅ HIGH confidence
Standard SQLSTATE for savepoint name errors. Stable across all versions.
See also
🔗 Related errors
📄 Reference pages
SAVEPOINTROLLBACK TO SAVEPOINTRELEASE SAVEPOINT
⚙️ This error reference was generated with AI assistance and reviewed for accuracy. Examples are provided to illustrate common scenarios and may not cover every case. Always test fixes in a development environment before applying to production. Spotted an error? Suggest a correction →