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

From David G. Johnston
Subject Re: [PATCH] initdb: Treat empty -U argument as unset username
Date
Msg-id CAKFQuwaCPkb8=2_V3121Ei0MBrg02FLRNQbcAcyzCO3dAha=Gw@mail.gmail.com
Whole thread Raw
In response to Re: [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
We try to stick with plain text and inline/bottom replies here.

On Tue, Jul 1, 2025 at 8:31 PM Jianghua Yang <yjhjstz@gmail.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.








pgsql-hackers by date:

Previous
From: Alexander Lakhin
Date:
Subject: Re: Improving tracking/processing of buildfarm test failures
Next
From: Dilip Kumar
Date:
Subject: Re: Proposal: Global Index for PostgreSQL