Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 3EBE31336B42 for ; Mon, 24 Jan 2011 14:04:25 -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 76450-05 for ; Mon, 24 Jan 2011 18:04:18 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from ht1-outbound.cloudmark.com (ht1-outbound.cloudmark.com [72.5.239.35]) by mail.postgresql.org (Postfix) with ESMTP id A4DEF133655C for ; Mon, 24 Jan 2011 14:04:17 -0400 (AST) Received: from EXCH-C2.corp.cloudmark.com ([172.22.1.74]) by malice.corp.cloudmark.com ([172.22.10.71]) with mapi; Mon, 24 Jan 2011 10:04:16 -0800 From: "Murray S. Kucherawy" To: Kevin Grittner , Tom Lane CC: Robert Haas , "pgsql-bugs@postgresql.org" Date: Mon, 24 Jan 2011 10:04:14 -0800 Subject: Re: BUG #5837: PQstatus() fails to report lost connection Thread-Topic: [BUGS] BUG #5837: PQstatus() fails to report lost connection Thread-Index: Acu77yHRM0oW2XCbSwGP0g6Qm05AuwAAAj7A Message-ID: References: <201101140136.p0E1aTFb017852@wwwmaster.postgresql.org> <1950.1295754244@sss.pgh.pa.us> <6493.1295882981@sss.pgh.pa.us> <4D3D67600200002500039B2C@gw.wicourts.gov> In-Reply-To: <4D3D67600200002500039B2C@gw.wicourts.gov> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.61 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201101/172 X-Sequence-Number: 29194 > -----Original Message----- > From: Kevin Grittner [mailto:Kevin.Grittner@wicourts.gov] > Sent: Monday, January 24, 2011 9:50 AM > To: Murray S. Kucherawy; Tom Lane > Cc: Robert Haas; pgsql-bugs@postgresql.org > Subject: Re: [BUGS] BUG #5837: PQstatus() fails to report lost connection >=20 > "Murray S. Kucherawy" wrote: >=20 > > Please, at a minimum, add some documentation about it. >=20 > Current documentation at: >=20 > http://www.postgresql.org/docs/9.0/interactive/libpq-async.html >=20 > says: >=20 > | PQgetResult must be called repeatedly until it returns a null > | pointer, indicating that the command is done. >=20 > What do you think would make this more clear? "command is done" sounds like normal operation to me, but we're talking abo= ut an obvious exception here. The command (I assume that means the query t= hat ultimately failed) can't even have started because the connection was g= one. That's why I find the description misleading. Indeed, the function order you're talking about is PQgetResult(), which ret= urns non-NULL in this condition (which looks like there's a result availabl= e), but then PQresultStatus() returns PGRES_FATAL_ERROR. It's not very obv= ious to me that the right thing to do here is call PQgetResult() again just= to get PQstatus() to tell me the truth. Now we're dealing with an excepti= on rather than something normal. So maybe something like this after the paragraph you cited would help: "Note that after returning a PGresult object, PQresultStatus() could indica= te a fatal error. The caller should still iterate calling PQgetResult() to= completion (i.e. until it returns NULL) in order to allow libpq to process= the error information completely."