Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1prjVt-0005ls-HN for pgsql-admin@arkaria.postgresql.org; Wed, 26 Apr 2023 18:05:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1prjVs-00074i-DX for pgsql-admin@arkaria.postgresql.org; Wed, 26 Apr 2023 18:05:08 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1prjVs-00074Y-1y for pgsql-admin@lists.postgresql.org; Wed, 26 Apr 2023 18:05:08 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1prjVo-005DWs-Sl for pgsql-admin@lists.postgresql.org; Wed, 26 Apr 2023 18:05:07 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 33QI51fx880087; Wed, 26 Apr 2023 14:05:01 -0400 From: Tom Lane To: richard coleman cc: pgsql-admin@lists.postgresql.org Subject: Re: how to list privileges on the database object itself via SQL? In-reply-to: References: <870558.1682527243@sss.pgh.pa.us> <875041.1682529779@sss.pgh.pa.us> Comments: In-reply-to richard coleman message dated "Wed, 26 Apr 2023 13:50:18 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <880085.1682532301.1@sss.pgh.pa.us> Date: Wed, 26 Apr 2023 14:05:01 -0400 Message-ID: <880086.1682532301@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk richard coleman writes: > Thanks for that. It still seems rather weird that there isn't a more > straightforward way to get access to that information. You could just read the system catalog documentation: https://www.postgresql.org/docs/current/catalogs.html psql's queries are mostly useful as a shortcut to finding out where to look. > Also the SQL generated by psql -E doesn't seem to work on earlier versions > of PostgreSQL: Yeah, you'd need to try it against a server of the vintage you care about. (Also read the documentation of the correct version.) > Are you saying that the only place this information is stored > is in an array in the datacl column of the pg_catalog.pg_database table? Precisely. > If that's the case then I am going to be forced to either write code to > parse out that array, or write a looping union of multiple > "has_database_privilege()" calls. You were already pointed at aclexplode(), which might help. select datname, a.* from pg_database, aclexplode(datacl) a; regards, tom lane