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 1t2Sx5-0049LW-6a for pgsql-hackers@arkaria.postgresql.org; Sun, 20 Oct 2024 10:14:23 +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 1t2Sx3-00EB77-9N for pgsql-hackers@arkaria.postgresql.org; Sun, 20 Oct 2024 10:14:21 +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 1t2Sx2-00EB6z-TY for pgsql-hackers@lists.postgresql.org; Sun, 20 Oct 2024 10:14:21 +0000 Received: from fhigh-a7-smtp.messagingengine.com ([103.168.172.158]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t2Sww-0022jE-F2 for pgsql-hackers@lists.postgresql.org; Sun, 20 Oct 2024 10:14:20 +0000 Received: from phl-compute-11.internal (phl-compute-11.phl.internal [10.202.2.51]) by mailfhigh.phl.internal (Postfix) with ESMTP id B04FA114011F; Sun, 20 Oct 2024 06:14:12 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-11.internal (MEProxy); Sun, 20 Oct 2024 06:14:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1729419252; x= 1729505652; bh=DyLf52Ym05YIWcLqkcbbGfQtj2zgWfBQB8JmoJFXqqY=; b=R s2At/+i1Korcuel6Dv9sfMw23ZEd0IvLRra/sns8H0aYopuQPiTNuv5XaIyrn4l9 86Adq+4olfvI8I80vmhAv37bX3BW/g+a3lg2lfhc00Zbp1TMyDwiKCFu+sQuga4K xOvZ4YZpaGSqbGT2JcPMu1all2TD7yOtlp8WILJholiGKoeXL/G7VMOMDq3y7+lM d/arXkNyLi+jI3QZDZMS32CLZJOoGVBUTpPEawBPezdJLT3vBvJ0ZdiX5Ywj/Z1s b9GXxBjv+o9WwLijRe0SDe6Z4tYvxAsW6AOQLgtwxTnKMI9zE1A2/+65ah6ZrKyI iiTHjOxfkG4gexc+V61iA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvdehjedgvdehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhepfffhvfevuffkgggtugfgjgesthekredttddtjeen ucfhrhhomheptehlvhgrrhhoucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhh drnhhoqdhiphdrohhrgheqnecuggftrfgrthhtvghrnhepgfdtgeelgefgffdtieduudff hfevkefgudefteehgfethfekvdegjeelhfethedvnecuffhomhgrihhnpegvnhhtvghrph hrihhsvggusgdrtghomhdpphhoshhtghhrvghsqhhlrdhorhhgnecuvehluhhsthgvrhfu ihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghlvhhhvghrrhgvsegrlhhvhh drnhhoqdhiphdrohhrghdpnhgspghrtghpthhtohepvddpmhhouggvpehsmhhtphhouhht pdhrtghpthhtohepjhhovghlsegtohhmphhilhgvrhdrohhrghdprhgtphhtthhopehpgh hsqhhlqdhhrggtkhgvrhhssehlihhsthhsrdhpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 20 Oct 2024 06:14:12 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alvh.no-ip.org; s=schmee; t=1729419251; bh=fTZ40F+47h4/0a+1XG30+pS/CHqh9mIAALxtVXeSXMU=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=WkXfUgMSeOY/93HKHJr4cJH1yCPJUWxPN8fwviDzRVIjN12P+a0l5Jqp9mgh1cbLx do8OgLakOdcspW/AGfyLylxd/fLo0PizE6TJMHjqCp56e7YJLOhpEwbLqw7QaibnBg Xj0zNJ9hpcLH2rsGPIGnVuWDCKb8W5PpzjM31BXAjd1dYUXaJ6Ee0A13mGuRVWZUU6 txnNyahcIGUkZEnEDu/kI6Wv8LeAVBSz43M8kF7BLB5UaTibc+AL4FbKRFj7QpIhq3 A0VQZ36ZQjOwT3TGG2M8yh9k4ewLczdSf1ym/IVFeKsNnuigtK7HSyNyF6d7ukDMk9 E4g8SNvSCIXeQ== Received: by schmee.alvh.no-ip.org (Postfix, from userid 1000) id 00AEAE3; Sun, 20 Oct 2024 12:14:10 +0200 (CEST) Date: Sun, 20 Oct 2024 12:14:10 +0200 From: Alvaro Herrera To: Joel Jacobson Cc: pgsql-hackers@lists.postgresql.org Subject: Re: Add pg_ownerships and pg_privileges system views Message-ID: <202410201014.dcvfvqdncdds@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hello, On 2024-Oct-20, Joel Jacobson wrote: > Here is an attempt to revive this patch from 2021-2022, that has been ready now > for a while, thanks to pg_get_acl() function that was committed in > 4564f1c and d898665. Nice. I think the function calls should be in the FROM clause, and restrict the pg_shdepend rows to only the ones in the current database: CREATE VIEW pg_privileges AS SELECT a.classid::regclass, a.objid, a.objsubid, a.type, a.schema, a.name, a.identity, a.grantor::regrole, a.grantee::regrole, a.privilege_type, a.is_grantable FROM ( SELECT pg_shdepend.classid, pg_shdepend.objid, pg_shdepend.objsubid, identify.*, aclexplode.* FROM pg_catalog.pg_shdepend JOIN pg_catalog.pg_database ON pg_database.datname = current_database() AND pg_database.oid = pg_shdepend.dbid JOIN pg_catalog.pg_authid ON pg_authid.oid = pg_shdepend.refobjid AND pg_shdepend.refclassid = 'pg_authid'::regclass, LATERAL pg_catalog.pg_identify_object(pg_shdepend.classid,pg_shdepend.objid,pg_shdepend.objsubid) AS identify, LATERAL pg_catalog.aclexplode(pg_catalog.pg_get_acl(pg_shdepend.classid,pg_shdepend.objid,pg_shdepend.objsubid)) AS aclexplode WHERE pg_shdepend.deptype = 'a' AND pg_shdepend.dbid = (( SELECT pg_database_1.oid FROM pg_database pg_database_1 WHERE pg_database_1.datname = current_database())) ) AS a ; Now, depending on pg_shdepend for this means that you don't report anything for an object until a GRANT to another user has been executed. For example if you REVOKE some priv from the object owner, nothing is shown until a GRANT is done for another user (and at that point onwards, privs by the owner are shown). This seems less than ideal, but I'm not sure how to do different, other than ditching the use of pg_shdepend entirely. -- Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/ "Once again, thank you and all of the developers for your hard work on PostgreSQL. This is by far the most pleasant management experience of any database I've worked on." (Dan Harris) http://archives.postgresql.org/pgsql-performance/2006-04/msg00247.php