PostgreSQL
Appendix A. PostgreSQL Error Codes
All messages emitted by the PostgreSQL server are assigned five-character error codes that follow the SQL standard’s conventions for “[.quote]#SQLSTATE”# codes. Applications that need to know which error condition has occurred should usually test the error code, rather than looking at the textual error message. The error codes are less likely to change across PostgreSQL releases, and also are not subject to change due to localization of error messages. Note that some, but not all, of the error codes produced by PostgreSQL are defined by the SQL standard; some additional error codes for conditions not defined by the standard have been invented or borrowed from other databases.
According to the standard, the first two characters of an error code denote a class of errors, while the last three characters indicate a specific condition within that class. Thus, an application that does not recognize the specific error code might still be able to infer what to do from the error class.
Table A.1 lists all the error codes defined in PostgreSQL 12.17. (Some are not actually used at present, but are defined by the SQL standard.) The error classes are also shown. For each error class there is a “[.quote]#standard”# error code having the last three characters 000
. This code is used only for error conditions that fall within the class but do not have any more-specific code assigned.
The symbol shown in the column “[.quote]#Condition Name”# is the condition name to use in PL/pgSQL. Condition names can be written in either upper or lower case. (Note that PL/pgSQL does not recognize warning, as opposed to error, condition names; those are classes 00, 01, and 02.)
For some types of errors, the server reports the name of a database object (a table, table column, data type, or constraint) associated with the error; for example, the name of the unique constraint that caused a unique_violation
error. Such names are supplied in separate fields of the error report message so that applications need not try to extract them from the possibly-localized human-readable text of the message. As of PostgreSQL 9.3, complete coverage for this feature exists only for errors in SQLSTATE class 23 (integrity constraint violation), but this is likely to be expanded in future.
Table A.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 |
|
|
|
|
|
|
|
+
Prev | Up | Next |
---|---|---|
Part VIII. Appendixes |
Appendix B. Date/Time Support |
Submit correction
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.
Copyright © 1996-2023 The PostgreSQL Global Development Group