SQLSTATE 25P01Severity lowLab verified

Incident brief

No active SQL transaction

A command that only makes sense inside an open transaction block was issued with none active. PostgreSQL rejected it instead of silently ignoring it.

Reproduced on PostgreSQL 16.14Verified 2026-07-16 (Docker lab, PostgreSQL 16.14)Reviewed by Verified against PostgreSQL 16.14 in an isolated lab environment

In 10 seconds

What
No active SQL transaction
What triggers it
Issue ROLLBACK AND CHAIN with no transaction block open.
The fix
Only issue AND CHAIN variants inside an already-open transaction block (after BEGIN).
Proof
Reproduced on PostgreSQL 16.14 → ROLLBACK AND CHAIN with no transaction block open was rejected with SQLSTATE 25P01. The session was unaffected afterward.

The fix

What to do right now

The immediate, application-level response to this error.

  • Only issue AND CHAIN variants inside an already-open transaction block (after BEGIN).
  • Plain COMMIT/ROLLBACK outside a transaction block are not an error at all — just a warning, see the premium test.
  • Don't 'fix' this by unconditionally prefixing a defensive BEGIN — see the counterexample for what that can silently discard.
Fix — SQL
BEGIN;
-- ... statements ...
ROLLBACK AND CHAIN;

Related & next steps

Follow the thread

Everything this error touches — jump straight to the sibling error, term, runbook, or parameter.

Verification

PG 16.14
Last verified
2026-07-16 (Docker lab, PostgreSQL 16.14)
Reviewed by
Verified against PostgreSQL 16.14 in an isolated lab environment
Audit status
reviewed