Re: aclitem binary encoding - Mailing list pgsql-general

From Dominique Devienne
Subject Re: aclitem binary encoding
Date
Msg-id CAFCRh-9zGLQJEirA5W8i91Q4dFSi80nb-TosLu8hqCKM=G9cUw@mail.gmail.com
Whole thread Raw
In response to Re: aclitem binary encoding  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
On Fri, Jul 21, 2023 at 4:58 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
Joseph Koshakow <koshy44@gmail.com> writes:
> Is this an intentional decision to not support a binary encoding for
> aclitem types? Or is it just a lack of a feature?

I'm also using binary input/output, and for ACLs, when not using the usual ACL related functions,
I parse them myself, using code inspired from the official sources. Something like below (for DBs in this case).
Assumes you can deal with text arrays in your code of course. I hope that helps. --DD

select ..., coalesce(datacl, acldefault('d', datdba))::text[] as acls,
  from pg_database

// See getid() from https://github.com/postgres/postgres/blob/master/src/backend/utils/adt/acl.c
std::string_view parseAclName(std::string_view sv, std::string& name) { ... }

// See aclparse() from https://github.com/postgres/postgres/blob/master/src/backend/utils/adt/acl.c
// And also https://www.postgresql.org/docs/current/ddl-priv.html
std::string_view parseAclPrivs(std::string_view sv, AclFlags& privs, AclFlags& grantable) { ... }

// Of the form: grantee=privs/grantor
// Where empty grantee means "public"
void parseAclItem(const std::string& s, AclItem& acl) { ... }
    std::string_view sv(s);
...
    sv = parseAclName(sv, acl.grantee_);
...
    sv = parseAclPrivs(sv, acl.privs_, acl.grantable_);
...
    sv = parseAclName(sv, acl.grantor_);
...
}

void parseAcls(const std::vector<std::string>& acls_in, std::vector<AclItem>& acls_out) {
...
    for (const std::string& acl : acls_in) {
        parseAclItem(acl, acls_out.emplace_back());
    }
}

pgsql-general by date:

Previous
From: gzh
Date:
Subject: Re: How to improve the performance of my SQL query?
Next
From: Sabri Taner Burak ALTINDAL
Date:
Subject: Error 503 Backend fetch failed