Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0cb27df

Browse files
author
Neil Conway
committed
Improve documentation for SQLSTATE error codes, per recent thread on
-patches.
1 parent9f944f0 commit0cb27df

File tree

3 files changed

+53
-24
lines changed

3 files changed

+53
-24
lines changed

‎doc/src/sgml/errcodes.sgml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/errcodes.sgml,v 1.3 2004/03/04 21:47:18 neilc Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/errcodes.sgml,v 1.4 2004/05/14 18:04:02 neilc Exp $ -->
22

33
<appendix id="errcodes-appendix">
44
<title><productname>PostgreSQL</productname> Error Codes</title>
@@ -9,13 +9,18 @@
99
</indexterm>
1010

1111
<para>
12-
All messages emitted by the <productname>PostgreSQL</productname> server
13-
are assigned five-character error codes that follow the SQL standard's
14-
conventions for <quote>SQLSTATE</> codes. Applications that need to know
15-
which error condition has occurred should usually test the error code,
16-
rather than looking at the textual error message. The error codes are
17-
less likely to change across <productname>PostgreSQL</productname> releases,
18-
and also are not subject to change due to localization of error messages.
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.
1924
</para>
2025

2126
<para>

‎doc/src/sgml/libpq.sgml

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/libpq.sgml,v 1.154 2004/04/24 22:58:40 neilc Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/libpq.sgml,v 1.155 2004/05/14 18:04:02 neilc Exp $
33
-->
44

55
<chapter id="libpq">
@@ -1336,12 +1336,20 @@ localized translation of one of these. Always present.
13361336
</varlistentry>
13371337

13381338
<varlistentry>
1339+
<indexterm>
1340+
<primary>error codes</primary>
1341+
<secondary>libpq</secondary>
1342+
</indexterm>
13391343
<term><symbol>PG_DIAG_SQLSTATE</>
13401344
</term>
13411345
<listitem>
13421346
<para>
1343-
The SQLSTATE code for the error (see <xref linkend="errcodes-appendix">).
1344-
Not localizable. Always present.
1347+
The SQLSTATE code for the error. The SQLSTATE code identifies the type
1348+
of error that has occurred; it can be used by front-end applications
1349+
to perform specific operations (such as error handling) in response to
1350+
a particular database error. For a list of the possible SQLSTATE
1351+
codes, see <xref linkend="errcodes-appendix">. This field is not
1352+
localizable, and is always present.
13451353
</para>
13461354
</listitem>
13471355
</varlistentry>
@@ -1871,7 +1879,7 @@ on <function>PQfsize</function> to obtain the actual data length.
18711879
Prints out all the rows and, optionally, the
18721880
column names to the specified output stream.
18731881
<synopsis>
1874-
void PQprint(FILE*fout, /* output stream */
1882+
void PQprint(FILE *fout, /* output stream */
18751883
const PGresult *res,
18761884
const PQprintOpt *po);
18771885

@@ -3217,15 +3225,15 @@ typedef enum {
32173225

32183226
PGVerbosity PQsetErrorVerbosity(PGconn *conn, PGVerbosity verbosity);
32193227
</synopsis>
3220-
<function>PQsetErrorVerbosity</> sets the verbosity mode, returning the
3221-
connection's previous setting.
3222-
In <firstterm>terse</> mode,returned messages include severity, primary text, and position
3223-
only;this will normally fit on a single line. The default mode produces
3224-
messages that include the above plus any detail, hint, or context fields
3225-
(these may span multiple lines). The <firstterm>VERBOSE</> mode includes all available
3226-
fields. Changing the verbosity does not affect the messages available from
3227-
already-existing <structname>PGresult</> objects, only subsequently-created
3228-
ones.
3228+
<function>PQsetErrorVerbosity</> sets the verbosity mode, returning
3229+
theconnection's previous setting. In <firstterm>TERSE</> mode,
3230+
returned messages include severity, primary text, and position only;
3231+
this will normally fit on a single line. The default mode produces
3232+
messages that include the above plus any detail, hint, or context
3233+
fields(these may span multiple lines). The <firstterm>VERBOSE</>
3234+
mode includes all availablefields. Changing the verbosity does not
3235+
affect the messages available from already-existing
3236+
<structname>PGresult</> objects, only subsequently-createdones.
32293237
</para>
32303238
</listitem>
32313239
</varlistentry>

‎src/include/utils/errcodes.h

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
* Copyright (c) 2003, PostgreSQL Global Development Group
1313
*
14-
* $PostgreSQL: pgsql/src/include/utils/errcodes.h,v 1.8 2004/03/04 21:47:18 neilc Exp $
14+
* $PostgreSQL: pgsql/src/include/utils/errcodes.h,v 1.9 2004/05/14 18:04:02 neilc Exp $
1515
*
1616
*-------------------------------------------------------------------------
1717
*/
@@ -30,8 +30,24 @@
3030
* class (the first two characters of the code value identify the class).
3131
* The listing is organized by class to make this prominent.
3232
*
33-
* The generic '000' class code should be used for an error only when there
34-
* is not a more-specific code defined.
33+
* The generic '000' subclass code should be used for an error only
34+
* when there is not a more-specific subclass code defined.
35+
*
36+
* The SQL spec requires that all the elements of a SQLSTATE code be
37+
* either digits or upper-case ASCII characters.
38+
*
39+
* Classes that begin with 0-4 or A-H are defined by the
40+
* standard. Within such a class, subclass values defined by the
41+
* standard must begin with 0-4 or A-H. To define a new error code,
42+
* ensure that it is either in an "implementation-defined class" (it
43+
* begins with 5-9 or I-Z), or its subclass falls outside the range of
44+
* error codes that could be present in future versions of the
45+
* standard (i.e. the subclass value begins with 5-9 or I-Z).
46+
*
47+
* The convention is that new error codes defined by PostgreSQL in a
48+
* class defined by the standard have a subclass value that begins
49+
* with 'P'. In addition, error codes defined by PostgreSQL clients
50+
* (such as ecpg) have a class value that begins with 'Y'.
3551
*/
3652

3753
/* Class 00 - Successful Completion */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp