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</> 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</> 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</>
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 can 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</> error code having the last three characters
40
<literal>000</>. 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 <application>PL/pgSQL</> condition name for each error code is the
46
same as the phrase shown in the table, with underscores substituted
47
for spaces. For example, code <literal>22012</>, DIVISION BY ZERO,
48
has condition name <literal>DIVISION_BY_ZERO</>. Condition names can
49
be written in either upper or lower case. (Note that
50
<application>PL/pgSQL</> does not recognize warning, as opposed to error,
51
condition names; those are classes 00, 01, and 02.)
56
The following table should correspond to the contents of
57
src/include/utils/errcodes.h and src/pl/plpgsql/src/plerrcodes.h.
60
<table id="errcodes-table">
61
<title><productname>PostgreSQL</productname> Error Codes</title>
64
<colspec colnum="1" colname="errorcode">
65
<colspec colnum="3" colname="condname">
66
<spanspec namest="errorcode" nameend="condname" spanname="span13">
70
<entry>Error Code</entry>
71
<entry>Meaning</entry>
72
<entry>Condition Name</entry>