pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedaclitem binary encoding
3+ messages / 3 participants
[nested] [flat]
* aclitem binary encoding
@ 2023-07-21 14:30 Joseph Koshakow <koshy44@gmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: Joseph Koshakow @ 2023-07-21 14:30 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
Hi all,
I was using a PostgreSQL driver that used binary input/output to query
some ACL data and was surprised to see the following error:
no binary output function available for type aclitem
In fact, aclitem has no binary input or output functions
postgres=# SELECT typinput, typoutput, typreceive, typsend FROM pg_type
WHERE typname = 'aclitem';
typinput | typoutput | typreceive | typsend
-----------+------------+------------+---------
aclitemin | aclitemout | - | -
(1 row)
Is this an intentional decision to not support a binary encoding for
aclitem types? Or is it just a lack of a feature?
Thanks,
Joe Koshakow
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: aclitem binary encoding
@ 2023-07-21 14:58 Tom Lane <tgl@sss.pgh.pa.us>
parent: Joseph Koshakow <koshy44@gmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: Tom Lane @ 2023-07-21 14:58 UTC (permalink / raw)
To: Joseph Koshakow <koshy44@gmail.com>; +Cc: pgsql-general@lists.postgresql.org
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 think it's at least somewhat intentional, to have a core type
that has no binary I/O so that that case can be tested. In any
event, a binary representation probably wouldn't be terribly
useful, as it'd contain role OIDs that wouldn't reliably transport
from one system to the next, and also privilege bitmasks that
we sometimes redefine.
regards, tom lane
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: aclitem binary encoding
@ 2023-07-24 12:44 Dominique Devienne <ddevienne@gmail.com>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 3+ messages in thread
From: Dominique Devienne @ 2023-07-24 12:44 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Joseph Koshakow <koshy44@gmail.com>; pgsql-general@lists.postgresql.org
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());
}
}
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2023-07-24 12:44 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-07-21 14:30 aclitem binary encoding Joseph Koshakow <koshy44@gmail.com>
2023-07-21 14:58 ` Tom Lane <tgl@sss.pgh.pa.us>
2023-07-24 12:44 ` Dominique Devienne <ddevienne@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox