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 "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.

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 may still be able to infer what to do from the error class.

Table A-1 lists all the error codes defined in PostgreSQL 7.4.8. (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 "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.

Table A-1. PostgreSQL Error Codes

Error CodeMeaning
Class 00Successful Completion
00000SUCCESSFUL COMPLETION
Class 01Warning
01000WARNING
0100CWARNING DYNAMIC RESULT SETS RETURNED
01008WARNING IMPLICIT ZERO BIT PADDING
01003WARNING NULL VALUE ELIMINATED IN SET FUNCTION
01004WARNING STRING DATA RIGHT TRUNCATION
Class 02No Data --- this is also a warning class per SQL99
02000NO DATA
02001NO ADDITIONAL DYNAMIC RESULT SETS RETURNED
Class 03SQL Statement Not Yet Complete
03000SQL STATEMENT NOT YET COMPLETE
Class 08Connection Exception
08000CONNECTION EXCEPTION
08003CONNECTION DOES NOT EXIST
08006CONNECTION FAILURE
08001SQLCLIENT UNABLE TO ESTABLISH SQLCONNECTION
08004SQLSERVER REJECTED ESTABLISHMENT OF SQLCONNECTION
08007TRANSACTION RESOLUTION UNKNOWN
08P01PROTOCOL VIOLATION
Class 09Triggered Action Exception
09000TRIGGERED ACTION EXCEPTION
Class 0AFeature Not Supported
0A000FEATURE NOT SUPPORTED
Class 0BInvalid Transaction Initiation
0B000INVALID TRANSACTION INITIATION
Class 0FLocator Exception
0F000LOCATOR EXCEPTION
0F001INVALID SPECIFICATION
Class 0LInvalid Grantor
0L000INVALID GRANTOR
0LP01INVALID GRANT OPERATION
Class 0PInvalid Role Specification
0P000INVALID ROLE SPECIFICATION
Class 21Cardinality Violation
21000CARDINALITY VIOLATION
Class 22Data Exception
22000DATA EXCEPTION
2202EARRAY ELEMENT ERROR
22021CHARACTER NOT IN REPERTOIRE
22008DATETIME FIELD OVERFLOW
22012DIVISION BY ZERO
22005ERROR IN ASSIGNMENT
2200BESCAPE CHARACTER CONFLICT
22022INDICATOR OVERFLOW
22015INTERVAL FIELD OVERFLOW
22018INVALID CHARACTER VALUE FOR CAST
22007INVALID DATETIME FORMAT
22019INVALID ESCAPE CHARACTER
2200DINVALID ESCAPE OCTET
22025INVALID ESCAPE SEQUENCE
22010INVALID INDICATOR PARAMETER VALUE
22020INVALID LIMIT VALUE
22023INVALID PARAMETER VALUE
2201BINVALID REGULAR EXPRESSION
22009INVALID TIME ZONE DISPLACEMENT VALUE
2200CINVALID USE OF ESCAPE CHARACTER
2200GMOST SPECIFIC TYPE MISMATCH
22004NULL VALUE NOT ALLOWED
22002NULL VALUE NO INDICATOR PARAMETER
22003NUMERIC VALUE OUT OF RANGE
22026STRING DATA LENGTH MISMATCH
22001STRING DATA RIGHT TRUNCATION
22011SUBSTRING ERROR
22027TRIM ERROR
22024UNTERMINATED C STRING
2200FZERO LENGTH CHARACTER STRING
22P01FLOATING POINT EXCEPTION
22P02INVALID TEXT REPRESENTATION
22P03INVALID BINARY REPRESENTATION
22P04BAD COPY FILE FORMAT
22P05UNTRANSLATABLE CHARACTER
Class 23Integrity Constraint Violation
23000INTEGRITY CONSTRAINT VIOLATION
23001RESTRICT VIOLATION
23502NOT NULL VIOLATION
23503FOREIGN KEY VIOLATION
23505UNIQUE VIOLATION
23514CHECK VIOLATION
Class 24Invalid Cursor State
24000INVALID CURSOR STATE
Class 25Invalid Transaction State
25000INVALID TRANSACTION STATE
25001ACTIVE SQL TRANSACTION
25002BRANCH TRANSACTION ALREADY ACTIVE
25008HELD CURSOR REQUIRES SAME ISOLATION LEVEL
25003INAPPROPRIATE ACCESS MODE FOR BRANCH TRANSACTION
25004INAPPROPRIATE ISOLATION LEVEL FOR BRANCH TRANSACTION
25005NO ACTIVE SQL TRANSACTION FOR BRANCH TRANSACTION
25006READ ONLY SQL TRANSACTION
25007SCHEMA AND DATA STATEMENT MIXING NOT SUPPORTED
25P01NO ACTIVE SQL TRANSACTION
25P02IN FAILED SQL TRANSACTION
Class 26Invalid SQL Statement Name
26000INVALID SQL STATEMENT NAME
Class 27Triggered Data Change Violation
27000TRIGGERED DATA CHANGE VIOLATION
Class 28Invalid Authorization Specification
28000INVALID AUTHORIZATION SPECIFICATION
Class 2BDependent Privilege Descriptors Still Exist
2B000DEPENDENT PRIVILEGE DESCRIPTORS STILL EXIST
2BP01DEPENDENT OBJECTS STILL EXIST
Class 2DInvalid Transaction Termination
2D000INVALID TRANSACTION TERMINATION
Class 2FSQL Routine Exception
2F000SQL ROUTINE EXCEPTION
2F005FUNCTION EXECUTED NO RETURN STATEMENT
2F002MODIFYING SQL DATA NOT PERMITTED
2F003PROHIBITED SQL STATEMENT ATTEMPTED
2F004READING SQL DATA NOT PERMITTED
Class 34Invalid Cursor Name
34000INVALID CURSOR NAME
Class 38External Routine Exception
38000EXTERNAL ROUTINE EXCEPTION
38001CONTAINING SQL NOT PERMITTED
38002MODIFYING SQL DATA NOT PERMITTED
38003PROHIBITED SQL STATEMENT ATTEMPTED
38004READING SQL DATA NOT PERMITTED
Class 39External Routine Invocation Exception
39000EXTERNAL ROUTINE INVOCATION EXCEPTION
39001INVALID SQLSTATE RETURNED
39004NULL VALUE NOT ALLOWED
39P01TRIGGER PROTOCOL VIOLATED
39P02SRF PROTOCOL VIOLATED
Class 3DInvalid Catalog Name
3D000INVALID CATALOG NAME
Class 3FInvalid Schema Name
3F000INVALID SCHEMA NAME
Class 40Transaction Rollback
40000TRANSACTION ROLLBACK
40002INTEGRITY CONSTRAINT VIOLATION
40001SERIALIZATION FAILURE
40003STATEMENT COMPLETION UNKNOWN
40P01DEADLOCK DETECTED
Class 42Syntax Error or Access Rule Violation
42000SYNTAX ERROR OR ACCESS RULE VIOLATION
42601SYNTAX ERROR
42501INSUFFICIENT PRIVILEGE
42846CANNOT COERCE
42803GROUPING ERROR
42830INVALID FOREIGN KEY
42602INVALID NAME
42622NAME TOO LONG
42939RESERVED NAME
42804DATATYPE MISMATCH
42P18INDETERMINATE DATATYPE
42809WRONG OBJECT TYPE
42703UNDEFINED COLUMN
42883UNDEFINED FUNCTION
42P01UNDEFINED TABLE
42P02UNDEFINED PARAMETER
42704UNDEFINED OBJECT
42701DUPLICATE COLUMN
42P03DUPLICATE CURSOR
42P04DUPLICATE DATABASE
42723DUPLICATE FUNCTION
42P05DUPLICATE PSTATEMENT
42P06DUPLICATE SCHEMA
42P07DUPLICATE TABLE
42712DUPLICATE ALIAS
42710DUPLICATE OBJECT
42702AMBIGUOUS COLUMN
42725AMBIGUOUS FUNCTION
42P08AMBIGUOUS PARAMETER
42P09AMBIGUOUS ALIAS
42P10INVALID COLUMN REFERENCE
42611INVALID COLUMN DEFINITION
42P11INVALID CURSOR DEFINITION
42P12INVALID DATABASE DEFINITION
42P13INVALID FUNCTION DEFINITION
42P14INVALID PSTATEMENT DEFINITION
42P15INVALID SCHEMA DEFINITION
42P16INVALID TABLE DEFINITION
42P17INVALID OBJECT DEFINITION
Class 44WITH CHECK OPTION Violation
44000WITH CHECK OPTION VIOLATION
Class 53Insufficient Resources
53000INSUFFICIENT RESOURCES
53100DISK FULL
53200OUT OF MEMORY
53300TOO MANY CONNECTIONS
Class 54Program Limit Exceeded
54000PROGRAM LIMIT EXCEEDED
54001STATEMENT TOO COMPLEX
54011TOO MANY COLUMNS
54023TOO MANY ARGUMENTS
Class 55Object Not In Prerequisite State
55000OBJECT NOT IN PREREQUISITE STATE
55006OBJECT IN USE
55P02CANT CHANGE RUNTIME PARAM
Class 57Operator Intervention
57000OPERATOR INTERVENTION
57014QUERY CANCELED
57P01ADMIN SHUTDOWN
57P02CRASH SHUTDOWN
57P03CANNOT CONNECT NOW
Class 58System Error (errors external to PostgreSQL itself)
58030IO ERROR
58P01UNDEFINED FILE
58P02DUPLICATE FILE
Class F0Configuration File Error
F0000CONFIG FILE ERROR
F0001LOCK FILE EXISTS
Class XXInternal Error
XX000INTERNAL ERROR
XX001DATA CORRUPTED
XX002INDEX CORRUPTED