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 1wLGPb-001f78-2Y for pgsql-hackers@arkaria.postgresql.org; Fri, 08 May 2026 08:18:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wLGPa-008jhj-1M for pgsql-hackers@arkaria.postgresql.org; Fri, 08 May 2026 08:18:18 +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.96) (envelope-from ) id 1wLGMn-008gyp-0p for pgsql-hackers@lists.postgresql.org; Fri, 08 May 2026 08:15:25 +0000 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wLGMj-00000000m4S-3KnZ for pgsql-hackers@lists.postgresql.org; Fri, 08 May 2026 08:15:24 +0000 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-2baca4df358so9457985ad.2 for ; Fri, 08 May 2026 01:15:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778228121; x=1778832921; darn=lists.postgresql.org; h=to:date:message-id:subject:mime-version:from:from:to:cc:subject :date:message-id:reply-to; bh=aa2cudsw/uek3+TqGk+d8eVrJTKaWPArcWHsxLHqNnI=; b=MDUTBu8kYq/2zY3SvAPXC9VsKkVLO1uqESqm/16nGO1bqZwN5EP7V1VwCy82Y+rQoG j24Du/T6kA3r2IEaFAu+Xe9Jh2q0+rD4HY/Nd3T/8Be5/SGuxM0JfZtj8FKR6XYUlXx4 mL7ZEocOPLunIFQ7rViYJrT+IOCInyI5Hft1DmkzAewBOTHXs0E80h3hL/M/waPQiZ6+ wBFyQ14UIo3KfEC2gEwjyIY5vdzK9ezqgzzajLgLtoeM/8JXyG/V23w35d4VaOfVgBiS bAkFblIqgypj3uYFWXGp2JQXyyZzRzvnImF3w2NH8nIOLeGVSNArL4qsILoNr/S72nII ugQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778228121; x=1778832921; h=to:date:message-id:subject:mime-version:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=aa2cudsw/uek3+TqGk+d8eVrJTKaWPArcWHsxLHqNnI=; b=bW6YKQpUfbbeF+ROUaPSKwbYd0Y+2UdNxI/GwcLXBDi6sPGtmOliasz1Uv5EUPMPQA pFUH5CldZrTdVH2lTP6sphA+g9HAP+6GBUZPs0I0sOGr5Ywavlhx0BFjMiUIZa6125qj hA8hYbOfjtfbZEGMCLDy6HuU4myPasIgtyzMiyVrvw41t1S3EPEVEcEmJv/+PJHkjjdE f7NY/uhuHFa9ijSdqsx8xW0uPxNi6X3+1OOEwGk/5JD7gKQIaSXFHWltUw+ZDnlNQ+qA O7fMaK/iKZK1UiHVeOXn/0Yz2whZ423KZ3KGCwN1C9PfRMCU5nsqY3kZtdmsczf5dpK1 /Vjg== X-Gm-Message-State: AOJu0YzhYEWMJoSl+c/hPjXzYkMpnvHum8BK1z5l8LTtTWbX7pZUuiLo SJAF/2Cm/OpsT25c3X1RmQME7Yvi/UrZXcRo50Tr15/SuqMOUMev1CtZ+28s8MiO X-Gm-Gg: Acq92OFsbR6KBu6ocVsikgRWeDNEjaQjSLE1Wz+6hDTuAp9+e3U2W449obRrSWX0011 kkGKP+CaJOX98jYdq8lHfxWPqkG+kMh2OoBDT+n7CR6+0V6GTurq/dq/WmECGlT147W8YGj6k4V 5LUY/pZraOw6bSupooTF8mHPFl0jERl6s6M/YVKujMMOsLR2dqxjGJRdEzn8N5N1rR/VBnhTz+L uiy79eIp6bc0tLAgh1ObfDy3nHWub+UQKwaa1Gyw2z0OMWxYS0WZjn0mYcJO6Y2zQNDDM0Z21ek UfKaEW7SU6xPs/iBV7WqYLkaIoi0xmf4C0FHiEtpY9Z3PZfXTagTYiDLrw6rGI/4n0ydHLcBjWG xKMVNZ80zUBgGOdKlHxzipgPRX4TU6aBp6w5Adso2SWY2xDJG/AVJASlNhph2WaXIM0Xj4cg3aM pKc+uhrwVLqiNQVqkWR+kt+VmFHCxQnOI= X-Received: by 2002:a17:903:144f:b0:2ba:359a:9b8e with SMTP id d9443c01a7336-2ba793bfacbmr122384265ad.10.1778228120693; Fri, 08 May 2026 01:15:20 -0700 (PDT) Received: from smtpclient.apple ([45.32.121.103]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2baf1d2709bsm14048575ad.5.2026.05.08.01.15.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 May 2026 01:15:19 -0700 (PDT) From: Chao Li Content-Type: multipart/mixed; boundary="Apple-Mail=_C298D5B8-EECF-439A-A16A-77E3DC287CB1" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.400.21\)) Subject: Fix wrong error message from pg_get_tablespace_ddl() Message-Id: <53D05145-CE87-424F-A492-BB22A09BBE11@gmail.com> Date: Fri, 8 May 2026 16:14:40 +0800 To: PostgreSQL Hackers X-Mailer: Apple Mail (2.3864.400.21) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Apple-Mail=_C298D5B8-EECF-439A-A16A-77E3DC287CB1 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Hi, I started testing pg_get_tablespace_ddl(). While tracing = pg_get_tablespace_ddl_internal(), I noticed that this error report must = be 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 = 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: 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/ --Apple-Mail=_C298D5B8-EECF-439A-A16A-77E3DC287CB1 Content-Disposition: attachment; filename=v1-0001-Fix-wrong-error-message-from-pg_get_tablespace_dd.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="v1-0001-Fix-wrong-error-message-from-pg_get_tablespace_dd.patch" Content-Transfer-Encoding: quoted-printable =46rom=200ffd155eca7691b16fe799f43a776a7dc59f3b7c=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20"Chao=20Li=20(Evan)"=20=0A= Date:=20Fri,=208=20May=202026=2015:53:23=20+0800=0ASubject:=20[PATCH=20= v1]=20Fix=20wrong=20error=20message=20from=20pg_get_tablespace_ddl()=0A=0A= pg_get_tablespace_ddl_internal()=20checks=20ACL_SELECT=20on=20the=20= pg_tablespace=0Acatalog=20relation=20before=20reading=20the=20tablespace=20= tuple.=20=20However,=20when=20that=0Acheck=20failed,=20it=20reported=20= the=20error=20as=20permission=20denied=20for=20the=20specific=0A= tablespace=20object.=0A=0AReport=20the=20failure=20as=20permission=20= denied=20for=20table=20pg_tablespace=20instead,=0Amatching=20the=20= object=20on=20which=20the=20permission=20check=20was=20actually=20= performed.=0A=0AAuthor:=20Chao=20Li=20=0A---=0A=20= src/backend/utils/adt/ddlutils.c=20|=202=20+-=0A=201=20file=20changed,=20= 1=20insertion(+),=201=20deletion(-)=0A=0Adiff=20--git=20= a/src/backend/utils/adt/ddlutils.c=20b/src/backend/utils/adt/ddlutils.c=0A= index=20d6f55c48f37..11bf5ee5836=20100644=0A---=20= a/src/backend/utils/adt/ddlutils.c=0A+++=20= b/src/backend/utils/adt/ddlutils.c=0A@@=20-681,7=20+681,7=20@@=20= pg_get_tablespace_ddl_internal(Oid=20tsid,=20bool=20pretty,=20bool=20= no_owner)=0A=20=09if=20(pg_class_aclcheck(TableSpaceRelationId,=20= GetUserId(),=20ACL_SELECT)=20!=3D=20ACLCHECK_OK)=0A=20=09{=0A=20=09=09= ReleaseSysCache(tuple);=0A-=09=09aclcheck_error(ACLCHECK_NO_PRIV,=20= OBJECT_TABLESPACE,=20spcname);=0A+=09=09aclcheck_error(ACLCHECK_NO_PRIV,=20= OBJECT_TABLE,=20"pg_tablespace");=0A=20=09}=0A=20=0A=20=09/*=0A--=20=0A= 2.50.1=20(Apple=20Git-155)=0A=0A= --Apple-Mail=_C298D5B8-EECF-439A-A16A-77E3DC287CB1--