*** ./src/backend/utils/adt/acl.c.orig Sat Nov 29 20:51:57 2003 --- ./src/backend/utils/adt/acl.c Mon Apr 12 15:23:17 2004 *************** *** 874,879 **** --- 874,916 ---- PG_RETURN_ACLITEM_P(aclitem); } + /* give access to internal data within aclitem + */ + Datum + aclitem_grantee(PG_FUNCTION_ARGS) + { + AclItem * a = PG_GETARG_ACLITEM_P(0); + PG_RETURN_INT32(a->ai_grantee); + } + + Datum + aclitem_grantor(PG_FUNCTION_ARGS) + { + AclItem * a = PG_GETARG_ACLITEM_P(0); + PG_RETURN_INT32(a->ai_grantor); + } + + Datum + aclitem_idtype(PG_FUNCTION_ARGS) + { + AclItem * a = PG_GETARG_ACLITEM_P(0); + PG_RETURN_INT32(ACLITEM_GET_IDTYPE(*a)); + } + + Datum + aclitem_privs(PG_FUNCTION_ARGS) + { + AclItem * a = PG_GETARG_ACLITEM_P(0); + PG_RETURN_INT32(ACLITEM_GET_PRIVS(*a)); + } + + Datum + aclitem_goptions(PG_FUNCTION_ARGS) + { + AclItem * a = PG_GETARG_ACLITEM_P(0); + PG_RETURN_INT32(ACLITEM_GET_GOPTIONS(*a)); + } + static AclMode convert_priv_string(text *priv_type_text) { *** ./src/include/catalog/pg_proc.h.orig Mon Apr 5 12:06:43 2004 --- ./src/include/catalog/pg_proc.h Mon Apr 12 16:54:52 2004 *************** *** 3526,3531 **** --- 3526,3543 ---- DATA(insert OID = 1069 ( generate_series PGNSP PGUID 12 f f t t v 2 20 "20 20" _null_ generate_series_int8 - _null_ )); DESCR("non-persistent series generator"); + /* aclitem utils */ + DATA(insert OID = 2510 ( aclitem_grantor PGNSP PGUID 12 f f t f i 1 23 "1033" _null_ aclitem_grantor - _null_ )); + DESCR("extract user id grantor from aclitem"); + DATA(insert OID = 2511 ( aclitem_grantee PGNSP PGUID 12 f f t f i 1 23 "1033" _null_ aclitem_grantee - _null_ )); + DESCR("extract grantee (user or group id) from aclitem"); + DATA(insert OID = 2512 ( aclitem_idtype PGNSP PGUID 12 f f t f i 1 23 "1033" _null_ aclitem_idtype - _null_ )); + DESCR("extract id type of grantee (0 public, 1 user, 2 group) from aclitem"); + DATA(insert OID = 2513 ( aclitem_privs PGNSP PGUID 12 f f t f i 1 23 "1033" _null_ aclitem_privs - _null_ )); + DESCR("extract privileges from aclitem"); + DATA(insert OID = 2514 ( aclitem_goptions PGNSP PGUID 12 f f t f i 1 23 "1033" _null_ aclitem_goptions - _null_ )); + DESCR("extract grant options from aclitem"); + /* * Symbolic values for provolatile column: these indicate whether the result *** ./src/test/regress/expected/privileges.out.orig Mon Sep 15 02:26:31 2003 --- ./src/test/regress/expected/privileges.out Mon Apr 12 16:51:00 2004 *************** *** 581,586 **** --- 581,600 ---- t (1 row) + -- aclitem utils small test + SELECT u1.usename AS u1, u2.usename AS u2, + aclitem_idtype(c.relacl[0]) AS idtype, + aclitem_privs(c.relacl[0]) AS privs, + aclitem_goptions(c.relacl[0]) AS goptions + FROM pg_class AS c, pg_user AS u1, pg_user AS u2 + WHERE u1.usesysid = aclitem_grantor(c.relacl[0]) + AND u2.usesysid = aclitem_grantee(c.relacl[0]) + AND c.relname LIKE 'atest4'; + u1 | u2 | idtype | privs | goptions + --------------+--------------+--------+-------+---------- + regressuser1 | regressuser1 | 1 | 127 | 127 + (1 row) + -- clean up \c regression DROP FUNCTION testfunc2(int); *** ./src/test/regress/sql/privileges.sql.orig Wed May 14 05:26:03 2003 --- ./src/test/regress/sql/privileges.sql Mon Apr 12 16:49:48 2004 *************** *** 316,321 **** --- 316,330 ---- SELECT has_table_privilege('regressuser1', 'atest4', 'SELECT WITH GRANT OPTION'); -- true + -- aclitem utils small test + SELECT u1.usename AS u1, u2.usename AS u2, + aclitem_idtype(c.relacl[0]) AS idtype, + aclitem_privs(c.relacl[0]) AS privs, + aclitem_goptions(c.relacl[0]) AS goptions + FROM pg_class AS c, pg_user AS u1, pg_user AS u2 + WHERE u1.usesysid = aclitem_grantor(c.relacl[0]) + AND u2.usesysid = aclitem_grantee(c.relacl[0]) + AND c.relname LIKE 'atest4'; -- clean up