Re: Add pg_get_acl() function get the ACL for a database object

Michael Paquier <michael@paquier.xyz>

From: Michael Paquier <michael@paquier.xyz>
To: Joel Jacobson <joel@compiler.org>
Cc: Isaac Morland <isaac.morland@gmail.com>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2024-06-21T03:25:06Z
Lists: pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Add pg_get_acl() to get the ACL for a database object

  2. doc: Add ACL acronym for "Access Control List"

On Thu, Jun 20, 2024 at 08:32:57AM +0200, Joel Jacobson wrote:
> I've added overloaded versions for regclass and regproc so far:
> 
> \df pg_get_acl
>                              List of functions
>    Schema   |    Name    | Result data type |  Argument data types   | Type
> ------------+------------+------------------+------------------------+------
>  pg_catalog | pg_get_acl | aclitem[]        | classid oid, objid oid | func
>  pg_catalog | pg_get_acl | aclitem[]        | objid regclass         | func
>  pg_catalog | pg_get_acl | aclitem[]        | objid regproc          | func
> (3 rows)

Interesting idea.

I am not really convinced that the regproc and regclass overloads are
really necessary, considering the fact that one of the goals
mentioned, as far as I understand, is to be able to get an idea of the
ACLs associated to an object with its dependencies in pg_depend and/or 
pg_shdepend.  Another one is to reduce the JOIN burden when querying
a set of them, like attribute ACLs.

Perhaps the documentation should add one or two examples to show this
point?

+        tup = get_catalog_object_by_oid(rel, Anum_oid, objectId);
+        if (!HeapTupleIsValid(tup))
+            elog(ERROR, "cache lookup failed for object %u of catalog \"%s\"",
+                objectId, RelationGetRelationName(rel));

get_catalog_object_by_oid() is handled differently here than in
functions line pg_identify_object().  Shouldn't we return NULL for
this case?  That would be more useful when using this function with
one or more large scans.
--
Michael