Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uWoez-001q97-1A for pgsql-hackers@arkaria.postgresql.org; Wed, 02 Jul 2025 04:01:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uWoex-00A1Tk-3M for pgsql-hackers@arkaria.postgresql.org; Wed, 02 Jul 2025 04:01:23 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uWoew-00A1Tc-La for pgsql-hackers@lists.postgresql.org; Wed, 02 Jul 2025 04:01:23 +0000 Received: from mail-oo1-xc30.google.com ([2607:f8b0:4864:20::c30]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uWoev-0054UA-1l for pgsql-hackers@lists.postgresql.org; Wed, 02 Jul 2025 04:01:22 +0000 Received: by mail-oo1-xc30.google.com with SMTP id 006d021491bc7-6120049f09fso284562eaf.2 for ; Tue, 01 Jul 2025 21:01:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1751428881; x=1752033681; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=yflUvkZnnWbWz8X3hiVchpTAQNn/s7f3oXBVuxIb5X8=; b=CwLiZtAbnzVncupK2p/hlvB0NFn8pu5cHO59vBQgLoS+LAuX/49QUt15tsVwCrzXoy 3pZjGjR9a/B2Y8uPNIB+/3LgaXV44mTHpsN92aGDrZmj8pQIqDJ3g2U7eIdQQV02KwAn MK3+3lryZOs+mAPf4drJvsMsuw2oeEJwOD5qCjPZDDMhEYh3CJt6lyB58dAR9ltvnT/B uuGqKclO2L88LR3ooObbGSlHwsMMYl/MyJVTUat1pKnzT/jwg1Zf82TJsUIS59V1+uMa PODNmNmsfuqYwngdHBnU3DHxUmf5YPM9mXX5xWarNudZQGG3uHUKVhF0Wd7LhvSKj+E9 xwww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751428881; x=1752033681; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=yflUvkZnnWbWz8X3hiVchpTAQNn/s7f3oXBVuxIb5X8=; b=FkYVovJCUVIH9MMM6bGRAoJgHFPWXEYBEnOlNK+wlzQl7MufrGUUqTSpzsrnY4klCU 1me3N6kMbDsNux+hPgu8dxX421y9CtnciojG8K9RhXoHjDeLtPOD0c8F9ua31LEonD5A 1pGviqpi+WCa/rC5RtdI+VMhUI+v1dXM110KBL86D1ArlV/DFKIF42WclgkpemEiQagE J/E1E3xhIZDTIPTy/QYOp9eBwGp5A0UW7gpgSsHCYoyTKSmnQ0d9cv2Vx2IBjU4DJP1b 9LyKPiMKlW95jztDb6ZsD1VKYavxytGinb04BDxHHhquWM/hz2sEy+1NxO0yphMqEQlM sI1g== X-Gm-Message-State: AOJu0YymrBu9XlkBw6wYinZ4Xc0774wDjfaUCe9uPLC6773gIcmcR4zJ 8aKkO+SQxiwdxgmMN0wMC5zTXR/kISV3K7F5qOxopFG+RiPt2cr5Uxkxzk/MplEpZrm1Nhpeary kdE1w4e7drqbYsMcyX2pDT4qsYWFwarc= X-Gm-Gg: ASbGncu+dnlv8V13wVZs9IKqtAElZg7YsXnZ5owHPQ1bDONUD1fCIDRWnRwx7/8HOca mkS7iipX1hUA0T5xqa1VTI79ZlqahRD8PGye/KsuUcwj+VW1uAzxcFgSAaMCe+RF82VuAAhTOYc oSIcR+9wP1ewlHwLalaGdsv/NHj4Gf5+XevDT4lpUwFA2gUQc700wl1iVeih2dPEBrgnbAvt/GJ BOb X-Google-Smtp-Source: AGHT+IFHtBhTEsjD+4e5YFhAzK60bxLQBkTjkdQ+OxzS9SxRecR5gu8mVoENCN2WWm2ziUIJ2ObyS2/qmej/BO9B8o0= X-Received: by 2002:a05:6820:c8f:b0:611:e00a:598d with SMTP id 006d021491bc7-6120116d82fmr937188eaf.8.1751428880567; Tue, 01 Jul 2025 21:01:20 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: "David G. Johnston" Date: Tue, 1 Jul 2025 21:00:43 -0700 X-Gm-Features: Ac12FXwDc3FkG7owGL31ahyV49d6AffZPWidoxFOKr-yaun_C-Eo3L7ZADOyhjY Message-ID: Subject: Re: [PATCH] initdb: Treat empty -U argument as unset username To: Jianghua Yang Cc: pgsql-hackers@lists.postgresql.org Content-Type: multipart/alternative; boundary="0000000000004690960638ea5049" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000004690960638ea5049 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable We try to stick with plain text and inline/bottom replies here. On Tue, Jul 1, 2025 at 8:31=E2=80=AFPM Jianghua Yang wr= ote: > git show 8e673801262c66af4a54837f63ff596407835c20 > > > effective_user =3D get_id(); > > - if (strlen(username) =3D=3D 0) > > + if (!username) > > username =3D 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) =3D=3D 0 to !username, but th= is > 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. --0000000000004690960638ea5049 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
We try to stick with plain text and inline/bottom replies = here.

On Tue, Jul 1, 2025 at 8:31=E2=80=AFPM Jianghua Yang <yjhjstz@gmail.com> wrote:

git show 8e673801262c66af4a54837f63ff596407835c20


=C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0effective_user =3D= get_id();

- =C2=A0 =C2=A0 =C2=A0 if (strlen(username) =3D=3D = 0)

+ =C2=A0 =C2=A0 =C2=A0 if (!username)

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 username =3D effective_user;


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


At this poi= nt 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 t= han accept original intent.=C2=A0 Also, the amount of things it has to be c= onsistent 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.

<= /div>






--0000000000004690960638ea5049--