Re: [PATCH] initdb: Treat empty -U argument as unset username

From: Jianghua Yang <yjhjstz(at)gmail(dot)com>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: [PATCH] initdb: Treat empty -U argument as unset username
Date: 2025-07-02 03:30:53
Message-ID: CAAZLFmSKrcovMSauueWg=8VdZN-fHPH2ZengZRKA8AfgST6o6w@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: 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(dot)g(dot)johnston(at)gmail(dot)com> 于2025年7月1日周二 20:12写道:

> On Tue, Jul 1, 2025 at 7:56 PM Jianghua Yang <yjhjstz(at)gmail(dot)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.
>
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message vignesh C 2025-07-02 03:39:52 Re: Huge commitfest app update upcoming: Tags, Draft CF, Help page, and automated commitfest creat/open/close
Previous Message wenhui qiu 2025-07-02 03:16:25 Re: Making pg_rewind faster