Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 317201337B80 for ; Thu, 13 Jan 2011 21:36:30 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 22387-09 for ; Fri, 14 Jan 2011 01:36:29 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from wwwmaster.postgresql.org (wwwmaster.postgresql.org [217.196.146.204]) by mail.postgresql.org (Postfix) with ESMTP id 8EDC41337B5E for ; Thu, 13 Jan 2011 21:36:29 -0400 (AST) Received: from wwwmaster.postgresql.org (wwwmaster.postgresql.org [217.196.146.204]) by wwwmaster.postgresql.org (8.14.3/8.14.3) with ESMTP id p0E1aTnE017853 for ; Fri, 14 Jan 2011 01:36:29 GMT (envelope-from www@wwwmaster.postgresql.org) Received: (from www@localhost) by wwwmaster.postgresql.org (8.14.3/8.14.3/Submit) id p0E1aTFb017852; Fri, 14 Jan 2011 01:36:29 GMT (envelope-from www) Date: Fri, 14 Jan 2011 01:36:29 GMT Message-Id: <201101140136.p0E1aTFb017852@wwwmaster.postgresql.org> To: pgsql-bugs@postgresql.org Subject: BUG #5837: PQstatus() fails to report lost connection From: "Murray S. Kucherawy" Content-Type: text/plain; charset=utf-8 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 201101/98 X-Sequence-Number: 29120 The following bug has been logged online: Bug reference: 5837 Logged by: Murray S. Kucherawy Email address: msk@cloudmark.com PostgreSQL version: 9.0.2 Operating system: FreeBSD Description: PQstatus() fails to report lost connection Details: I'm accessing libpq via OpenDBX, but it appears to be doing the right thing. This is reproducible. 1) establish a connection to postgresql 2) initiate a query, collect results, etc.; all normal 3) while client is idle, restart the server 4) initiate the very same query as before 5) call PQgetResult(), returns non-NULL 6) call PQresultStatus(), returns PGRES_FATAL_ERROR 7) call PQstatus(), returns CONNECTION_OK This causes the caller not to try PQreset() or equivalent, because the connection is presumably fine. However, of course, no further queries will succeed. A call to PQerrorMessage() returns the string "FATAL: terminating connection due to administrator command", which would be expected. I would hate to have to have the application pull that out each time and look for this specific string to detect the dead connection. What happens internally prior to (7) appears to be a bug. I looked through the "TODO" list and didn't see any mention of this.