pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Murray S. Kucherawy <msk@cloudmark.com>
To: Kevin Grittner <Kevin.Grittner@wicourts.gov>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: pgsql-bugs@postgresql.org <pgsql-bugs@postgresql.org>
Subject: Re: BUG #5837: PQstatus() fails to report lost	 connection
Date: Mon, 24 Jan 2011 10:04:14 -0800
Message-ID: <F5833273385BB34F99288B3648C4F06F1341E73FCD@EXCH-C2.corp.cloudmark.com> (raw)
In-Reply-To: <4D3D67600200002500039B2C@gw.wicourts.gov>
References: <201101140136.p0E1aTFb017852@wwwmaster.postgresql.org>
	<AANLkTinZAdPCX685ecg2_eVXJ1vDNXL4Ki-B1rFN=Z3h@mail.gmail.com>
	<1950.1295754244@sss.pgh.pa.us>
	<F5833273385BB34F99288B3648C4F06F1341E73FC4@EXCH-C2.corp.cloudmark.com>
	<AANLkTi=rSATsN+3UD5feWm3ntsB=6jqAFBZWdTZ7ZfaO@mail.gmail.com>
	<F5833273385BB34F99288B3648C4F06F1341E73FC6@EXCH-C2.corp.cloudmark.com>
	<6493.1295882981@sss.pgh.pa.us>
	<F5833273385BB34F99288B3648C4F06F1341E73FCB@EXCH-C2.corp.cloudmark.com>
	<4D3D67600200002500039B2C@gw.wicourts.gov>

> -----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
> 
> "Murray S. Kucherawy" <msk@cloudmark.com> wrote:
> 
> > Please, at a minimum, add some documentation about it.
> 
> Current documentation at:
> 
> http://www.postgresql.org/docs/9.0/interactive/libpq-async.html
> 
> says:
> 
> | PQgetResult must be called repeatedly until it returns a null
> | pointer, indicating that the command is done.
> 
> What do you think would make this more clear?

"command is done" sounds like normal operation to me, but we're talking about an obvious exception here.  The command (I assume that means the query that ultimately failed) can't even have started because the connection was gone.  That's why I find the description misleading.

Indeed, the function order you're talking about is PQgetResult(), which returns non-NULL in this condition (which looks like there's a result available), but then PQresultStatus() returns PGRES_FATAL_ERROR.  It's not very obvious 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 exception 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 indicate 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."



view thread (25+ messages)  latest in thread

Message-ID: <F5833273385BB34F99288B3648C4F06F1341E73FCD@EXCH-C2.corp.cloudmark.com>
Permalink:  ../F5833273385BB34F99288B3648C4F06F1341E73FCD@EXCH-C2.corp.cloudmark.com/
Also on:    postgresql.org/message-id/F5833273385BB34F99288B3648C4F06F1341E73FCD@EXCH-C2.corp.cloudmark.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: msk@cloudmark.com, Kevin.Grittner@wicourts.gov, tgl@sss.pgh.pa.us, robertmhaas@gmail.com
  Subject: Re: BUG #5837: PQstatus() fails to report lost	 connection
  In-Reply-To: <F5833273385BB34F99288B3648C4F06F1341E73FCD@EXCH-C2.corp.cloudmark.com>
  References: <201101140136.p0E1aTFb017852@wwwmaster.postgresql.org> <AANLkTinZAdPCX685ecg2_eVXJ1vDNXL4Ki-B1rFN=Z3h@mail.gmail.com> <1950.1295754244@sss.pgh.pa.us> <F5833273385BB34F99288B3648C4F06F1341E73FC4@EXCH-C2.corp.cloudmark.com> <AANLkTi=rSATsN+3UD5feWm3ntsB=6jqAFBZWdTZ7ZfaO@mail.gmail.com> <F5833273385BB34F99288B3648C4F06F1341E73FC6@EXCH-C2.corp.cloudmark.com> <6493.1295882981@sss.pgh.pa.us> <F5833273385BB34F99288B3648C4F06F1341E73FCB@EXCH-C2.corp.cloudmark.com> <4D3D67600200002500039B2C@gw.wicourts.gov> <F5833273385BB34F99288B3648C4F06F1341E73FCD@EXCH-C2.corp.cloudmark.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox