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.96) (envelope-from ) id 1wLHK4-001frj-2j for pgsql-hackers@arkaria.postgresql.org; Fri, 08 May 2026 09:16:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wLHK3-008xHS-2E for pgsql-hackers@arkaria.postgresql.org; Fri, 08 May 2026 09:16:39 +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.96) (envelope-from ) id 1wLHK3-008xHK-11 for pgsql-hackers@lists.postgresql.org; Fri, 08 May 2026 09:16:39 +0000 Received: from mail-yx1-xb12e.google.com ([2607:f8b0:4864:20::b12e]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wLHK0-00000001CkO-3aB7 for pgsql-hackers@lists.postgresql.org; Fri, 08 May 2026 09:16:39 +0000 Received: by mail-yx1-xb12e.google.com with SMTP id 956f58d0204a3-651c7ddf514so1976142d50.1 for ; Fri, 08 May 2026 02:16:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1778231795; cv=none; d=google.com; s=arc-20240605; b=QBIVD+iYl+FHrVnNOD8uy7q97j32mx909/8Egy97/EyC6iPIPKpKwM/B09GY0965ON Xvd6XZzCEpaaNyw+MJnI73wqeHSMvXATFkaerBDF6ORk1uN/hMEEjVOcjftL3wyNijRi UdYi+kj3LOr+b9Y2p+h1wRBSQk1HOolT1vEbufwpYSEzsWL56J8EMvTapTJ9qMZ1O3wY 7kI6qD1Ct8ZEE04+EPo0D0UUNPBPlb+zxNrDdYpxxkk4xdP0GB4ST9/1FT5smqtcFtLg qBuVNGgM+1Gp4cTF0CW5yiAO+k7icK3MYfE7W/VWG4mlPrurbRf3T/6/HwYGLS0Wd1Qa 2wxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=Ra7oZKnGRS1XsIiHFs+QQngbF8Z+JvTOVIQotEsOQgk=; fh=difWPyZhf+FMfWnUHiBJsrLSKQJL23D1+3HP+YAZNos=; b=kYun6+SIZYkKnSbeVHqXj8y6RkHQh3UoMPAkaGBWBnJOIzyCNNvMw3NnYI6g25f4N6 yGQFGN3aEiXmdGXTIHyIiddgH1E6ji6631CdUofuXcgOtY3RInvfEcGlwgnscQaomRmo GUnH2YjxZdMtKKy9Ec8uD/lIJLL+G0+W214LR/GvcM0E9hInIXN3h2vKcDyOjTfIgsbs hM/MCCsTCJKoppXXXoTY6sXSTd/VmhkXqhTEDR6fYAdX1jAu5c8YvOZu57gnQ8UNxRZO a9a5dAUP9B8n44cQFWsX1Uu+H7FMi/35N1jvjC47PjTQ3IL5GgMy4rmkNuPKUUJgQjsH cTxA==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778231795; x=1778836595; 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=Ra7oZKnGRS1XsIiHFs+QQngbF8Z+JvTOVIQotEsOQgk=; b=hVLlfZ52/6T8fIEu0S6N/LYYi3HdpBhvOSr7Gdl8dMoFYgi/wMfqv0PASal6I8ESMF Z2AjHMwBYObhC6ERfrXU7haYAd1d/z4Jhyg3wlKuW7YnsTjal9nGa65IwSheWVxzlj9K kULX5a5AhqrIERgRj5Uqayan79UjyjNoi/cN/dEH9JRQjWMbz1UBQXiebV7JrvUdv0yU UfW5sNB4uVynLNCKiNoHEWoO5Kn8ygSC9rIM5roVFvlFI/9IDflQQdE+XWuMgmRDC7Fh z0f744UC1y2XQO9tL3BVAaEprGkFIT/XyaMpOw2RWmVtI4ix8ikVk2tNg0z40IUtxQQL EvKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778231795; x=1778836595; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Ra7oZKnGRS1XsIiHFs+QQngbF8Z+JvTOVIQotEsOQgk=; b=CSn6SmXlxISY7oNBmvCFWOOs2ZhZ00Vxfm7e4Y7Wzm5vixcpqZoC26l3WaLpQKnDhC NBvxHWfOeE//xurtxR/anGjaXWWS7GR+DnVGOm2e7SRTzNTXeNmeSHmVEYb4+XQGXp6Y W9DEZz2u/aCjRLMI9IdBxDoOnuZIrq/X5PWbF3cW7qj4X9i0aCANTRScUk1rCu22PGB3 DJ9qNNtdFOSc1PoF0J5mMWR/3lJg2M6L5MLTIya33OTymhFArWkjGMAI26mHu/kFXdy2 7tpmkipRBlCyFvMMClT+cjGt+EDohVOWwTz7LHi5XBnctmdOUWLR0N4K8aB3q7nKGrnD +v1w== X-Gm-Message-State: AOJu0YyP/heFOeA/JardFcK+g6KCLcwL6DytzYpz8Uph4WD13KKlbLQ6 GDgjKmmp/992o+oMrmA8iG5cK9CSFwc+oS6Df3aTSBReay1wq3bhnymGOMAJjOqcWS2eyf3WxjF GhLzbjULXNNsBPFAzSz9JgG8cHp+WjBo= X-Gm-Gg: Acq92OE8EmTxRCZyozbgTy64qX/O3W8ENIkIyLjDozOkHnPuntujoPEP/6gjZJ+KVsc EChWg2eNFmvzcHV6CCfCEZ1j+g8K8BPoOFcSDfzxfGUdJfMFNuriP6Qmd2YpsLbu2rrWSlsUmDZ HFbylCtwxXmM/waQjqMWdY0p/6WwvpZZUgLMeEt1T3m6xU3VltwxBJGeix04Zo2Y+sckQdJg7iM xEr6mSXAQjraSQKlAzBtaX2aFh3eKXVw6mJUZrn3LLUwLX6T5nus2vd5/xz3FnIVaCnK8lEM+YU xFeGGQ== X-Received: by 2002:a05:690e:e8b:b0:651:c128:54a5 with SMTP id 956f58d0204a3-65d9d0639cbmr108569d50.4.1778231793638; Fri, 08 May 2026 02:16:33 -0700 (PDT) MIME-Version: 1.0 References: <53D05145-CE87-424F-A492-BB22A09BBE11@gmail.com> In-Reply-To: <53D05145-CE87-424F-A492-BB22A09BBE11@gmail.com> From: Zhenwei Shang Date: Fri, 8 May 2026 17:16:21 +0800 X-Gm-Features: AVHnY4Lgbr8p0b0hSDwFIKFR3Azcnkgzwb91VGQNkyyf32FH6i1WitkRXGqGYHU Message-ID: Subject: Re: Fix wrong error message from pg_get_tablespace_ddl() To: Chao Li Cc: PostgreSQL Hackers Content-Type: multipart/alternative; boundary="000000000000635e8106514adada" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000635e8106514adada Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Chao Li =E4=BA=8E2026=E5=B9=B45=E6=9C=888=E6=97=A5= =E5=91=A8=E4=BA=94 16:15=E5=86=99=E9=81=93=EF=BC=9A > Hi, > > I started testing pg_get_tablespace_ddl(). While tracing > pg_get_tablespace_ddl_internal(), I noticed that this error report must b= e > wrong: > ``` > /* User must have SELECT privilege on pg_tablespace. */ > if (pg_class_aclcheck(TableSpaceRelationId, GetUserId(), > ACL_SELECT) !=3D ACLCHECK_OK) > { > ReleaseSysCache(tuple); > aclcheck_error(ACLCHECK_NO_PRIV, OBJECT_TABLESPACE, > spcname); > } > ``` > > The comment clearly says that SELECT privilege on pg_tablespace is > required, but the error is reported against the target tablespace instead= . > > This is easy to reproduce: > ``` > evantest=3D# set allow_in_place_tablespaces =3D true; > SET > evantest=3D# create role r1; > CREATE ROLE > evantest=3D# create tablespace ts1 location ''; > CREATE TABLESPACE > evantest=3D# revoke select on pg_tablespace from r1; > REVOKE > evantest=3D# set role r1; > SET > evantest=3D> select * from pg_get_tablespace_ddl('ts1'); > ERROR: permission denied for tablespace ts1 > ``` > > Attached is a simple one-line fix. Attached is a simple one-line fix. I > did not add a new test, as we usually try to avoid extending the test tim= e > for such a small fix. With the fix, the error message now looks like: > ``` > evantest=3D> select * from pg_get_tablespace_ddl('ts1'); > ERROR: permission denied for table pg_tablespace > ``` > > Oops, I was one of the reviewers of the original patch. Sorry for not > finding this during review. > > Best regards, > -- > Chao Li (Evan) > HighGo Software Co., Ltd. > https://www.highgo.com/ > > Thanks for the patch. I can reproduce the problem and the fix looks correct to me. Regards, Zhenwei Shang --000000000000635e8106514adada Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


Chao Li <li.evan.chao@gmail.com> =E4=BA=8E2026=E5= =B9=B45=E6=9C=888=E6=97=A5=E5=91=A8=E4=BA=94 16:15=E5=86=99=E9=81=93=EF=BC= =9A
Hi,

I started testing pg_get_tablespace_ddl(). While tracing pg_get_tablespace_= ddl_internal(), I noticed that this error report must be wrong:
```
=C2=A0 =C2=A0 =C2=A0 =C2=A0 /* User must have SELECT privilege on pg_tables= pace. */
=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (pg_class_aclcheck(TableSpaceRelationId, Get= UserId(), ACL_SELECT) !=3D ACLCHECK_OK)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ReleaseSysCache(tup= le);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 aclcheck_error(ACLC= HECK_NO_PRIV, OBJECT_TABLESPACE, spcname);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 }
```

The comment clearly says that SELECT privilege on pg_tablespace is required= , but the error is reported against the target tablespace instead.

This is easy to reproduce:
```
evantest=3D# set allow_in_place_tablespaces =3D true;
SET
evantest=3D# create role r1;
CREATE ROLE
evantest=3D# create tablespace ts1 location '';
CREATE TABLESPACE
evantest=3D# revoke select on pg_tablespace from r1;
REVOKE
evantest=3D# set role r1;
SET
evantest=3D> select * from pg_get_tablespace_ddl('ts1');
ERROR:=C2=A0 permission denied for tablespace ts1
```

Attached is a simple one-line fix. Attached is a simple one-line fix. I did= not add a new test, as we usually try to avoid extending the test time for= such a small fix. With the fix, the error message now looks like:
```
evantest=3D> select * from pg_get_tablespace_ddl('ts1');
ERROR:=C2=A0 permission denied for table pg_tablespace
```

Oops, I was one of the reviewers of the original patch. Sorry for not findi= ng this during review.

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
ht= tps://www.highgo.com/


Thanks fo= r the patch. I can reproduce the problem and the fix looks correct to me.

Regards,
Zhenwei Shang
--000000000000635e8106514adada--