public inbox for [email protected]  
help / color / mirror / Atom feed
From: Ranier Vilela <[email protected]>
To: Joel Jacobson <[email protected]>
Cc: pgsql-hackers <[email protected]>
Subject: Re: Add pg_get_acl() function get the ACL for a database object
Date: Wed, 19 Jun 2024 10:51:32 -0300
Message-ID: <CAEudQAoZSHYJZAfzQK53666+RvXLTCtg3Fk0ww1WGv+vXah+yw@mail.gmail.com> (raw)
In-Reply-To: <CAEudQApzU=q7ozYn-fKMBQYb44xkvurjKDZqzafM-qC1WCRLJA@mail.gmail.com>
References: <[email protected]>
	<CAEudQArAr+HiBsMA_mC2=S0ruHjn8123z2DHmyAnCN6j7yDvQQ@mail.gmail.com>
	<[email protected]>
	<CAEudQApzU=q7ozYn-fKMBQYb44xkvurjKDZqzafM-qC1WCRLJA@mail.gmail.com>

Em qua., 19 de jun. de 2024 às 10:28, Ranier Vilela <[email protected]>
escreveu:

> Em qua., 19 de jun. de 2024 às 10:26, Joel Jacobson <[email protected]>
> escreveu:
>
>> Hi Ranier,
>>
>> Thanks for looking at this.
>>
>> I've double-checked the patch I sent, and it works fine.
>>
>> I think I know the cause of your problem:
>>
>> Since this is a catalog change, you need to run `make clean`, to ensure
>> the catalog is rebuilt,
>> followed by the usual `make && make install`.
>>
>> You also need to run `initdb` to create a new database cluster, with the
>> new catalog version.
>>
>> Let me know if you need more specific instructions.
>>
> Sorry, sorry but I'm on Windows -> meson.
>
> Double checked with:
> ninja clean
> ninja
> ninja install
>
Sorry for the noise, now pg_get_acl is shown in the regress test.

Regarding the patch, could it be written in the following style?

Datum
pg_get_acl(PG_FUNCTION_ARGS)
{
Oid classId = PG_GETARG_OID(0);
Oid objectId = PG_GETARG_OID(1);
Oid catalogId;
AttrNumber Anum_oid;
AttrNumber Anum_acl;

/* for "pinned" items in pg_depend, return null */
if (!OidIsValid(classId) && !OidIsValid(objectId))
PG_RETURN_NULL();

catalogId = (classId == LargeObjectRelationId) ?
LargeObjectMetadataRelationId : classId;
Anum_oid = get_object_attnum_oid(catalogId);
Anum_acl = get_object_attnum_acl(catalogId);

if (Anum_acl != InvalidAttrNumber)
{
Relation rel;
HeapTuple tup;
Datum datum;
bool isnull;

rel = table_open(catalogId, AccessShareLock);

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));

datum = heap_getattr(tup, Anum_acl, RelationGetDescr(rel), &isnull);

table_close(rel, AccessShareLock);

if (!isnull)
PG_RETURN_DATUM(datum);
}

PG_RETURN_NULL();
}

best regards,
Ranier Vilela


view thread (5+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: Add pg_get_acl() function get the ACL for a database object
  In-Reply-To: <CAEudQAoZSHYJZAfzQK53666+RvXLTCtg3Fk0ww1WGv+vXah+yw@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox