Error 25005 is raised when a SAVEPOINT, RELEASE SAVEPOINT, or ROLLBACK TO SAVEPOINT is issued outside an active transaction block.
no_active_sql_transaction_for_branch_transaction (PostgreSQL 25005) means you called SAVEPOINT, RELEASE, or ROLLBACK TO when no BEGIN was in effect. Start a transaction with BEGIN before using savepoints, or remove the stray savepoint calls to resolve the error.
no_active_sql_transaction_for_branch_transaction
Error 25005 - no_active_sql_transaction_for_branch_transaction - appears when PostgreSQL receives a SAVEPOINT, RELEASE SAVEPOINT, or ROLLBACK TO SAVEPOINT command while no transaction block is currently open.
The server treats each connection as autocommit by default. Without an explicit BEGIN, there is no parent transaction to hold a branch (savepoint). PostgreSQL therefore halts the statement and raises 25005.
The message is common in ORMs or scripts that mix implicit and explicit transaction handling.
It often shows up after client code performs a commit, then tries to work with an earlier savepoint.
Long-running psql sessions that forgot a BEGIN can also trigger the error when developers enter SAVEPOINT by habit.
.
Yes. PostgreSQL requires an explicit transaction block to create or manage savepoints.
PostgreSQL allows multiple savepoints inside one transaction. Each can be rolled back independently.
Some ORMs auto-commit after each statement. Disable that behavior or manage transactions manually.
Galaxy spots orphaned savepoint statements in its linting pass and suggests inserting BEGIN or removing the command.