Re: can we use PQstatus for knowing connection status

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: HK <harikrishnan(at)midascomm(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: can we use PQstatus for knowing connection status
Date: 2003-06-19 13:53:29
Message-ID: 8257.1056030809@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

HK <harikrishnan(at)midascomm(dot)com> writes:
> I am using libpq for connecting from a C program to postgres
> 7.1.3. And i am using asyncronous query processing. Suppose i sent a query
> and while processing is on, the postmaster is stopped (for simulating a pg
> crash). Now if i use the PQstatus (conn) i am unable to get the actual
> status. It still says the connection is OK. Then how can we detect the pg
> crash.

You can't, in most scenarios, except by issuing a query and having it
fail. PQstatus will go to CONNECTION_BAD when libpq detects loss of
connection ... but it wouldn't be very reasonable or useful to have the
library constantly pinging the server to verify the connection is still
up.

regards, tom lane

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Ennio-Sr 2003-06-19 15:04:16 Re: Multibyte support and accented characters
Previous Message HK 2003-06-19 06:14:17 can we use PQstatus for knowing connection status