Subject RE: [Firebird-Architect] Re: SQLSTATE and Firebird
Author Tom Cole
[Sorry for the delay in weighing back in, I was out of office.]

Here's an example of a problematic error: isc_arith_except.

This is signaled in many places from within cvt.cpp and evl.cpp. It can means overflow, string truncation, or math domain errors such as divide-by-zero.

There are discrete SQLSTATE values for these. Consider Oracle's list:

01004 String data right truncated
22012 Division by zero
22003 Numeric value out of range

The isc_arith_except error is thrown from a variety of places where the context of the operation is necessary to know how to interpret which SQLSTATE to apply. This would be a case where I think that the actual error signaler has to add some value or data to describe what is happening - it's not possible for a status vector post-processor to know which is which.


-----Original Message-----
From: Firebird-Architect@yahoogroups.com [mailto:Firebird-Architect@yahoogroups.com] On Behalf Of Alex Peshkov
Sent: Wednesday, April 26, 2006 6:50 AM
To: Firebird-Architect@yahoogroups.com
Subject: Re: [Firebird-Architect] Re: SQLSTATE and Firebird

Roman Rokytskyy wrote:
>>AFAIU, this could (should?) be achieved via a mapping table between
>>GDSCODE's and SQLSTATE's (similarly to how SQLCODE's are handled) +
>>one new API function (fb_sqlstate?). This way, GDSCODE's are still the
>>primary error ids and nothing in the engine needs to be modified. The
>>client passes the status vector to fb_sqlstate() and gets SQLSTATE
>>value. PSQL code may be extended to support WHEN SQLSTATE <value>
>>construct.
>>
>>Am I missing something?
>
>
> No, I have used similar approach in Jaybird. The only problem is that
> there are only few SQLSTATEs that map nicely to Firebird:
>
> SQL_STATE_INVALID_CON_ATTR "01S00"
> SQL_STATE_NO_ROW_AVAIL "01S06"
> SQL_STATE_GENERAL_ERROR "HY00"
> SQL_STATE_DRIVER_NOT_CAPABLE "HYC00"
> SQL_STATE_INVALID_COLUMN "HY02"
> SQL_STATE_INVALID_PARAM_TYPE "HY105"
> SQL_STATE_INVALID_ARG_VALUE "HY009"
> SQL_STATE_WRONG_PARAM_NUM "07001"
> SQL_STATE_NO_RESULT_SET "07005"
> SQL_STATE_INVALID_CONVERSION "07006"
> SQL_STATE_CONNECTION_CLOSED "08003"
> SQL_STATE_CONNECTION_FAILURE_IN_TX "08007"
> SQL_STATE_COMM_LINK_FAILURE "08S01"
> SQL_STATE_INVALID_ESCAPE_SEQ "22025"
>

What problems, with, for example:
08001 - client unable to establish connection

is not it where we should map isc_network_error:
Unsuccessful execution caused by a system error that precludes successful execution of subsequent statements.
Unable to complete network request to host "QQ".
Failed to locate host machine.
The specified name was not found in the hosts file or Domain Name Services.

Moreover, if some of SQLSTATEs will not be used, that's not a big problem - this simply means, that such errors never happen in firebird.
The more serious problem will happen if we will not be able to map particular gdscode to SQLSTATE. Or if we will need to map it to different SQLSTATEs in different cases. But before trying to solve that problems, let's make sure they really happen.



Yahoo! Groups Links