Slightly better testing for pg_ctl(1)'s -w... - Mailing list pgsql-patches

From Sean Chittenden
Subject Slightly better testing for pg_ctl(1)'s -w...
Date
Msg-id 05D5F896-1A85-11D9-BF1B-000A95C705DC@speakeasy.net
Whole thread Raw
Responses Re: Slightly better testing for pg_ctl(1)'s -w...
Re: Slightly better testing for pg_ctl(1)'s -w...
List pgsql-patches
pg_ctl(1)'s -w option works well if the default user can automatically
authenticate without any user intervention.  The attached patch checks
the error message to see if it's asking for a password.  The theory
being that if it's asking for a password, the backend is up.  I'm not
entirely happy with the fact that I'm dependent on the error message
text, but I couldn't easily figure out a better way to test this via
libpq(3), so I'm not too unhappy... it's just not elegant.  This patch
does not encompass all possible scenarios for the backend being up, but
CONNECTION_BAD being set in libpq(3).  Regardless, it's a start and
hopefully someone can apply this.  I also cleaned up a small memory
leak when a connection is bad (PGconn not being free(3)'ed).  -sc

% pg_ctl -w start && psql
waiting for postmaster to start....done
postmaster started
test=>



--
Sean Chittenden


Attachment

pgsql-patches by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: cast pid_t to int when using *printf
Next
From: Sean Chittenden
Date:
Subject: Casting INT4 to BOOL...