Re: PQstatus() detect change in connection... - Mailing list pgsql-hackers

From Zeugswetter Andreas SB SD
Subject Re: PQstatus() detect change in connection...
Date
Msg-id 46C15C39FEB2C44BA555E356FBCD6FA41EB3CF@m0114.s-mxs.net
Whole thread Raw
In response to PQstatus() detect change in connection...  (Matthew Hagerty <mhagerty@voyager.net>)
List pgsql-hackers
> Matthew Hagerty <mhagerty@voyager.net> writes:
> > but I also want to check the connection *before* submitting a
query...

If you mean directly before the query, then forget it, as Tom already
said :-)

> This strikes me as utterly pointless.  You'll need to be able to
recover
> from query failure anyway, so what's the value of testing beforehand?
> Send the query and see if it works or not.

I see a value in checking connection status before you start doing
loads of local work after a long idle time, that results in a query.
In this situation I guess it is good enough to send an empty query
even if it takes a little.

In our projects we recv 0 bytes from the socket every x seconds
during long idle periods to detect connection problems early.
While it is not 100% reliable (since it does not transfer
anything over the network) it does detect some common error situations.

I am not 100% sure, but I think PQstatus could be patched to do that.

Andreas


pgsql-hackers by date:

Previous
From: Lee Kindness
Date:
Subject: Compiling on Solaris with Sun compiler
Next
From: Vince Vielhaber
Date:
Subject: Re: Snaptshot appears fine to me ...