All messages sent by the PostgreSQL server are given a five-character error code that follows the custom of the SQL "SQLSTATE" code. Apps that need to know what error conditions are occurring should usually test the error code instead of the text error message. These error codes are not easily modified with the version of PostgreSQL, and generally do not change as the error message is localized. Note that some, but not all,PostgreSQL generated error codes are defined by the SQL standard; some standards do not define error conditions that we invented or borrowed from other databases.
By Standard, the first two characters of the error code represent the error category, and the second three characters represent a specific condition within that category. Therefore, applications that do not recognize specific error codes can still infer what to do from the error category.
Table A-1 contains all the error codes defined by PostgreSQL 8.1. (some are not actually used at this time, but the SQL standard defines it.) The error category is also listed here. There is a "standard" error code for each error category, and its last three characters are. This code is only used for error conditions that fall within the category but do not give any more accurate code.
Pl/pgsql the condition name used for each error code is the same as the one shown in the table, with an underscore instead of whitespace. For example, code 22012, division by ZERO, its condition name is Division_by_zero. Conditional names can be written in uppercase or lowercase. (Note that Pl/pgsql does not recognize the warning, which is the opposite of the error, the condition name; those categories are 00, 01, and 02.) )
Code meaning
class 00 completed successfully
00000 Successful completion (successful completion)
Class 01 Warning
01000 Warning (WARNING)
0100C returns dynamic result sets returned
01008 warning, implied 0 bit (implicit ZERO bit PADDING)
01003 elimination of NULL values in aggregate functions (null value eliminated in Set function)
01007 No permissions granted (PRIVILEGE not granted)
01006 no revoke permission (PRIVILEGE not revoked)
01004 string data truncated at right end (string truncation)
Characteristics of 01P01 abandonment (DEPRECATED FEATURE)
Class 02 has no data-this is also a warning class, as required by the SQL standard
02000 No data
02001 returned no additional dynamic result set (no ADDITIONAL-result sets returned)
Class 03 SQL statement has not ended
03000 SQL statement has not ended (SQL STATEMENT not yet complete)
08 Class Connection Exceptions
08000 Connection Exceptions (CONNECTION EXCEPTION)
08003 connection does not exist (CONNECTION DOES not EXIST)
08006 connection failure (CONNECTION FAILURE)
08001 SQL Client cannot establish SQL connection (SQLCLIENT unable to establish SQLCONNECTION)
08004 SQL Server refuses to establish SQL connection (SQL rejected establishment of SQLCONNECTION)
08007 Unknown transaction resolution (TRANSACTION RESOLUTION UNKNOWN)
08P01 violation Agreement (PROTOCOL violation)
09-Class trigger actions out-of-column
09000 triggered action exception (triggered action EXCEPTION)
0 Class A does not support features
0A000 does not support this attribute (FEATURE not supported)
0 Class B Illegal transaction initialization
0b000 illegal transaction initialization (INVALID TRANSACTION initiation)
0F Class Indicator exceptions
0f000 Indicator Exception (LOCATOR EXCEPTION)
0f001 Illegal Locator Declaration (INVALID LOCATOR specification)
Category 0L Illegal empowering person
0l000 Illegal empowering person (INVALID grantor)
0LP01 illegal assignment operation (INVALID GRANT operation)
0P category Illegal role declaration
0p000 illegal role statement (INVALID role specification)
21 Class potential violations
21000 potential violations (cardinality violation)
22 Class Data exceptions
22000 Data Exceptions (EXCEPTION)
2202E Array subscript error (array subscript error)
22021 characters not within the Ready range (CHARACTER not in repertoire)
22008 Date-Time field overflow (DATETIME-field OVERFLOW)
22012 by 0 except (division by ZERO)
22005 Error in assignment (Error in Assignment)
2200B escape character clash (Escape CHARACTER CONFLICT)
22022 indicator Overflow (INDICATOR OVERFLOW)
22015 internal field overflow (INTERVAL field OVERFLOW)
2201E illegal parameters for logarithmic operation (INVALID ARGUMENT for logarithm)
Illegal parameters for 2201F exponential function (INVALID ARGUMENT for POWER function)
Illegal parameters for 2201G wide bucket functions (INVALID ARGUMENT for width bucket function)
22018 Invalid character value for type conversion (INVALID CHARACTER value for CAST)
22007 illegal datetime formats (INVALID DATETIME format)
22019 illegal escape character (INVALID escape CHARACTER)
2200D illegal Escape byte (INVALID escape OCTET)
22025 illegal escape sequence (INVALID escape SEQUENCE)
22P06 non-standard using escape character (nonstandard use of escape CHARACTER)
22010 Illegal indicator parameter value (INVALID INDICATOR PARAMETER value)
22020 illegal limit value (INVALID limit value)
22023 Illegal parameter value (INVALID PARAMETER value)
2201B illegal Regular expression (INVALID REGULAR expression)
22009 illegal timezone display value (INVALID time zone displacement value)
2200C illegally using escape characters (INVALID use of escape CHARACTER)
2200G most relevant type mismatch (most specific type mismatch)
22004 Null values not allowed (null value not allowed)
22002 null value cannot do indicator parameter (null value no INDICATOR PARAMETER)
22003 numeric value out of range (NUMERIC value out of range)
22026 string data length mismatch (string, length mismatch)
22001 string data is truncated to the right (string truncation)
22011 Extracting substring errors (SUBSTRING error)
22027 Truncation error (TRIM error)
22024 end of C string (unterminated C string)
2200F 0-length string (ZERO length CHARACTER string)
22P01 Float Exception (floating point EXCEPTION)
22P02 illegal text representation (INVALID text representation)
22P03 illegal binary representation (INVALID binary representation)
22P04 Error in copy format (bad copy, FILE format)
22P05 non-translatable characters (untranslatable CHARACTER)
Class 23 Violation Integrity constraints
23000 violation of integrity constraints (INTEGRITY CONSTRAINT violation)
23001 violation of restrictions (RESTRICT violation)
23502 violation of non-null (NOT NULL violation)
23503 violation of FOREIGN KEY constraint (FOREIGN key violation)
23505 violation of UNIQUE constraint (unique violation)
23514 breach Check (check violation)
Class 24 Illegal cursor states
24000 illegal cursor states (INVALID cursor State)
25 types of illegal transaction status
25000 illegal transaction status (INVALID TRANSACTION state)
25001 Active SQL status (active SQL TRANSACTION)
25002 Branch Transaction activated (BRANCH TRANSACTION already active)
25008 held cursors require the same isolation level (HELD cursor REQUIRES same isolation levels)
25003 inappropriate access to branch transactions (inappropriate access mode for BRANCH TRANSACTION)
25004 inappropriate isolation levels for branch transactions (inappropriate isolation level for BRANCH TRANSACTION)
25005 Branch transactions do not have an active SQL transaction (no active SQL TRANSACTION for BRANCH TRANSACTION)
25,006 read-only SQL transactions (read only SQL TRANSACTION)
25007 mixed schemas and data statements are not supported (schema and STATEMENT MIXING not supported)
25P01 no active SQL transaction (no active SQL TRANSACTION)
25P02 in a failed SQL transaction (in FAILED SQL TRANSACTION)
Class 26 Illegal SQL statement name
26000 Illegal SQL statement name (INVALID SQL STATEMENT name)
27 class triggered data change violation
27000 triggered data change violation (triggered violation)
Category 28 Unlawful authorization statement
28000 Unlawful Authorization Statement (INVALID AUTHORIZATION specification)
2 Class B still has a dependency priority descriptor
2b000 still has a dependent priority descriptor (DEPENDENT PRIVILEGE descriptors still EXIST)
2bp01 dependency object still exists (DEPENDENT OBJECTS still EXIST)
The end of a class of illegal transactions
2d000 illegal termination of business (INVALID TRANSACTION termination)
2F class SQL Procedure exceptions
2f000 SQL procedure exception (SQL ROUTINE EXCEPTION)
2f005 executed function does not return statements (function EXECUTED no return STATEMENT)
2f002 not allowed to modify SQL data (modifying SQL database not permitted)
2f003 attempted to use a forbidden SQL statement (prohibited SQL STATEMENT attempted)
2f004 not allowed to read SQL data (READING SQL database not permitted)
Class 34 Illegal cursor name
34000 illegal cursor name (INVALID cursor name)
Class 38 External Procedure exception
38000 External Process exceptions (EXTERNAL ROUTINE EXCEPTION)
38001 contains SQL not allowed (containing SQL not permitted)
38002 SQL data is not allowed to be modified (modifying SQL permitted)
38003 attempts to use a forbidden SQL statement (prohibited SQL STATEMENT attempted)
38004 not allowed to read SQL data (READING SQL database not permitted)
39 Class External procedure Call exception
39000 External Procedure Call exception (EXTERNAL ROUTINE invocation EXCEPTION)
39001 returned to the illegal SQLSTATE (INVALID SQLSTATE returned)
39004 null value not allowed (null value not allowed)
39P01 violation of Trigger protocol (TRIGGER PROTOCOL violated)
39P02 violation of the SRF agreement (SRF PROTOCOL violated)
3 Class B Save Point exception
3b000 Save Point Exception (SavePoint EXCEPTION)
3B001 Invalid save point Declaration (INVALID savepoint specification)
The name of the three-class illegal database
3d000 Illegal database name (INVALID CATALOG name)
3F class Illegal Mode name
3f000 illegal Mode name (INVALID schema name)
40-Class Transaction rollback
40000 transaction rollback (TRANSACTION ROLLBACK)
40002 violation of Transaction integrity constraints (TRANSACTION INTEGRITY CONSTRAINT violation)
40001 serialization Failure (serialization FAILURE)
40003 do not know if the statement is over (STATEMENT completion UNKNOWN)
40P01 detects a deadlock (DEADLOCK detected)
42 class syntax errors or violation of access rules
42000 syntax error or violation of access rule (SYNTAX error or access rule violation)
42601 syntax error (SYNTAX error)
42501 Insufficient permissions (insufficient PRIVILEGE)
42846 Unable to type convert (cannot coerce)
42803 Grouping errors (GROUPING error)
42830 illegal foreign keys (INVALID FOREIGN key)
42602 illegal names (INVALID name)
42,622 name is too long (name TOO long)
42939 reserved Name (RESERVED name)
42804 data type mismatch (DATATYPE mismatch)
42P18 pending data types (indeterminate DATATYPE)
42809 Wrong object type (wrong.
42703 undefined field (UNDEFINED COLUMN)
42883 undefined functions (UNDEFINED function)
42P01 table not defined (UNDEFINED table)
42P02 undefined parameter (UNDEFINED PARAMETER)
42704 undefined Objects (UNDEFINED object)
42701 repeating fields (DUPLICATE COLUMN)
42P03 Duplicate cursor (DUPLICATE cursor)
42P04 Duplicate databases (DUPLICATE database))
42723 repeating functions (DUPLICATE function)
42P05 Duplicate prepared statement (DUPLICATE PREPARED STATEMENT)
42p06 repeating pattern (DUPLICATE schema)
42p07 repeating table (DUPLICATE table)
42712 Duplicate aliases (DUPLICATE alias)
42710 Duplicate objects (DUPLICATE object)
42702 ambiguous fields (ambiguous COLUMN)
42725 fuzzy functions (ambiguous function)
42p08 fuzzy parameters (ambiguous PARAMETER)
42p09 ambiguous alias (ambiguous alias)
42P10 illegal field reference (INVALID COLUMN REFERENCE)
42611 illegal field definitions (INVALID COLUMN definition)
42P11 illegal cursor definition (INVALID cursor definition)
42P12 illegal database definition (INVALID)
42P13 illegal functions definition (INVALID function definition)
42P14 illegally prepared statement definitions (INVALID PREPARED STATEMENT definition)
42P15 illegal schema definition (INVALID schema definition)
42P16 Illegal table definitions (INVALID tables definition)
42P17 illegal objects definition (INVALID object definition)
Class 44 violates with CHECK option
44000 violation with CHECK option violation
53 types of resources not enough
53000 insufficient resources (insufficient)
53100 Disk Full
53200 memory exhaustion (out of memories)
53300 Too many connections (TOO many CONNECTIONS)
Class 54 exceeds program limit
54000 exceeding program limit exceeded
54001 statement too complex (STATEMENT TOO COMPLEX)
54011 too many fields (TOO many COLUMNS)
54023 Too many parameters (TOO many ARGUMENTS)
Class 55 objects are not in a pre-requested State
55000 object is not in a pre-requested State (object is not in prerequisite)
55006 objects in use (object in using)
55P02 cannot modify runtime parameters (CANT change runtime PARAM)
55P03 Lock not available (lock not AVAILABLE)
Class 57 operator interference
57000 operator interferences (OPERATOR intervention)
57014 queries canceled (query CANCELED)
57P01 Administrator shutdown (admin SHUTDOWN)
57P02 crash shutdown (CRASH SHUTDOWN)
57P03 cannot connect now (cannot connect today)
Class 58 System error (PostgreSQL own internal error)
58030 IO errors (IO error)
58P01 files that are not defined (UNDEFINED file)
58P02 Duplicate files (DUPLICATE file)
F0 class configuration File Error
F0000 profile errors (config file error)
F0001 lock file exists (lock files EXISTS)
P0 Class Pl/pgsql Error
P0000 plpgsql errors (plpgsql error)
P0001 throws Exception (RAISE EXCEPTION)
XX Class Internal Error
XX000 Internal Error (INTERNAL error)
XX001 data corruption (corrupted)
XX002 index is corrupt (index corrupted)