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

Поиск
Список
Период
Сортировка
От Ranier Vilela
Тема Re: Add pg_get_acl() function get the ACL for a database object
Дата
Msg-id CAEudQAoZSHYJZAfzQK53666+RvXLTCtg3Fk0ww1WGv+vXah+yw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Add pg_get_acl() function get the ACL for a database object  (Ranier Vilela <ranier.vf@gmail.com>)
Ответы Re: Add pg_get_acl() function get the ACL for a database object
Список pgsql-hackers
Em qua., 19 de jun. de 2024 às 10:28, Ranier Vilela <ranier.vf@gmail.com> escreveu:
Em qua., 19 de jun. de 2024 às 10:26, Joel Jacobson <joel@compiler.org> 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

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Dave Page
Дата:
Сообщение: Re: Meson far from ready on Windows
Следующее
От: Nathan Bossart
Дата:
Сообщение: Re: Better error message when --single is not the first arg to postgres executable