Error codes
Each message emitted by the PostgreSQL server carries a five-character error code that follows the SQL standard's SQLSTATE convention. Test the error code in your application rather than parsing the text of the error message — codes are stable across PostgreSQL releases and are not affected by message localization.
The first two characters of an error code identify the error class; the last three characters identify the specific condition within that class. An application that does not recognize a specific code can still act on the class.
Table 1 lists all error codes defined in PostgreSQL 14.11. Some codes are reserved by the SQL standard but not currently used. Each error class includes a generic code ending in 000, used when no more-specific code applies.
Use condition names in PL/pgSQL exception handlers. Condition names are case-insensitive. PL/pgSQL does not recognize condition names for warning classes (00, 01, and 02).
For some errors, the server also reports the name of the database object associated with the error — for example, the name of the unique constraint that caused a unique_violation. These names appear in separate fields of the error report, not embedded in the human-readable message text.
Table 1. PostgreSQL error codes
|
Error code |
Condition name |
|
Class 00 — Successful completion |
|
|
|
|
|
Class 01 — Warning |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Class 02 — No data (this is also a warning class per the SQL standard) |
|
|
|
|
|
|
|
|
Class 03 — SQL statement not yet complete |
|
|
|
|
|
Class 08 — Connection exception |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Class 09 — Triggered action exception |
|
|
|
|
|
Class 0A — Feature not supported |
|
|
|
|
|
|
|
|
|
|
|
Class 0B — Invalid transaction initiation |
|
|
|
|
|
Class 0F — Locator exception |
|
|
|
|
|
|
|
|
Class 0L — Invalid grantor |
|
|
|
|
|
|
|
|
Class 0P — Invalid role specification |
|
|
|
|
|
Class 0Z — Diagnostics exception |
|
|
|
|
|
|
|
|
Class 20 — Case not found |
|
|
|
|
|
Class 21 — Cardinality violation |
|
|
|
|
|
Class 22 — Data exception |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Class 23 — Integrity constraint violation |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Class 24 — Invalid cursor state |
|
|
|
|
|
Class 25 — Invalid transaction state |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Class 26 — Invalid SQL statement name |
|
|
|
|
|
Class 27 — Triggered data change violation |
|
|
|
|
|
Class 28 — Invalid authorization specification |
|
|
|
|
|
|
|
|
Class 2B — Dependent privilege descriptors still exist |
|
|
|
|
|
|
|
|
Class 2D — Invalid transaction termination |
|
|
|
|
|
Class 2F — SQL routine exception |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Class 34 — Invalid cursor name |
|
|
|
|
|
Class 38 — External routine exception |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Class 39 — External routine invocation exception |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Class 3B — Savepoint exception |
|
|
|
|
|
|
|
|
Class 3D — Invalid catalog name |
|
|
|
|
|
Class 3F — Invalid schema name |
|
|
|
|
|
Class 40 — Transaction rollback |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Class 42 — Syntax error or access rule violation |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Class 44 — WITH CHECK OPTION violation |
|
|
|
|
|
Class 53 — Insufficient resources |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Class 54 — Program limit exceeded |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Class 55 — Object not in prerequisite state |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Class 57 — Operator intervention |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Class 58 — System error (errors external to PostgreSQL itself) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Class 72 — Snapshot failure |
|
|
|
|
|
Class F0 — Configuration file error |
|
|
|
|
|
|
|
|
Class HV — Foreign data wrapper error (SQL/MED) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Class P0 — PL/pgSQL error |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Class XX — Internal error |
|
|
|
|
|
|
|
|
|
|
|
Class PX — Internal error (PolarDB) |
|
|
|
|
|
Class SCC — SCC (PolarDB) |
|
|
|
|
|
|
|