You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Evgeny Shirykalov <ev...@monsoonmultimedia.com> on 2006/06/23 05:36:09 UTC

[users@httpd] apr_dbd error codes and SQLSTATE

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 <ev...@monsoonmultimedia.com>


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] apr_dbd error codes and SQLSTATE

Posted by Nick Kew <ni...@webthing.com>.
On Friday 23 June 2006 04:36, Evgeny Shirykalov wrote:
> Dear All,
>
> Current version of Postgres driver for apr_dbd returns ExecStatusType
> values from query-like functions. This behaviour leads to two
> unconvenient consequences:

Yes, this has been discussed recently on the dev@apr list.
The underlying issue is to create new APR/APU error codes
to express conditions that aren't dealt with at present.

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

We're more likely to implement things at the APR level, so they might
look like, for example, APR_ENODBD or APR_ESQLSYNTAX, with some
secondary means to retrieve the native database's original error.

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

Please feel free to hop over to the dev@apr list and contribute your
thoughts.  If you're happy to share what you've done with pgsql, we'll
be interested to take a look.

-- 
Nick Kew

Re: [users@httpd] apr_dbd error codes and SQLSTATE

Posted by Nick Kew <ni...@webthing.com>.
On Friday 23 June 2006 04:36, Evgeny Shirykalov wrote:
> Dear All,
>
> Current version of Postgres driver for apr_dbd returns ExecStatusType
> values from query-like functions. This behaviour leads to two
> unconvenient consequences:

Yes, this has been discussed recently on the dev@apr list.
The underlying issue is to create new APR/APU error codes
to express conditions that aren't dealt with at present.

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

We're more likely to implement things at the APR level, so they might
look like, for example, APR_ENODBD or APR_ESQLSYNTAX, with some
secondary means to retrieve the native database's original error.

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

Please feel free to hop over to the dev@apr list and contribute your
thoughts.  If you're happy to share what you've done with pgsql, we'll
be interested to take a look.

-- 
Nick Kew

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org