pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: marko@joh.to
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #11712: Empty string as error message from libpq
Date: Wed, 22 Oct 2014 18:16:01 -0400
Message-ID: <31203.1414016161@sss.pgh.pa.us> (raw)
In-Reply-To: <20141019003736.2662.84048@wrigleys.postgresql.org>
References: <20141019003736.2662.84048@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

marko@joh.to writes:
> Consider a program similar to the LISTEN/NOTIFY example here:
> http://www.postgresql.org/docs/9.3/static/libpq-example.html#LIBPQ-EXAMPLE-2,
> but with an added error handling around PQconsumeInput():

>         if (PQconsumeInput(conn) != 1) {
>             fprintf(stderr,
>                     "PQconsumeInput() failed: %s\n",
>                     PQerrorMessage(conn));
>             PQfinish(conn);
>             return;
>         }

> Now when this program is running without SSL, and the server closes the
> network connection, what happens is this:

>   PQconsumeInput() failed: 

> i.e. the error string is empty.  This happens when recv() returns 0 on EOF. 

Hmm.  I wonder why we're not getting ECONNRESET, since surely the TCP
stack knows the other end is dead?  Anyway, it looks to me like the
best fix is just to set an error message, ie copy this bit

            printfPQExpBuffer(&conn->errorMessage,
                              libpq_gettext(
                                "server closed the connection unexpectedly\n"
                   "\tThis probably means the server terminated abnormally\n"
                             "\tbefore or while processing the request.\n"));

right before definitelyFailed:.  For the goto's leading to that label,
it's reasonable to expect that lower-level code set the errorMessage,
but this will not have happened when pqsecure_read returns zero, since
the whole point is that it doesn't know there's anything wrong.

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (2+ messages)

Message-ID: <31203.1414016161@sss.pgh.pa.us>
Permalink:  ../31203.1414016161@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/31203.1414016161@sss.pgh.pa.us

 · 

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: tgl@sss.pgh.pa.us, marko@joh.to
  Subject: Re: BUG #11712: Empty string as error message from libpq
  In-Reply-To: <31203.1414016161@sss.pgh.pa.us>
  References: <20141019003736.2662.84048@wrigleys.postgresql.org> <31203.1414016161@sss.pgh.pa.us>

* 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