httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Evgeny Shirykalov <>
Subject [users@httpd] apr_dbd error codes and SQLSTATE
Date Fri, 23 Jun 2006 03:36:09 GMT
Dear All,

Current version of Postgres driver for apr_dbd returns ExecStatusType
values from query-like functions. This behaviour leads to two
unconvenient consequences:
- error codes are Postgres-specific
- there are no possibility to distinguish between real unrecoverable
error (like connection abort) and data error (like constraint violation).

Second item seems more serious to me. Of course, we can get error string,
but it is localisation-dependent, and it is not convenient to analyse
human-readable text instead of erro code from fixed set. Unfortunately,
request results are unaccessible after return from query functions if
there were errors. So, it is impossible to obtain SQLSTATE error code in
current implementation. 

My suggestion is to use SQLSTATE codes as return values. There are two
difficulties: (i) SQLSATE code is 5-char line, but return type is
4-bytes integer, and (ii) query functions from Postgres client library
do not return result object in some situations, and no SQLSTATE code
available in this case.

The method to overcome the size difficulty can be found in standard
Postgres server utilities. Include file <server/utils/elog.h> contains
MAKE_SQLSTATE macro which convert 5-bytes code to 4-bytes integer value.

Second difficulty shall be solved by convention: some existing code
should be used in this situation. For instance, 'connection error' can
be used.

I've implemented and tested this scheme using version of apr_dbd_pgsql.c
from httpd-2.2.2. But current CVS version contains a lot of changes, and
I did not use it. Nevertheless, this error reporting scheme seems to me
much more convenient than current one. And new Oracle driver may also
use it.
Evgeny Shirykalov <>

The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
   "   from the digest:
For additional commands, e-mail:

View raw message