libpq error codes

From: Denis Perchine <dyp(at)perchine(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: libpq error codes
Date: 2000-06-21 06:43:30
Message-ID: 0006211348540E.30655@dyp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-patches

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(at)perchine(dot)com
HomePage: http://www.perchine.com/dyp/
FidoNet: 2:5000/120.5
----------------------------------

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Poul L. Christiansen 2000-06-21 07:36:26 Re: Postgres with php3
Previous Message Haroldo Stenger 2000-06-21 05:22:46 Re: Sequences do not obey transactions...

Browse pgsql-patches by date

  From Date Subject
Next Message Philip J. Warner 2000-06-21 06:55:58 RE: Big 7.1 open items
Previous Message Chris Bitmead 2000-06-21 06:13:47 Re: Big 7.1 open items