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 1wLXnq-001qrh-2w for pgsql-hackers@arkaria.postgresql.org; Sat, 09 May 2026 02:52:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wLXnp-00C73v-2T for pgsql-hackers@arkaria.postgresql.org; Sat, 09 May 2026 02:52:29 +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 1wLXnp-00C73n-1U for pgsql-hackers@lists.postgresql.org; Sat, 09 May 2026 02:52:29 +0000 Received: from mail-yx1-xb136.google.com ([2607:f8b0:4864:20::b136]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wLXnn-00000001KsC-2GpJ for pgsql-hackers@lists.postgresql.org; Sat, 09 May 2026 02:52:29 +0000 Received: by mail-yx1-xb136.google.com with SMTP id 956f58d0204a3-654672a6d68so2858670d50.0 for ; Fri, 08 May 2026 19:52:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1778295146; cv=none; d=google.com; s=arc-20240605; b=IVuAL8OqDAhfIn9qtxPlZsQlcGQ8099TDFq2BToAkhnYr59JiDq+qIST8PqCJXJUJm 3URcPsY1KAj23tghSacrcDVLNanLRKxnALT7C5y/kllOtMOqVuDkjsoDBNPdtmLKa50t Drf8gFhYvG0vj57UPuiPgyOOX6nNk3jHResl5G8ljy5iLMMsCqPVDHqv4lvdIaLOMYJ2 qvoifLTUc7HpOCaXbZ14FqDwbKdprE3iD9W6ZNCJTJWl2vHRiAfwto8I66F1FU3yOuWO m7cQ54pTIABjJDFkJ5CtbqD5uI0BFxGr64IiBNSc5kkergPOlOMKnBvOwcY5O+gcXF7W rdoA== 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:references:in-reply-to :mime-version:dkim-signature; bh=wsKGfuBVer/K042Sdj7URZ9WD1/hTA/HzRTCVp9e5C4=; fh=cY0dBLQqcyn1MXSM8XHioTHjKSiLMOuopUiKf+lk19Y=; b=ZGU6cwNzqHoVxhqom0VwlOYyUz3qtuVWUD/2tM7nbkUjKjGIzC8PdbzaQUkOXfJBHN U4aqNt7/J5vS0TJhrv0Ab/vl7xOFw88PonK+BCWRofNjYQSyTePyPENy1M1wqwUigL+W DVarvv2cvKpc93vDv5EifiZouA7CBLWXQOQAnYtN0jwSOYuwKGfAE/pjcmSj4ZO3o+ez LXMPLvwmj4XPITCCvK2ypUhRsUOLp+Q2HfR/xU1W534Bmb0GZkaCDKNCl8mo6htTCaeo 0diiYQBzR40Zo2aLLzgKK4Ukh8n2kpofrsdU/4I/cD9T0rWJT5CyQyhijtOaL9K4wcUq ckmQ==; 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=1778295146; x=1778899946; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:references:in-reply-to :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=wsKGfuBVer/K042Sdj7URZ9WD1/hTA/HzRTCVp9e5C4=; b=ThRipSTs0x09C5HjK2x9vouTUAmErABxY2W/BngeRlvrjoQ2kvEIvMKY0ZqPt429Ps vlkWzCaLK0eDODhm2zobildiG5Lve6PoQOGOVf5p5GDHt/t0a9Uwx6nFNKIIhtNkfPgt CSyOXOzMJG/LaQuJop8Hh6MGbJ4TTJORZMAYyy+uav4scRD2h3tX2Q9BtiJu5G9Op1pk 2B3d+XrJv6Q9gojX9xSz/EiWT1/Gv+ffQV+nuFl297Yx62YUiW4pcAWH5uCcd9b+xG7X +TzVVBxoGvFZI/clINb2eVlBH057uOf/xyeNp2qCLV/xipdtoXZU0pYO+mF7LTR4C+Fo 0Llg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778295146; x=1778899946; h=cc:to:subject:message-id:date:from:references:in-reply-to :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=wsKGfuBVer/K042Sdj7URZ9WD1/hTA/HzRTCVp9e5C4=; b=tMwMn4nThlbFVc2X3wX3ravZVn0NVrfgqOvnvez4t/Nu0fYgHQDzP11mRFbRfP5sCx L+gz0DENWZd2wz8w3EaCNF/TtbXRucLlx3SK54bFf+ucLVCIHNeUfsQc2rG5XIhVzKuj YPwUn6Gr5Tl8nhkXE0+pTpeQazKev+DrJWNZWwCGwP6IHvHA1gG/gUOPin53p3QmpJeZ bmxMpy+1dyGLlKfUci6gzKt3roGbz0ln9RV4Hq/gpqcfFELmbSATUgOmuXEY0pERYcIx VsGg0qJiKf6c5+3pV1YgZfo/1kUYSNeqeglTA/URZ9Xgi+IIDsOcCOqUS9f25DjU8aUH TTMg== X-Forwarded-Encrypted: i=1; AFNElJ8nxew8GYkS20JYOk367DJ21Ec8WpFdd1/5uJhKozvv1RzOLmh/6rrXGo/wFic8soULIKkwruiErOPEaG6x@lists.postgresql.org X-Gm-Message-State: AOJu0Ywta4M2kJd5MHea3A9m8Ul3Z51KPLMNOGZa8MDcyAcxkCoB4Yk4 fAfsNjKEpMossKiWrwb+9MPb1Jg2ohmmdDhvr4zsHCPknshyEywTBa0Z/TXK0oKWpaFa7BnEejo 9vNXSWATIr9oY4X1jFEfbcQckmZtf4+k= X-Gm-Gg: Acq92OH54DhrNvrQdg8xERJpG0wkUjxr5WeEQ8C/+qffRUkycMjy2WUlNW8bk+wuvGs Gp5W/IhjKERd5AHWNFkN6/eactiJ9b9R1ZbqPKyOEjzALhXdA2ImnMFe/+yCOGmC6BlHMDP2H9Y zRURd+Q1YanmQsfAhOGT1zo3mHlDy5YrpZ8/WOB2v3Xg4JW3OJkY4HXfdt7COfokIfYRnq3wc05 qz+uy04e4G5WVXmHz8T30R5DTFMQ2gdnt6FfUMSmVX7IKOhNShxNmPZio6lLnSB0nph9/6BpZO8 T2Ilbw== X-Received: by 2002:a05:690e:4401:b0:65c:6164:f29a with SMTP id 956f58d0204a3-65c799b5259mr11110850d50.46.1778295145871; Fri, 08 May 2026 19:52:25 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a05:7011:404b:20b0:515:5950:5ff0 with HTTP; Fri, 8 May 2026 19:52:25 -0700 (PDT) In-Reply-To: <4B28CBF6-7470-456A-A635-62FE28067AEE@gmail.com> References: <4B28CBF6-7470-456A-A635-62FE28067AEE@gmail.com> From: "David G. Johnston" Date: Fri, 8 May 2026 19:52:25 -0700 X-Gm-Features: AVHnY4JQIfdRY2zMk4ewbSXrbn2o0mxkryrecbau0XpCStOZSu6J_M38y6BVMT0 Message-ID: Subject: Re: Fix wrong error message from pg_get_tablespace_ddl() To: Chao Li Cc: =?UTF-8?Q?=C3=81lvaro_Herrera?= , Andrew Dunstan , Jim Jones , PostgreSQL Hackers Content-Type: multipart/alternative; boundary="00000000000079beb20651599a8d" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000079beb20651599a8d Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Friday, May 8, 2026, Chao Li wrote: > > > > On May 9, 2026, at 01:20, =C3=81lvaro Herrera wr= ote: > > > > On 2026-May-08, Jim Jones wrote: > > > >> It depends on what we expect from the error message. If its purpose is > >> simply to tell the user "you can't access this object," the current > message > >> is totally fine. If, however, the goal is to show the error's root > cause, it > >> could be a bit misleading. > > > > Hmm, the idea in my mind was that if SELECT from the catalog is > > revoked, but the user does have a grant on the tablespace that lets the= m > > read the DDL, then they should be able to obtain the CREATE statement > > for it even though they cannot read the properties from the catalog > > directly. The current coding does not seem to do that, but instead > > it refuses to produce the DDL. Is this really what we want? > > > > From Andrew=E2=80=99s comment, I think I was too much driven by the root = cause of > the problem. From a user=E2=80=99s perspective, if they are trying to vie= w the DDL > of "ts1", but the command fails with an error against "pg_tablespace", th= at > could be confusing. So, how about keeping the original error message and > adding a hint about how to resolve the error? Otherwise, the user might b= e > misled into granting privileges on "ts1" itself, which would not help > resolve the problem. For example: > > ``` > ERROR: permission denied for tablespace ts1 > HINT: Grant SELECT on catalog pg_tablespace to read tablespace properties= . > ``` > > =C3=81lvaro seems to bring the question to a deeper level, and I feel tha= t > might be worth a dedicated discussion. For example, I am not sure > ACL_CREATE on the tablespace is enough to imply visibility of the > tablespace DDL. My understanding is that CREATE on a tablespace allows th= e > user to create objects within that tablespace, but it does not necessaril= y > mean the user is allowed to inspect the definition of the tablespace itse= lf. > The system is designed and built with the assumption that knowledge of catalog contents are not private (aside from a few security-related cases). I really don=E2=80=99t see the benefit to jumping through hoops making this= feature work in a world where that isn=E2=80=99t true. If you cannot read the cata= log in question your superuser did something outside of our design and us choosing to refuse to produce any DDL requiring the contents of that catalog is reasonable. I=E2=80=99d draw the line that if any part of the DDL we would= produce is restricted the entire production is halted, not that we will provide a best effort result. IOW, parity with pg_dump seems reasonable. Reporting which catalogs are restricted is a good message to send. I=E2=80=99m fine gating the object-based output behind an RLS policies on c= atalogs feature so we can at least let people leave select in place and restrict output to owners/admins of the objects in question. David J. --00000000000079beb20651599a8d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Friday, May 8, 2026, Chao Li <li.evan.chao@gmail.com> wrote:
=

> On May 9, 2026, at 01:20, =C3=81lvaro Herrera <alvherre@kurilemu.de> wrote:
>
> On 2026-May-08, Jim Jones wrote:
>
>> It depends on what we expect from the error message. If its purpos= e is
>> simply to tell the user "you can't access this object,&qu= ot; the current message
>> is totally fine. If, however, the goal is to show the error's = root cause, it
>> could be a bit misleading.
>
> Hmm, the idea in my mind was that if SELECT from the catalog is
> revoked, but the user does have a grant on the tablespace that lets th= em
> read the DDL, then they should be able to obtain the CREATE statement<= br> > for it even though they cannot read the properties from the catalog > directly.=C2=A0 The current coding does not seem to do that, but inste= ad
> it refuses to produce the DDL.=C2=A0 Is this really what we want?
>