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

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Jianghua Yang <yjhjstz(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 04:00:43
Message-ID: CAKFQuwaCPkb8=2_V3121Ei0MBrg02FLRNQbcAcyzCO3dAha=Gw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

We try to stick with plain text and inline/bottom replies here.

On Tue, Jul 1, 2025 at 8:31 PM Jianghua Yang <yjhjstz(at)gmail(dot)com> wrote:

> 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.
>
>>
>>
At this point I'd rather take advantage of this behaveing in the "doesn't
work" category for the past 8 years, and thus all supported releases, and
not change existing behavior (just improve the error message) rather than
accept original intent. Also, the amount of things it has to be consistent
with is quite small and I'm pytr sure that some of those are also broken -
encoding/pgdata/textsearch all exhibit the same pattern (xlog is the
reverse so maybe ok...)

David J.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dilip Kumar 2025-07-02 04:03:51 Re: Proposal: Global Index for PostgreSQL
Previous Message Alexander Lakhin 2025-07-02 04:00:00 Re: Improving tracking/processing of buildfarm test failures