Re: [PATCH] initdb: Treat empty -U argument as unset username
От | Daniel Gustafsson |
---|---|
Тема | Re: [PATCH] initdb: Treat empty -U argument as unset username |
Дата | |
Msg-id | CEDBFBDE-2BBA-4568-8B9B-42AD74E377EA@yesql.se обсуждение исходный текст |
Ответ на | [PATCH] initdb: Treat empty -U argument as unset username (Jianghua Yang <yjhjstz@gmail.com>) |
Список | pgsql-hackers |
> On 2 Jul 2025, at 15:52, Jianghua Yang <yjhjstz@gmail.com> wrote: > > Hi hackers, > > Based on the suggestion that we should explicitly reject empty usernames instead of silently falling back, I’ve updatedthe 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 alsobrings 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
В списке pgsql-hackers по дате отправления: