Thread: SQLError SqlState wrong when postgres backend dies

SQLError SqlState wrong when postgres backend dies

From
Jeremy Faith
Date:

Hi,


The SQLError function is returning the last statement level SqlState value if called after the postgres backend dies.

For exampel, if prior to the death of the postgres backend the last SQL statement that had an error returned an SqlState="23505"(due to a unique index problem) then after the postgres backend dies the next SQL statement will fail and SQLError returns:-

  NativeError=26 SqlState="23505" ErrorMsg=Could not send Query(connection dead)

So ErrorMsg is correct but SqlState is not.


I was using psqlodbc-09.05.0400 but repeated my test with 10.01.0000 and got the same result.


Note:I know SQLError is deprecated and that SQLGetDiagRec should be used instead but I have a comment in my code that indicates I was getting a segfault with the postgres ODBC driver when I used SQLGetDiagRec(this would have been from some years ago).


Regards,

Jeremy Faith

Re: SQLError SqlState wrong when postgres backend dies

From
Clemens Ladisch
Date:
Jeremy Faith wrote:
> The SQLError function is returning the last statement level SqlState value if called
> after the postgres backend dies.

This problem in libpq has been known for over ten years:
<https://www.postgresql.org/message-id/8904.1196130273%40sss.pgh.pa.us>


Regards,
Clemens