Re: [PATCH] pg_permissions

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Joel Jacobson <joel(at)compiler(dot)org>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Joe Conway <mail(at)joeconway(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: [PATCH] pg_permissions
Date: 2021-03-26 12:43:27
Message-ID: 20210326124327.GA26883@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2021-Mar-26, Joel Jacobson wrote:

> On Fri, Mar 26, 2021, at 11:30, Alvaro Herrera wrote:
> > On 2021-Mar-26, Joel Jacobson wrote:
> >
> > > On Thu, Mar 25, 2021, at 17:51, Tom Lane wrote:
> >
> > > > I wonder what performance will be like with lots o' objects.
> > >
> > > I guess pg_get_acl() would need to be implemented using a switch(classid) with 36 cases (one for each class)?
> >
> > No, we have a generalized object query mechanism, see objectaddress.c
>
> That's where I was looking actually and noticed the switch with 36 cases, in the function getObjectDescription().

Ah! well, you don't have to repeat that.

AFAICS the way to do it is like AlterObjectOwner_internal obtains data
-- first do get_catalog_object_by_oid (gives you the HeapTuple that
represents the object), then
heap_getattr( ..., get_object_attnum_acl(), ..), and there you have the
ACL which you can "explode" (or maybe just return as-is).

AFAICS if you do this, it's just one cache lookups per object, or
one indexscan for the cases with no by-OID syscache. It should be much
cheaper than the UNION ALL query. And you use pg_shdepend to guide
this, so you only do it for the objects that you already know are
interesting.

--
Álvaro Herrera Valdivia, Chile
"La conclusión que podemos sacar de esos estudios es que
no podemos sacar ninguna conclusión de ellos" (Tanenbaum)

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tomas Vondra 2021-03-26 12:54:13 Re: PoC/WIP: Extended statistics on expressions
Previous Message Joel Jacobson 2021-03-26 12:33:52 Re: [PATCH] pg_permissions