From: jtv@xs4all.nl
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: jtv@xs4all.nl
Cc: pgsql-interfaces@postgresql.org
Subject: Re: Getting results after networking error
Date: Wed, 10 Aug 2005 05:51:48 +0200 (CEST)
Message-ID: <17553.202.47.227.25.1123645908.squirrel@202.47.227.25> (raw)
In-Reply-To: <21820.1123643273@sss.pgh.pa.us>
References: <4395.210.86.147.191.1123600604.squirrel@210.86.147.191>
<16904.1123604812@sss.pgh.pa.us>
<6201.202.47.227.25.1123640679.squirrel@202.47.227.25>
<21820.1123643273@sss.pgh.pa.us>
Tom Lane wrote:
> I think that a reasonable API for this "if PQstatus(conn) is
> CONNECTION_BAD then you had a networking problem". I am not at all sure
> how well libpq honors that definition currently ... but feel free to
> send patches ;-)
As I posted in July,
http://archives.postgresql.org/pgsql-interfaces/2005-07/msg00003.php
the current situation is that libpq goes out of its way to maintain
CONNECTION_OK in these cases. I'd still like to see the fix I outlined
there, which is to treat socket errors as fatal by default (apart from the
special cases for EAGAIN, EINTR and friends that are already there, of
course).
I'm attaching a patch; something similar may be called for in pqSendSome()
as well. A next step would be to factor the code duplication out of the
function, eliminating the redundant error message in the process.
Jeroen
Attachments:
[text/x-patch] fe-misc.patch (645B, ../17553.202.47.227.25.1123645908.squirrel@202.47.227.25/2-fe-misc.patch)
download | inline diff:--- src/interfaces/libpq/fe-misc.c.org 2005-08-10 10:46:47.000000000 +0700+++ src/interfaces/libpq/fe-misc.c 2005-08-10 10:48:38.000000000 +0700@@ -610,7 +610,7 @@
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext("could not receive data from server: %s\n"),
SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));
- return -1;+ goto definitelyFailed:
}
if (nread > 0)
{
@@ -701,7 +701,7 @@
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext("could not receive data from server: %s\n"),
SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));
- return -1;+ goto definitelyFailed:
}
if (nread > 0)
{
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 using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: jtv@xs4all.nl, tgl@sss.pgh.pa.us
Subject: Re: Getting results after networking error
In-Reply-To: <17553.202.47.227.25.1123645908.squirrel@202.47.227.25>
* 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