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 1sPVj3-0050sa-KD for pgsql-hackers@arkaria.postgresql.org; Thu, 04 Jul 2024 23:18:54 +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 1sPVj1-003kWB-7m for pgsql-hackers@arkaria.postgresql.org; Thu, 04 Jul 2024 23:18:51 +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.94.2) (envelope-from ) id 1sPViz-003kW3-Vl for pgsql-hackers@lists.postgresql.org; Thu, 04 Jul 2024 23:18:51 +0000 Received: from fhigh1-smtp.messagingengine.com ([103.168.172.152]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sPVix-000RNw-Il for pgsql-hackers@lists.postgresql.org; Thu, 04 Jul 2024 23:18:49 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 27C4811401C8; Thu, 4 Jul 2024 19:18:46 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Thu, 04 Jul 2024 19:18:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1720135126; x=1720221526; bh=m57lZ7ll71 flpBGUhlNc7LP2xRTM/c+EiC1Mz6MjN1Y=; b=OsHl3WZCF7NOGd8EByM+SWuEbq alupJcXy7yD2j5/6pPrDyn7IiDDMS8PADeEC0XzEo+/3OVCye+baVwFMZ6kOXLRN iuSoyll2kk/6nFrELeQ6QGhREZWZqg/DN2HV+l+Jvn5cksJ6a805JG3uRu+nd6ES AAPcISqRcxs05jUrPyHiOHo9K/8r5NBY3H+logx9kpyE/AndUVIwUB13K7evgDG2 jlTVJPECcnozmmkWBuiPjEnMTqcl+5hMWlnbbgfG+ovxFhOWJuiKjqeG3vwCG2xD dV2it/i+OczvhZgXVchC7JT3SZyYQbAayVJywp5fPp2Hf1+ORFrmM1/IIyNw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1720135126; x=1720221526; bh=m57lZ7ll71flpBGUhlNc7LP2xRTM /c+EiC1Mz6MjN1Y=; b=sVoB8GYLBwBRzfwS01LF0YEpQ7S07xTqUJVWrIFSCcIQ nkrmfXsw9OI3MIKdTJPZfvCPti8N1O1CZQf3MJ/7rIVw8xF5uoEUGqZRuZ5Adih8 gAn38QaMowZXp8i2yhDia3kb6gjacndyZ/+XZ9Vu55VEInuaDI5TavSmH7N8JiU8 S7LUnNILFksmJNYmeZdivLzcadmKCHPQ7q3WkgIBztayMcOEATN0QrikznqqCDnJ IAkpMhCNkIlT2M0mq0C5TtsuikzuM8h1bzMI3horyWDmW+WdTDbld0mRF02KkQYL 9gpcpgRbh6bdpHsamb+HtOMADbgzY4WsNSo1++ZG0Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvddtgddvtdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfg hrlhcuvffnffculdejtddmnecujfgurhepfffhvfevuffkfhggtggujgesghdtreertddt vdenucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgvrhcuoehmihgthhgrvghlsehprg hquhhivghrrdighiiiqeenucggtffrrghtthgvrhhnpeetleeifedufffhhfdtteelgeeg geffhfekueevteeigfduudevudetgfegiedvjeenucevlhhushhtvghrufhiiigvpedtne curfgrrhgrmhepmhgrihhlfhhrohhmpehmihgthhgrvghlsehprghquhhivghrrdighiii X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 4 Jul 2024 19:18:44 -0400 (EDT) Date: Fri, 5 Jul 2024 08:18:33 +0900 From: Michael Paquier To: Joel Jacobson Cc: Tom Lane , Postgres hackers Subject: Re: pgsql: Add pg_get_acl() to get the ACL for a database object Message-ID: References: <3408967.1720107891@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="6UQK2KDtdANUlsli" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --6UQK2KDtdANUlsli Content-Type: text/plain; charset=us-ascii Content-Disposition: inline (Moving to -hackers) On Thu, Jul 04, 2024 at 10:53:49PM +0200, Joel Jacobson wrote: > On Thu, Jul 4, 2024, at 17:44, Tom Lane wrote: >> Uh, why is it defined like that rather than allowing a subobject? >> This definition is unable to fetch column-specific ACLs. Yes, I was wondering about that as well yesterday when looking at the patch, and saw that this was already a pretty good cut as it covers most of the objects types and does 90% of the job, so just moved on. > I wonder if it would be motivated to provide overloads for this function, > and perhaps even for pg_get_object_address and pg_identify_object_as_address? > > That is, two param versions (class OID and object OID), > and three param versions that in addition also take subobject ID. I would still stick to only one function, with arguments coming from scanning pg_[sh]depend. > I found some code in aclchk.c on line 4452-4468 that seems useful, > but not sure. Maybe there is some other existing code that is better > as an inspiration? My first feelings about that was that subobjids are only used for pg_attribute, so if we use them as a base, it would look like: - Adding a new AttrNumber in ObjectProperty to track to which column the subobjid should apply and its catcache number (ATTNUM for the attribute number for fast lookup). - Extend get_catalog_object_by_oid() with more data: the attribute column for the subobjid scan stored in ObjectProperty, the subobjid value given by the caller. If get_catalog_object_by_oid()'s caller defines a subobjid, use get_object_catcache_oid() on it over the main OID one. If it cannot be found in the cache, use a scan key based on the class OID and the subobjid. > I guess we need to handle the RelationRelationId separately, > and handle all other classes using the current code in pg_get_acl()? But most of that simply blows away because we track the dependency to the attribute ACLs in pg_shdepend based on pg_class, not pg_attribute. get_attname() itself relies on ATTNUM, so perhaps that's OK to just add an exception based on RelationRelationId in the code path of pg_get_acl(). That makes me a bit uncomfortable to derive more from the other routines for the object descriptions, but we've been living with that in getObjectDescription() for years now, as well. -- Michael --6UQK2KDtdANUlsli Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmaHLckACgkQnvQgOdby QH29XA//f7QhyjJRfc3VWqZltS9of6pJPpfaihPsAttlkZq570h7SsYdLvNo/PB5 73Bfip1kg3M6Z8yl7/BDRe1huBOgzFWCjT2xCeMVVYy4x5i9myN1Sa82W3qC3yrg 5jEuGX7d46XamerizzRCqEw59vkg42qO7gvlqtD15CJ/89MFzllISIIGUDu0yaiR c0yl0tbiEfk4XTCB3isfE5wBGeoIHduN7Bqdh1LJU4fNDF3jA89yvCmxQCcnYKL8 4c9+N+bSrQwo1XYqmLP5sUOOl8oSWsFNTu14JUCAKNV6wf2SB2V+AbCOkQwxQrUc nC5TzHZvsw4uMQ91pLcPA+rgG456LfA40PX6Qcva7BR8+MPjwc/AuK8wNojaKHVz FQTCm17ikPzkQN82QlyubXSjI+Ed8JBqYapm4l0qi3lItidQ5GVwnvNRFfCSVGu4 V/jFm5XtUpMDbiTBFAh2LZFE7Vn9lWZ4TdgyT75wg3UOKhgNwnvrxbu81svv+R2w 6n365BKSQiDGhDaAzApBSB5y5RlBBNQomHELg+ptizHgKgSBhJs0+zZCV3OpFr8h MFfiGLhKVwmg414VZmTgshF+OITpVVxS5on9yK6JVnvp3NmnvuzMH2krMKdgDKHH vaHMkxeMpFX8fYII1hY8mJX5UWFV7Z2siLbokC3iXhvyz53Rt/8= =cuSK -----END PGP SIGNATURE----- --6UQK2KDtdANUlsli--