On Tue, 2004-05-11 at 22:56, Neil Conway wrote: > The only convention I can see is that subclass values not defined by the > SQL specification begin with 'P'. (This ought to be documented; barring > any objections, I'll commit a patch stating this in errcodes.h > explicitly).
I've applied the attached patch to CVS HEAD. -Neil
Index: doc/src/sgml/errcodes.sgml =================================================================== RCS file: /var/lib/cvs/pgsql-server/doc/src/sgml/errcodes.sgml,v retrieving revision 1.3 diff -c -r1.3 errcodes.sgml *** a/doc/src/sgml/errcodes.sgml 4 Mar 2004 21:47:18 -0000 1.3 --- b/doc/src/sgml/errcodes.sgml 14 May 2004 17:53:17 -0000 *************** *** 9,21 **** </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</> 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. </para> <para> --- 9,26 ---- </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</> 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</> 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</> ! 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> Index: doc/src/sgml/libpq.sgml =================================================================== RCS file: /var/lib/cvs/pgsql-server/doc/src/sgml/libpq.sgml,v retrieving revision 1.154 diff -c -r1.154 libpq.sgml *** a/doc/src/sgml/libpq.sgml 24 Apr 2004 22:58:40 -0000 1.154 --- b/doc/src/sgml/libpq.sgml 14 May 2004 17:25:56 -0000 *************** *** 1336,1347 **** </varlistentry> <varlistentry> <term><symbol>PG_DIAG_SQLSTATE</> </term> <listitem> <para> ! The SQLSTATE code for the error (see <xref linkend="errcodes-appendix">). ! Not localizable. Always present. </para> </listitem> </varlistentry> --- 1336,1355 ---- </varlistentry> <varlistentry> + <indexterm> + <primary>error codes</primary> + <secondary>libpq</secondary> + </indexterm> <term><symbol>PG_DIAG_SQLSTATE</> </term> <listitem> <para> ! The SQLSTATE code for the error. The SQLSTATE code identifies the type ! of error that has occurred; it can be used by front-end applications ! to perform specific operations (such as error handling) in response to ! a particular database error. For a list of the possible SQLSTATE ! codes, see <xref linkend="errcodes-appendix">. This field is not ! localizable, and is always present. </para> </listitem> </varlistentry> *************** *** 1871,1877 **** Prints out all the rows and, optionally, the column names to the specified output stream. <synopsis> ! void PQprint(FILE* fout, /* output stream */ const PGresult *res, const PQprintOpt *po); --- 1879,1885 ---- Prints out all the rows and, optionally, the column names to the specified output stream. <synopsis> ! void PQprint(FILE *fout, /* output stream */ const PGresult *res, const PQprintOpt *po); *************** *** 3217,3231 **** PGVerbosity PQsetErrorVerbosity(PGconn *conn, PGVerbosity verbosity); </synopsis> ! <function>PQsetErrorVerbosity</> sets the verbosity mode, returning the ! connection's previous setting. ! In <firstterm>terse</> mode, returned messages include severity, primary text, and position ! only; this will normally fit on a single line. The default mode produces ! messages that include the above plus any detail, hint, or context fields ! (these may span multiple lines). The <firstterm>VERBOSE</> mode includes all available ! fields. Changing the verbosity does not affect the messages available from ! already-existing <structname>PGresult</> objects, only subsequently-created ! ones. </para> </listitem> </varlistentry> --- 3225,3239 ---- PGVerbosity PQsetErrorVerbosity(PGconn *conn, PGVerbosity verbosity); </synopsis> ! <function>PQsetErrorVerbosity</> sets the verbosity mode, returning ! the connection's previous setting. In <firstterm>TERSE</> mode, ! returned messages include severity, primary text, and position only; ! this will normally fit on a single line. The default mode produces ! messages that include the above plus any detail, hint, or context ! fields (these may span multiple lines). The <firstterm>VERBOSE</> ! mode includes all available fields. Changing the verbosity does not ! affect the messages available from already-existing ! <structname>PGresult</> objects, only subsequently-created ones. </para> </listitem> </varlistentry> Index: src/include/utils/errcodes.h =================================================================== RCS file: /var/lib/cvs/pgsql-server/src/include/utils/errcodes.h,v retrieving revision 1.8 diff -c -r1.8 errcodes.h *** a/src/include/utils/errcodes.h 4 Mar 2004 21:47:18 -0000 1.8 --- b/src/include/utils/errcodes.h 14 May 2004 17:59:40 -0000 *************** *** 30,37 **** * class (the first two characters of the code value identify the class). * The listing is organized by class to make this prominent. * ! * The generic '000' class code should be used for an error only when there ! * is not a more-specific code defined. */ /* Class 00 - Successful Completion */ --- 30,53 ---- * class (the first two characters of the code value identify the class). * The listing is organized by class to make this prominent. * ! * The generic '000' subclass code should be used for an error only ! * when there is not a more-specific subclass code defined. ! * ! * The SQL spec requires that all the elements of a SQLSTATE code be ! * either digits or upper-case ASCII characters. ! * ! * Classes that begin with 0-4 or A-H are defined by the ! * standard. Within such a class, subclass values defined by the ! * standard must begin with 0-4 or A-H. To define a new error code, ! * ensure that it is either in an "implementation-defined class" (it ! * begins with 5-9 or I-Z), or its subclass falls outside the range of ! * error codes that could be present in future versions of the ! * standard (i.e. the subclass value begins with 5-9 or I-Z). ! * ! * The convention is that new error codes defined by PostgreSQL in a ! * class defined by the standard have a subclass value that begins ! * with 'P'. In addition, error codes defined by PostgreSQL clients ! * (such as ecpg) have a class value that begins with 'Y'. */ /* Class 00 - Successful Completion */
---------------------------(end of broadcast)--------------------------- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])