public inbox for [email protected]
help / color / mirror / Atom feedFrom: Daniel Gustafsson <[email protected]>
To: Jianghua Yang <[email protected]>
Cc: Robert Treat <[email protected]>
Cc: David G. Johnston <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH] initdb: Treat empty -U argument as unset username
Date: Wed, 2 Jul 2025 16:01:26 +0200
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAAZLFmSY_s6TOsiTwjzqrc2Y4uShATuWcEEN8O8cdtpkS=zfLg@mail.gmail.com>
References: <CAAZLFmRK+XFp=mqCeruyNVkqGq5mH45CP+e-8oNttPRtLuB5eQ@mail.gmail.com>
<CAKFQuwbVK=oANp9XLdQknd7o9jJOUFQanUtG3QAh-3kuaM5tJw@mail.gmail.com>
<CAAZLFmSKrcovMSauueWg=8VdZN-fHPH2ZengZRKA8AfgST6o6w@mail.gmail.com>
<CAKFQuwaCPkb8=2_V3121Ei0MBrg02FLRNQbcAcyzCO3dAha=Gw@mail.gmail.com>
<CABV9wwOOpOijL9sY03KV3WNvgMxVFsyfvfYbfy2MYfn40z0yyQ@mail.gmail.com>
<[email protected]>
<CAAZLFmSY_s6TOsiTwjzqrc2Y4uShATuWcEEN8O8cdtpkS=zfLg@mail.gmail.com>
> On 2 Jul 2025, at 15:52, Jianghua Yang <[email protected]> wrote:
>
> Hi hackers,
>
> Based on the suggestion that we should explicitly reject empty usernames instead of silently falling back, I’ve updated the patch accordingly.
>
> ### Changes in v2:
>
> - `initdb` now errors out immediately if the `-U` or `--username` argument is an empty string.
> - The error message is:
>
> superuser name must not be empty
>
> - A regression test is added to `src/bin/initdb/t/001_initdb.pl` to verify that the case `initdb -U ''` fails as expected.
>
> This approach avoids any ambiguity about whether an empty username is valid, and fails early with a clear message. It also brings consistency with existing checks, such as the one disallowing superuser names starting with `pg_`.
>
> Let me know if this looks acceptable or if further refinement is needed.
+ pg_log_error("superuser name must not be empty");
+ exit(1);
I would prefer pg_fatal() for this.
--
Daniel Gustafsson
view thread (16+ messages) latest in thread
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 using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected], [email protected]
Subject: Re: [PATCH] initdb: Treat empty -U argument as unset username
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox