Re: connection watchdog

From: frbn <frbn(at)efbs-seafrigo(dot)fr>
To: Michael Kichanov <mike(at)nordlink(dot)ru>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: connection watchdog
Date: 2002-10-10 15:02:54
Message-ID: 3DA5969E.2050000@efbs-seafrigo.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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)

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Robert Treat 2002-10-10 15:10:23 Re: Getting tables, procedures, etc.
Previous Message Roberto (SmartBit) 2002-10-10 14:57:31 Re: Getting tables, procedures, etc.