Re: initdb: Improve error recovery.

From: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
To: Mats Erik Andersson <bsd(at)gisladisker(dot)se>, <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: initdb: Improve error recovery.
Date: 2014-12-05 12:38:54
Message-ID: 5481A75E.7030607@vmware.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 11/27/2014 02:28 PM, Mats Erik Andersson wrote:
> Hello there,
>
> I would like to improve error recovery of initdb when the
> password file is empty. The present code declares "Error 0"
> as the cause of failure. It suffices to use ferrer() since
> fgets() returns NULL also at a premature EOF.

Thanks, committed.

> In addition, a minor case is the need of a line feed in
> order to print the error message on a line of its own
> seems desirable.

Hmm. If you've piped stdout somewhere else, that produces a spurious
empty line in stderr:

$ bin/initdb -D data-foo > /dev/null

initdb: input file "/home/heikki/pgsql.master/share/postgres.bki" does
not belong to PostgreSQL 9.5devel
Check your installation or specify the correct path using the option -L.
initdb: removing data directory "data-foo"

I think the newline needs to go to stdout instead.

But in any case, that's just one error out of many similar ones that can
happen during initdb. If we care enough to fix this, we should fix them
all. Not sure it's worth the churn, though, unless you can come up with
some kind of a simple wholesale solution, rather than adding
fprintf(stdout, "\n") calls to every error condition.
- Heikki

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Stephen Frost 2014-12-05 13:16:20 Re: superuser() shortcuts
Previous Message Alvaro Herrera 2014-12-05 12:29:59 Re: Testing DDL deparsing support