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. Patch attached. Best regards, Jianghua Yang Daniel Gustafsson <dan...@yesql.se> 于2025年7月2日周三 00:16写道: > > On 2 Jul 2025, at 06:31, Robert Treat <r...@xzilla.net> wrote: > > > FWIW, I tend to agree with David; I feel like if a user passes in -U, > > there was probably a reason, and a good error message would be more > > useful in clarifying things rather than blindly pushing forward with > > potentially the wrong thing. > > Agreed, and it's not even clear that the previous code was intentionally > trying > to allow an empty -U. An improved error message would be a good patch > though. > > -- > Daniel Gustafsson > >
0001-initdb-Reject-empty-string-for-U-username-option.patch
Description: Binary data