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 1uY6Dz-00149M-I7 for pgsql-hackers@arkaria.postgresql.org; Sat, 05 Jul 2025 16:58:52 +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 1uY6Dx-007zhu-Kf for pgsql-hackers@arkaria.postgresql.org; Sat, 05 Jul 2025 16:58:50 +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 1uY6Dx-007zfA-5p for pgsql-hackers@lists.postgresql.org; Sat, 05 Jul 2025 16:58:49 +0000 Received: from mail-ej1-x636.google.com ([2a00:1450:4864:20::636]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uY6Dv-005vCb-0x for pgsql-hackers@lists.postgresql.org; Sat, 05 Jul 2025 16:58:49 +0000 Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-ae0d7b32322so268453266b.2 for ; Sat, 05 Jul 2025 09:58:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1751734726; x=1752339526; 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=6p3ZsAbfywLAainlkaGEs7dkRp5UeKX5iQExznVprgQ=; b=ZHIK0syMHmJyLF7R5hVJW7JvDwo4lk6GhfImjw8JsNQFlJDknNQtaiGqZ6JM9tsUkV p9KKLle0E5RTtPwk1K/3ZEOAag8Q8FpPN55lOKTyZiH5t/loQfKCLUTaA9hOQZF0vj+f Y9ceDz3NS+J9NMNLIjBb1/xI9Vr6zjZjlYC0yLy/hh8RiHQSHAMi/qUf2FUpXlSfAn9j bVFxWU2TR3L4a4JWZGC3+qSrZpDRCi6Zvi8QzzkBa3J9aWNZf7Dba1mSz52o4/VYC91y 7G+eqjrF0MufkB209MxClWyWK7m+migpl9GTeQ2t9J5qjETqiNrnUs6l+ZgQd0ox4k7r aqQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751734726; x=1752339526; 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=6p3ZsAbfywLAainlkaGEs7dkRp5UeKX5iQExznVprgQ=; b=ZdbP6gQMUZWZqf6d6s1gKQXpwMfMyfQoaJHUArgoM+vWSywb6rR0V9kt5/XNRduXGG h8aawLfXzDaDOOXLUlUwzkPRw2dhq1P3wseCvv98Y4g7z9T7CIsZKoJ10Q+AtzuFgopW X6sCKfYSlwFl2+/Szy+ASTRhl4deI+MIFbYRuDgvEV3YB7R2B7UzJ5PFDqu6GdXkf8zE 5expZ0xTPUuyNRt8vmlRnBaleQpfCF6m9E6WFTiKvnSUH+jBMxwYBWuBKsDvKhk+t1iF 8oZxju94X+O5QsXPPN3j234gF5BcnZr5VCF2s+TIeIw9GyoCoANran+pgn796So7LRVd xWjA== X-Forwarded-Encrypted: i=1; AJvYcCUIhPlPgZEE3NdbHTL5mJDOioJXblbH/JPhmfpUGJY41Tj5r7L2GrGluWctvkOaaOH1NM2PNJX/BQ5nWsie@lists.postgresql.org X-Gm-Message-State: AOJu0YwAQWKhRT4KLTaATQ7AAK2BxYPoaoPdj5zcnlwmF5cX2N+G2Xn4 DZ2bY5qHmBPZr8Jgxqgsg8/Q6Sy/FZPI2/XKUnILocYlDtA8vp2j0NjTRrYMoQod54PeW+1YkRJ im5+F8QZjvHNzAKIQAlbMo2Y6uI8AtCSwF9ld1S4= X-Gm-Gg: ASbGncu1cBlZPkV+DYYDsEjuwW/YTzwngWdIswJtfz2nYOOwntrRasj40jcyvoW10Dw uJL6oQLSCaqBc3cj/QZKM40E4YORQ4JLMXNdtgqm+IMwE2dsa+v487TxcChFNAE8+a7W/y9rNBZ /bnN5sZZwxp8mvjn5knBYOMU+H6311bZfX+HopBKkRhwzdP3SOJANcgOQ8WmzuBM+XT2vp7hCvB H+dpfFAmHJuHAQ= X-Google-Smtp-Source: AGHT+IE7G6gdyZrHI9x8oRHpw/6rGGjsfuYPlzOgFRuM9jQ6c2iaPXFEqfhQCq+M1fdDHBgj5v7VNR7JtIO8MpQ8ZcU= X-Received: by 2002:a17:906:483:b0:ae3:cdc0:eeb8 with SMTP id a640c23a62f3a-ae3fe59ffbcmr499455866b.28.1751734725333; Sat, 05 Jul 2025 09:58:45 -0700 (PDT) MIME-Version: 1.0 References: <3793879.1751492926@sss.pgh.pa.us> In-Reply-To: <3793879.1751492926@sss.pgh.pa.us> From: Jianghua Yang Date: Sat, 5 Jul 2025 09:58:09 -0700 X-Gm-Features: Ac12FXxbWMG50HUorcUiil3lYReo-i2F2mKBgmr_V0qnqG5etdBb3iBdW7ybZ3o Message-ID: Subject: Re: [PATCH] initdb: Treat empty -U argument as unset username To: Tom Lane Cc: Peter Eisentraut , pgsql-hackers@lists.postgresql.org Content-Type: multipart/alternative; boundary="0000000000000b584006393186ee" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000000b584006393186ee Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hello Daniel, Tom lane 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 . Best regards, Jianghua Tom Lane =E4=BA=8E2025=E5=B9=B47=E6=9C=882=E6=97=A5=E5= =91=A8=E4=B8=89 14:48=E5=86=99=E9=81=93=EF=BC=9A > Peter Eisentraut writes: > > ... The aclitem parsing ends up in getid() > > in src/backend/utils/adt/acl.c, which thinks that an input string > > consisting entirely of "" is an escaped double quote. > > Yeah, that is definitely broken, and also it occurs to me that this > coding is not robust in the face of non-ASCII identifiers (since > the behavior of isalnum is unportable in that case). I've posted > a draft patch for that in a separate thread [1]. > > > Maybe it's worth fixing that, and making putid() also print empty user > > names correspondingly. > > putid() prints an empty name as an empty string, which seems fine > at least at this level. > > > Alternatively, it's the fault of initdb that it constructs aclitem > > values that don't follow the aclitem-specific quoting rules. > > With the patch at [1], initdb -U '' still fails at the same place, > but now with > > FATAL: a name must follow the "/" sign at character 72 > > which is a consequence of getid()'s output not distinguishing > "I found nothing" from "I found an empty string". Now if we > cared to support empty identifiers, we could make some more > revisions here so that those were consistently represented as > "" rather than nothing. But I fail to see that that's a useful > expenditure of time: we're never going to allow empty names. > > > Another thought is, if we don't allow zero-length names, shouldn't > > namein() reject empty input strings? > > I'm inclined to think not. It's introducing too much of a gotcha > for too little return. As a perhaps-not-quite-exact analogy, > NULL::name also doesn't correspond to any identifier you can spell > in SQL; but we're not going to try to forbid that value. So there > is at least one value of type "name" that isn't valid in SQL, and > I don't see why ''::name can't be another. > > regards, tom lane > > [1] > https://www.postgresql.org/message-id/3792884.1751492172%40sss.pgh.pa.us > --0000000000000b584006393186ee Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello Daniel, Tom lane

I want= ed to ask if this patch can be merged first, as it seems to be a separate i= ssue different from the aclitem parsing problem Tom discussed in h= ttps://www.postgresql.org/message-id/3792884.1751492172%40sss.pgh.pa.us= .

Best regards,
Jianghua


Tom Lane = <tgl@sss.pgh.pa.us> =E4=BA= =8E2025=E5=B9=B47=E6=9C=882=E6=97=A5=E5=91=A8=E4=B8=89 14:48=E5=86=99=E9=81= =93=EF=BC=9A
Pet= er Eisentraut <peter@eisentraut.org> writes:
> ... The aclitem parsing ends up in getid()
> in src/backend/utils/adt/acl.c, which thinks that an input string
> consisting entirely of "" is an escaped double quote.

Yeah, that is definitely broken, and also it occurs to me that this
coding is not robust in the face of non-ASCII identifiers (since
the behavior of isalnum is unportable in that case).=C2=A0 I've posted<= br> a draft patch for that in a separate thread [1].

> Maybe it's worth fixing that, and making putid() also print empty = user
> names correspondingly.

putid() prints an empty name as an empty string, which seems fine
at least at this level.

> Alternatively, it's the fault of initdb that it constructs aclitem=
> values that don't follow the aclitem-specific quoting rules.

With the patch at [1], initdb -U '' still fails at the same place,<= br> but now with

FATAL:=C2=A0 a name must follow the "/" sign at character 72

which is a consequence of getid()'s output not distinguishing
"I found nothing" from "I found an empty string".=C2=A0= Now if we
cared to support empty identifiers, we could make some more
revisions here so that those were consistently represented as
"" rather than nothing.=C2=A0 But I fail to see that that's a= useful
expenditure of time: we're never going to allow empty names.

> Another thought is, if we don't allow zero-length names, shouldn&#= 39;t
> namein() reject empty input strings?

I'm inclined to think not.=C2=A0 It's introducing too much of a got= cha
for too little return.=C2=A0 As a perhaps-not-quite-exact analogy,
NULL::name also doesn't correspond to any identifier you can spell
in SQL; but we're not going to try to forbid that value.=C2=A0 So there=
is at least one value of type "name" that isn't valid in SQL,= and
I don't see why ''::name can't be another.

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 regards, tom lane

[1] https://www.postgresql.o= rg/message-id/3792884.1751492172%40sss.pgh.pa.us
--0000000000000b584006393186ee--