Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id B2B6E1337B92 for ; Fri, 11 Mar 2011 06:56:06 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 03618-01 for ; Fri, 11 Mar 2011 10:55:59 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from momjian.us (momjian.us [70.90.9.53]) by mail.postgresql.org (Postfix) with ESMTP id 427931337BA8 for ; Fri, 11 Mar 2011 06:55:59 -0400 (AST) Received: (from bruce@localhost) by momjian.us (8.11.6/8.11.6) id p2BAu1L22204; Fri, 11 Mar 2011 05:56:01 -0500 (EST) From: Bruce Momjian Message-Id: <201103111056.p2BAu1L22204@momjian.us> Subject: Re: BUG #5837: PQstatus() fails to report lost connection In-Reply-To: To: Robert Haas Date: Fri, 11 Mar 2011 05:56:01 -0500 (EST) CC: Kevin Grittner , "Murray S. Kucherawy" , "pgsql-bugs@postgresql.org" , Tom Lane X-Mailer: ELM [version 2.4ME+ PL124 (25)] MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="ELM1299840961-10557-1_" Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201103/187 X-Sequence-Number: 29697 --ELM1299840961-10557-1_ Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="US-ASCII" Robert Haas wrote: > On Tue, Jan 25, 2011 at 10:54 AM, Kevin Grittner > wrote: > > Robert Haas wrote: > >> I think this patch would only be adding to the confusion. ?When > >> PQgetResult() is called, we read enough data from the connection > >> to create and return one result object. ?It's true that this > >> doesn't necessarily detect an EOF, but IIUC calling PQgetResult() > >> again is just ONE way that you could trigger another read against > >> the socket, not the only one. ?I think it would also work to call > >> PQconsumeInput(), for example. > > > > I find it hard to reconcile the above with this: > > > > http://archives.postgresql.org/message-id/6493.1295882981@sss.pgh.pa.us > > > > and the quote from our documentation referenced here: > > > > http://archives.postgresql.org/message-id/4D3D67600200002500039B2C@gw.wicourts.gov > > IIUC, Tom's point was that doing it that way would detect the error, > not that it was the ONLY way to detect the error. > > But it's easily testable. > > >> I think the real, underlying problem here is that Murray would > >> like a behavior change > > > > More than that I think he wants to be able to read the manual and > > know what will work, without spending loads of time getting in tune > > with The Tao of Libpq. ?Based on his initial reading of the docs he > > expected different behavior; that can be fixed by changing the > > behavior or changing the docs. > > That is why I suggested the type of doc correction that I thought > would be most helpful and accurate. Doc patch attached and applied. I used "should be called" instead of "must". -- Bruce Momjian http://momjian.us EnterpriseDB http://enterprisedb.com + It's impossible for everything to be true. + --ELM1299840961-10557-1_ Content-Transfer-Encoding: 7bit Content-Type: text/x-diff Content-Disposition: inline; filename="/rtmp/libpq.diff" diff --git a/doc/src/sgml/libpq.sgml b/doc/src/sgml/libpq.sgml new file mode 100644 index 49edc51..59b4011 *** a/doc/src/sgml/libpq.sgml --- b/doc/src/sgml/libpq.sgml *************** PGresult *PQgetResult(PGconn *conn); *** 3846,3851 **** --- 3846,3860 ---- active and the necessary response data has not yet been read by PQconsumeInput. + + + + Even when PQresultStatus indicates a fatal + error, PQgetResult should be called until it + returns a null pointer to allow libpq to + process the error information completely. + + --ELM1299840961-10557-1_--