libpq error codes - Mailing list pgsql-general

From Denis Perchine
Subject libpq error codes
Date
Msg-id 0006211348540E.30655@dyp
Whole thread Raw
Responses Re: libpq error codes
List pgsql-general
Hello all,

I try to add automatical connection restoring possibility to my app.
And I have the following problem:

When I execute query I have:

query: 1024: 'select count(*) from pg_class'
ResStatus: PGRES_TUPLES_OK
Status: 0

ResStatus is the result of PQresultStatus, Status is the result of PQstatus.

If I shutdown postgres between queries I get:

query: 1024: 'select count(*) from pg_class'
ResStatus: PGRES_FATAL_ERROR
Status: 0
except: pqReadData() --  read() failed: errno=32
���������� �����

query: 1024: 'select count(*) from pg_class'
FATAL 1:  The system is shutting down
NOTICE:  AbortTransaction and not in in-progress state
Status: 1
except: pqReadData() -- backend closed the channel unexpectedly.
        This probably means the backend terminated abnormally
        before or while processing the request.

Please note, that Status is 0 in the first case. There's already no any backend on the
other side but Status is still OK. That's bad... And the second query just return NULL
to PQexec.

The problem is that I cannot properly distinguish between errors in SQL, or some incorrect
SQL usage and situations when connection is lost and I should try to reconnect.

Any ideas how this can be implemented?

--
Sincerely Yours,
Denis Perchine

----------------------------------
E-Mail: dyp@perchine.com
HomePage: http://www.perchine.com/dyp/
FidoNet: 2:5000/120.5
----------------------------------

pgsql-general by date:

Previous
From: Haroldo Stenger
Date:
Subject: Re: Sequences do not obey transactions...
Next
From: "Andrea Aime"
Date:
Subject: NT + cygipc + postgresql = boom!