Search Postgresql Archives

Re: aclitem binary encoding

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jul 21, 2023 at 4:58 PM Tom Lane <tgl@xxxxxxxxxxxxx> wrote:
Joseph Koshakow <koshy44@xxxxxxxxx> 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());
    }
}

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux