1 <!-- doc/src/sgml/errcodes.sgml -->
3 <appendix id=
"errcodes-appendix">
4 <title><productname>PostgreSQL
</productname> Error Codes
</title>
6 <indexterm zone=
"errcodes-appendix">
7 <primary>error codes
</primary>
8 <secondary>list of
</secondary>
12 All messages emitted by the
<productname>PostgreSQL
</productname>
13 server are assigned five-character error codes that follow the SQL
14 standard's conventions for
<quote>SQLSTATE
</quote> codes. Applications
15 that need to know which error condition has occurred should usually
16 test the error code, rather than looking at the textual error
17 message. The error codes are less likely to change across
18 <productname>PostgreSQL
</productname> releases, and also are not subject to
19 change due to localization of error messages. Note that some, but
20 not all, of the error codes produced by
<productname>PostgreSQL
</productname>
21 are defined by the SQL standard; some additional error codes for
22 conditions not defined by the standard have been invented or
23 borrowed from other databases.
27 According to the standard, the first two characters of an error code
28 denote a class of errors, while the last three characters indicate
29 a specific condition within that class. Thus, an application that
30 does not recognize the specific error code might still be able to infer
31 what to do from the error class.
35 <xref linkend=
"errcodes-table"/> lists all the error codes defined in
36 <productname>PostgreSQL
</productname> &version;. (Some are not actually
37 used at present, but are defined by the SQL standard.)
38 The error classes are also shown. For each error class there is a
39 <quote>standard
</quote> error code having the last three characters
40 <literal>000</literal>. This code is used only for error conditions that fall
41 within the class but do not have any more-specific code assigned.
45 The symbol shown in the column
<quote>Condition Name
</quote> is
46 the condition name to use in
<application>PL/pgSQL
</application>. Condition
47 names can be written in either upper or lower case. (Note that
48 <application>PL/pgSQL
</application> does not recognize warning, as opposed to error,
49 condition names; those are classes
00,
01, and
02.)
53 For some types of errors, the server reports the name of a database object
54 (a table, table column, data type, or constraint) associated with the error;
55 for example, the name of the unique constraint that caused a
56 <symbol>unique_violation
</symbol> error. Such names are supplied in separate
57 fields of the error report message so that applications need not try to
58 extract them from the possibly-localized human-readable text of the message.
59 As of
<productname>PostgreSQL
</productname> 9.3, complete coverage for this feature
60 exists only for errors in SQLSTATE class
23 (integrity constraint
61 violation), but this is likely to be expanded in future.
65 <table id=
"errcodes-table">
66 <title><productname>PostgreSQL
</productname> Error Codes
</title>
69 <colspec colnum=
"1" colname=
"errorcode" colwidth=
"1*"/>
70 <colspec colnum=
"2" colname=
"condname" colwidth=
"8*"/>
71 <spanspec namest=
"errorcode" nameend=
"condname" spanname=
"span12"/>
75 <entry>Error Code
</entry>
76 <entry>Condition Name
</entry>