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 1uWp80-001wMh-OQ for pgsql-hackers@arkaria.postgresql.org; Wed, 02 Jul 2025 04:31: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 1uWp7x-00ADJt-91 for pgsql-hackers@arkaria.postgresql.org; Wed, 02 Jul 2025 04:31:21 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uWp7w-00ADJg-Mg for pgsql-hackers@lists.postgresql.org; Wed, 02 Jul 2025 04:31:21 +0000 Received: from mail-vk1-xa29.google.com ([2607:f8b0:4864:20::a29]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uWp7u-005E1j-2D for pgsql-hackers@lists.postgresql.org; Wed, 02 Jul 2025 04:31:20 +0000 Received: by mail-vk1-xa29.google.com with SMTP id 71dfb90a1353d-53145c74e15so1875229e0c.0 for ; Tue, 01 Jul 2025 21:31:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xzilla-net.20230601.gappssmtp.com; s=20230601; t=1751430676; x=1752035476; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=C89hjLHewJNRz40sFOcVd8HfHSnv2vhvclZSeU70s+Y=; b=i80xhDsqFbkZgpxUF0itwtx6uADf4UbLcHKeOEgj5IlAyPFXwELmbvaqtgEEeAYSCh 3VLuOUOJYnSXlfGqnupDNczVZx268SP6u+yTARd0rjYMAhW5KR4+uVzE68boHmG03CVe WhA3cbYCsuumb4wZnF2KMaNLQK/J46MBkTxG5hDXH6OUVJ4K9+3HLFn68GLAKa2L1yzO C+4DvW8uqDE3Nf8UZDI1FUw9mFN1yrVqRaC9MXFLrZjyR/EK0EbBj0SZ3mkzwbQlLPH0 1XhF1FkkKHpaDvAu93vQu2nzIj2vtf9tFRzKQpzY+D5MWsBP3dd7Vrm0J4AflwGaak/h MGog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751430676; x=1752035476; h=content-transfer-encoding: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=C89hjLHewJNRz40sFOcVd8HfHSnv2vhvclZSeU70s+Y=; b=H7ioVRz0Nfm0yDVri1RnWeixLLLd3um+KXwZouZFCjBd/Y6w5AziL4HZFrfrdi9Edt 73zbpJ+ENeCxTiyGM8TTkSGopOFx2J/nHnnZt1jLwhlv+nqoqGhjxMrA915xRxkcomU+ AD0gHjNQDd13s7jst/S7EzyIg9rpLOt5M1lC0tSE2dI7B1AENqXoMgVwltjR9eLIofRZ TcdfuKalNR9w3PwxjR/LAjt16s9KWCQh0Tmb1W41zLwUOCFW7pE5KIU4JskmIXA1ZsW5 eYCh0gFbjwEBPf8SRMr+cyoEJk9sTGWzDomU0iehuGB8tyqTv9Ok+kNshCPpp3w3rpSL cumw== X-Forwarded-Encrypted: i=1; AJvYcCVuwy213+5DX57xyQizzXo576oJgPpG4A8SAuPeQgHLvgHv3nN49MGpzNGEsBEj0gJvoqEEIKjdeCH9uQst@lists.postgresql.org X-Gm-Message-State: AOJu0Yyydf+6wuYal2Y9HGfqTJxt0WqiCP4ZAQYcUAzvt8r5CVtgdcbz T6hoGRwIIwTAIP7VX0YuCN3z4VVUUuEBZYYJ8CXou+CFaq12JxfecdQh87K2/pG0QWmux0dMjC9 fhssmYs0oIoghxeEgrBQ6SCCj/UQwqbaokCapvFQUOw== X-Gm-Gg: ASbGncvrfOYn5pJK14gHnh+1iUmDqMyJL2flqZFhhmbw6Kew1+IBS918kqNvdSfor4T Nt/4zYLgQpXr+yEghIObXWODxF5x1yP2IMJ+Nz3PAER/Dfh/piAVl8OlFXZ/tB9W2/ZoLLG4dIA SIWf4xlocbHI6p/oF6UYmIwIgOHUM2IP8+VbVUs9EMY97KTmjTNqsHeA== X-Google-Smtp-Source: AGHT+IEPeLi8FM1gNm8WWK+U5RuWMrlwyBlLjZ+7L7hkw5aKtBbMKvkKEafRHhvNt4bX3eLkz942kGiQEsvzcE92aXA= X-Received: by 2002:a05:6122:4587:b0:520:af9c:c058 with SMTP id 71dfb90a1353d-534580fd44emr1109846e0c.5.1751430676199; Tue, 01 Jul 2025 21:31:16 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Robert Treat Date: Wed, 2 Jul 2025 00:31:05 -0400 X-Gm-Features: Ac12FXzCqFyPunVbKSuxwcGMxkrZwpFoPzebgIcu5M4nyWd_ZWxRqhl_c1F3kQE Message-ID: Subject: Re: [PATCH] initdb: Treat empty -U argument as unset username To: "David G. Johnston" Cc: Jianghua Yang , pgsql-hackers@lists.postgresql.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Jul 2, 2025 at 12:01=E2=80=AFAM David G. Johnston wrote: > On Tue, Jul 1, 2025 at 8:31=E2=80=AFPM Jianghua Yang = wrote: >> >> 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 fallin= g back to the system user. >> The check was changed from strlen(username) =3D=3D 0 to !username, but t= his inadvertently stopped handling the empty-string case. This patch restor= es 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 a= ccept 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 revers= e so maybe ok...) > FWIW, I tend to agree with David; I feel like if a user passes in -U, there was probably a reason, and a good error message would be more useful in clarifying things rather than blindly pushing forward with potentially the wrong thing. Robert Treat https://xzilla.net