Hi,
The underlying aclitem quoting issue has been fixed in commit 64840e46243
("Fix inconsistent quoting of role names in ACLs"), so the concern about
this patch interfering with that investigation no longer applies.
Here's a rebased version of the patch. The approach is unchanged from v3:
reject an empty string passed to -U/--username early with a clear error
message, rather than letting it fall through to a confusing FATAL during
bootstrap SQL execution.
Changes:
- Add an empty-string check before the existing pg_ prefix check
in initdb's main(), using pg_fatal().
- Add a regression test using command_fails_like() to verify the
error message.
Jianghua Yang <[email protected]> 于2025年7月5日周六 10:45写道:
> Hi Tom,
>
> Thanks for the clarification.
>
> Just to provide a bit more context — we encountered this issue in a
> production environment where initdb was being run inside a Docker
> container. In such environments, the $USER environment variable may be
> unset or empty, which causes initdb -U $USER to fail with a confusing
> error.
>
> While it's true that this behavior has existed for a long time, it's
> become more relevant as Docker and containerized deployments have become
> common. This issue can be hard to diagnose for users unfamiliar with the
> internals of initdb, especially since the failure message isn't very
> informative in this case.
>
> I understand your point about not wanting to merge the patch prematurely
> if it could obscure underlying problems. That said, this particular fix
> seems orthogonal to the ACL parsing issue and addresses a real-world
> usability problem with minimal risk.
>
> Would you be open to reconsidering a standalone merge of this patch, or
> perhaps applying a minimal workaround for cases where $USER is unset?
>
> Thanks again for your time and consideration.
>
> Best regards,
> Jianghua Yang
>
> Tom Lane <[email protected]> 于2025年7月5日周六 10:34写道:
>
>> Jianghua Yang <[email protected]> writes:
>> > I wanted to ask if this patch can be merged first, as it seems to be a
>> > separate issue different from the aclitem parsing problem Tom discussed
>> in
>> >
>> https://www.postgresql.org/message-id/3792884.1751492172%40sss.pgh.pa.us
>>
>> Merging your patch will make it more difficult to poke at these
>> underlying issues, so I'm not in a hurry to do that. It's not
>> like this is an urgent issue: initdb has behaved like that for
>> years if not decades, and nobody's complained before.
>>
>> regards, tom lane
>>
>
0001-initdb-reject-empty-string-for-U-username-option.patch
Description: Binary data
