SQLSTATE 25P01 ERROR Class 25: Invalid Transaction State

no_active_sql_transaction RELEASE SAVEPOINT can only be used in transaction blocks — 25P01

PostgreSQL error "RELEASE SAVEPOINT can only be used in transaction blocks" (SQLSTATE 25P01): what it means, common causes, and how to fix it.

PG 12, 13, 14, 15, 16, 17, 18 Official docs
Last reviewed May 2025 Grounded in source

Diagnostic Queries

Symptoms

A RELEASE SAVEPOINT was issued outside an explicit transaction block. PostgreSQL raises SQLSTATE 25P01 (no_active_sql_transaction).

  • RELEASE SAVEPOINT used with no open transaction.
  • Savepoints exist only inside a transaction.
  • Common when BEGIN is missing or already committed.

What the server log shows

ERROR:  RELEASE SAVEPOINT can only be used in transaction blocks

Why PostgreSQL raises this — what the manual says

As the RELEASE SAVEPOINT reference (Description) explains:

RELEASE SAVEPOINT is only meaningful inside a transaction block, because savepoints exist only within an explicit transaction; issue it between BEGIN and COMMIT, after a matching SAVEPOINT command.

Releasing a savepoint operates on transaction state. With no active transaction, there is no savepoint to release, so PostgreSQL reports 25P01.

Common causes

  • Issuing RELEASE SAVEPOINT without a transaction open.
  • Autocommit mode.
  • The transaction was already committed/rolled back.

How to fix it

  1. Ensure a transaction is open (BEGIN) and the savepoint exists.
  2. Release the savepoint before committing the transaction.
  3. Disable autocommit where savepoints are used.

Related & next steps

Reference: PostgreSQL 18 — RELEASE SAVEPOINT.

Was this helpful?