pgsql: Rewrite PQping to be more like what we agreed to last week.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Rewrite PQping to be more like what we agreed to last week.
Date: 2010-11-27 06:32:22
Message-ID: E1PMEKc-0001Wh-T4@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Rewrite PQping to be more like what we agreed to last week.

Basically, we want to distinguish all cases where the connection was
not made from those where it was. A convenient proxy for this is to
see if we got a message with a SQLSTATE code back from the postmaster.
This presumes that the postmaster will always send us a SQLSTATE in
a failure message, which is true for 7.4 and later postmasters in
every case except fork failure. (We could possibly complicate the
postmaster code to do something about that, but it seems not worth
the trouble, especially since pg_ctl's response for that case should
be to keep waiting anyway.)

If we did get a SQLSTATE from the postmaster, there are basically only
two cases, as per last week's discussion: ERRCODE_CANNOT_CONNECT_NOW
and everything else. Any other error code implies that the postmaster
is in principle willing to accept connections, it just didn't like or
couldn't handle this particular request. We want to make a special
case for ERRCODE_CANNOT_CONNECT_NOW so that "pg_ctl start -w" knows
it should keep waiting.

In passing, pick names for the enum constants that are a tad less
likely to present collision hazards in future.

Branch
------
master

Details
-------
http://git.postgresql.org/gitweb?p=postgresql.git;a=commitdiff;h=db96e1ccfcb8f3514eef931bea9435974ec7ad28

Modified Files
--------------
doc/src/sgml/libpq.sgml | 152 +++++++++++++++++++----------------
src/bin/pg_ctl/pg_ctl.c | 91 +++++++++++----------
src/interfaces/libpq/fe-connect.c | 82 +++++++++++++++----
src/interfaces/libpq/fe-protocol3.c | 10 ++-
src/interfaces/libpq/libpq-fe.h | 7 +-
src/interfaces/libpq/libpq-int.h | 1 +
6 files changed, 209 insertions(+), 134 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2010-11-27 07:12:17 pgsql: On further testing, PQping also needs an explicit check for AUTH
Previous Message Tom Lane 2010-11-27 00:17:09 pgsql: Clean up IPv4 vs IPv6 bogosity in connectFailureMessage().