Re: connection watchdog - Mailing list pgsql-general

From frbn
Subject Re: connection watchdog
Date
Msg-id 3DA5969E.2050000@efbs-seafrigo.fr
Whole thread Raw
In response to connection watchdog  (Michael Kichanov <mike@nordlink.ru>)
Responses Re: connection watchdog  (Michael Kichanov <mike@nordlink.ru>)
List pgsql-general
Michael Kichanov wrote:
> Hi Postgres gurus!
>
> How can I check from C-program whether connection to pgsql
> engine still works or already lost?
> PQstatus() returns CONNECTION_OK even when backend process is killed
> by hands after connection is made.

> ps: Searching through pgsql-mail-lists archive and Faq gave nothing.


I think you can't know if a connection is ok before trying to send
a query to the server (IMHO)

If you really want to know before, you can send a simple query  (select '1')
and test the PGResult
(!= PGRES_COMMAND_OK or !=PGRES_TUPLES_OK or ==PGRES_BAD_RESPONSE or ==PGRES_FATAL_ERROR)


pgsql-general by date:

Previous
From: "Roberto (SmartBit)"
Date:
Subject: Re: Getting tables, procedures, etc.
Next
From: Robert Treat
Date:
Subject: Re: Getting tables, procedures, etc.