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

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Joel Jacobson <joel(at)compiler(dot)org>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: pgsql: Add pg_get_acl() to get the ACL for a database object
Date: 2024-07-10 01:25:49
Message-ID: Zo3jHUYX9juFYtON@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

On Mon, Jul 08, 2024 at 11:55:28AM +0200, Joel Jacobson wrote:
> Thanks, nice simplifications.
> I agree the tests you removed are not that interesting.
>
> Looks good to me.

On second review, I have spotted a use-after-free for the case of an
attribute ACL in both v1 and v2, as we would finish by releasing the
syscache entry before returning the ACL datum. For builds with the
flags -DRELCACHE_FORCE_RELEASE -DCATCACHE_FORCE_RELEASE, like the
buildfarm member prion, this would cause lookup failures in the
function when building the result because the datum is borked.

At the end, I have settled down on using SearchSysCacheCopyAttNum().
It requires a heap_freetuple(), which we already don't care much about
in the existing callers of get_catalog_object_by_oid() because these
are short-lived, with bonus points because this routine uses
SearchSysCacheAttNum() that has a check for attisdropped, making the
code of pg_get_acl() even simpler.

The usual trick I use to check a fix with this configuration is to use
two builds because initdb is insanely slow if caches are released: one
with the flags and one without them. I have used the build without
the flags to initialize a cluster with the objects and their ACLs.
Then, the second build is used only to execute all the scenarios of
pg_get_acl(), which are much cheaper to execute.
--
Michael

In response to

Browse pgsql-committers by date

  From Date Subject
Next Message Fujii Masao 2024-07-10 07:00:30 pgsql: doc: Update track_io_timing documentation to mention pg_stat_io.
Previous Message Michael Paquier 2024-07-10 01:14:46 pgsql: Extend pg_get_acl() to handle sub-object IDs

Browse pgsql-hackers by date

  From Date Subject
Next Message Junwang Zhao 2024-07-10 02:45:34 Re: make pg_ctl more friendly
Previous Message Richard Guo 2024-07-10 01:22:54 Re: Wrong results with grouping sets