Re: [PATCH] initdb: Treat empty -U argument as unset username - Mailing list pgsql-hackers

From Jianghua Yang
Subject Re: [PATCH] initdb: Treat empty -U argument as unset username
Date
Msg-id CAAZLFmSKrcovMSauueWg=8VdZN-fHPH2ZengZRKA8AfgST6o6w@mail.gmail.com
Whole thread Raw
In response to [PATCH] initdb: Treat empty -U argument as unset username  (Jianghua Yang <yjhjstz@gmail.com>)
Responses Re: [PATCH] initdb: Treat empty -U argument as unset username
List pgsql-hackers

git show 8e673801262c66af4a54837f63ff596407835c20


        effective_user = get_id();

-       if (strlen(username) == 0)

+       if (!username)

                username = effective_user;


The previous code already intended to treat a missing username as falling back to the system user. 
The check was changed from strlen(username) == 0 to !username, but this inadvertently stopped handling the empty-string case. This patch restores the original intent and makes the behavior consistent.

David G. Johnston <david.g.johnston@gmail.com> 于2025年7月1日周二 20:12写道:
On Tue, Jul 1, 2025 at 7:56 PM Jianghua Yang <yjhjstz@gmail.com> wrote:
Let me know if this approach seems reasonable or if you’d prefer we explicitly reject empty usernames with an error instead.


I'd rather we reject the ambiguous input.

David J.

pgsql-hackers by date:

Previous
From: wenhui qiu
Date:
Subject: Re: Making pg_rewind faster
Next
From: Alexander Lakhin
Date:
Subject: Re: Improving tracking/processing of buildfarm test failures