> 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