SQLSTATE P0001Severity lowLab verified

Incident brief

Raise exception

PL/pgSQL code called RAISE EXCEPTION with no explicit error code. PostgreSQL reported it under the default PL/pgSQL error code, P0001, and aborted the transaction.

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
Raise exception
What triggers it
Run a DO block (or function) containing RAISE EXCEPTION 'message'.
The fix
Read the message — P0001 is intentional application logic, not a PostgreSQL bug. Fix whatever condition triggered the RAISE.
Proof
Reproduced on PostgreSQL 16.14 → A plain RAISE EXCEPTION with a custom message and no ERRCODE was reported as SQLSTATE P0001, and the transaction aborted.

The fix

What to do right now

The immediate, application-level response to this error.

  • Read the message — P0001 is intentional application logic, not a PostgreSQL bug. Fix whatever condition triggered the RAISE.
  • If callers need to distinguish this error programmatically, give it a specific ERRCODE via RAISE ... USING ERRCODE = '...' instead of relying on the generic P0001.
Fix — SQL
RAISE EXCEPTION 'Account balance cannot be negative'
  USING ERRCODE = 'check_violation'; -- gives callers a specific, catchable code instead of generic P0001

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