summaryrefslogtreecommitdiffstats
path: root/doc/src/sgml/errcodes.sgml
blob: 861fa51f180e940b86a03d4a90fc2c1045820e66 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<!-- doc/src/sgml/errcodes.sgml -->

<appendix id="errcodes-appendix">
 <title><productname>PostgreSQL</productname> Error Codes</title>

 <indexterm zone="errcodes-appendix">
  <primary>error codes</primary>
  <secondary>list of</secondary>
 </indexterm>

 <para>
  All messages emitted by the <productname>PostgreSQL</productname>
  server are assigned five-character error codes that follow the SQL
  standard's conventions for <quote>SQLSTATE</quote> 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
  <productname>PostgreSQL</productname> 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 <productname>PostgreSQL</productname>
  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.
 </para>

 <para>
  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.
 </para>

 <para>
  <xref linkend="errcodes-table"/> lists all the error codes defined in
  <productname>PostgreSQL</productname> &version;.  (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</quote> error code having the last three characters
  <literal>000</literal>.  This code is used only for error conditions that fall
  within the class but do not have any more-specific code assigned.
 </para>

 <para>
  The symbol shown in the column <quote>Condition Name</quote> is
  the condition name to use in <application>PL/pgSQL</application>.  Condition
  names can be written in either upper or lower case.  (Note that
  <application>PL/pgSQL</application> does not recognize warning, as opposed to error,
  condition names; those are classes 00, 01, and 02.)
 </para>

 <para>
  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
  <symbol>unique_violation</symbol> 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 <productname>PostgreSQL</productname> 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.
 </para>


<table id="errcodes-table">
 <title><productname>PostgreSQL</productname> Error Codes</title>

 <tgroup cols="2">
  <colspec colnum="1" colname="errorcode" colwidth="1*"/>
  <colspec colnum="2" colname="condname" colwidth="8*"/>
  <spanspec namest="errorcode" nameend="condname" spanname="span12"/>

  <thead>
   <row>
    <entry>Error Code</entry>
    <entry>Condition Name</entry>
   </row>
  </thead>

  <tbody>

    &errcodes-table;

  </tbody>
 </tgroup>
</table>


</appendix>