Commit 7415e083 authored by Alvaro Herrera's avatar Alvaro Herrera

Refactor some bits in aclchk.c in order to reduce code duplication.

parent 164442fe
This diff is collapsed.
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/catalog/pg_shdepend.c,v 1.5 2005/11/22 18:17:08 momjian Exp $
* $PostgreSQL: pgsql/src/backend/catalog/pg_shdepend.c,v 1.6 2005/12/01 02:03:00 alvherre Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -1122,6 +1122,7 @@ shdepDropOwned(List *roleids, DropBehavior behavior)
{
ObjectAddress obj;
GrantObjectType objtype;
InternalGrant istmt;
/* Shouldn't happen */
case SHARED_DEPENDENCY_PIN:
......@@ -1132,22 +1133,22 @@ shdepDropOwned(List *roleids, DropBehavior behavior)
switch (sdepForm->classid)
{
case RelationRelationId:
objtype = ACL_OBJECT_RELATION;
istmt.objtype = ACL_OBJECT_RELATION;
break;
case DatabaseRelationId:
objtype = ACL_OBJECT_DATABASE;
istmt.objtype = ACL_OBJECT_DATABASE;
break;
case ProcedureRelationId:
objtype = ACL_OBJECT_FUNCTION;
istmt.objtype = ACL_OBJECT_FUNCTION;
break;
case LanguageRelationId:
objtype = ACL_OBJECT_LANGUAGE;
istmt.objtype = ACL_OBJECT_LANGUAGE;
break;
case NamespaceRelationId:
objtype = ACL_OBJECT_NAMESPACE;
istmt.objtype = ACL_OBJECT_NAMESPACE;
break;
case TableSpaceRelationId:
objtype = ACL_OBJECT_TABLESPACE;
istmt.objtype = ACL_OBJECT_TABLESPACE;
break;
default:
elog(ERROR, "unexpected object type %d",
......@@ -1156,11 +1157,15 @@ shdepDropOwned(List *roleids, DropBehavior behavior)
objtype = (GrantObjectType) 0;
break;
}
ExecGrantStmt_oids(false, objtype,
list_make1_oid(sdepForm->objid), true,
ACL_NO_RIGHTS, list_make1_oid(roleid),
false, DROP_CASCADE);
istmt.is_grant = false;
istmt.objects = list_make1_oid(sdepForm->objid);
istmt.all_privs = true;
istmt.privileges = ACL_NO_RIGHTS;
istmt.grantees = list_make1_oid(roleid);
istmt.grant_option = false;
istmt.behavior = DROP_CASCADE;
ExecGrantStmt_oids(&istmt);
break;
case SHARED_DEPENDENCY_OWNER:
......
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/utils/acl.h,v 1.90 2005/11/22 18:17:31 momjian Exp $
* $PostgreSQL: pgsql/src/include/utils/acl.h,v 1.91 2005/12/01 02:03:01 alvherre Exp $
*
* NOTES
* An ACL array is simply an array of AclItems, representing the union
......@@ -181,6 +181,26 @@ typedef enum AclObjectKind
MAX_ACL_KIND /* MUST BE LAST */
} AclObjectKind;
/*
* The information about one Grant/Revoke statement, in internal format: object
* and grantees names have been turned into Oids, the privilege list is an
* AclMode bitmask. If 'privileges' is ACL_NO_RIGHTS (the 0 value) and
* all_privs is true, it will be internally turned into the right kind of
* ACL_ALL_RIGHTS_*, depending on the object type (NB - this will modify the
* InternalGrant struct!)
*/
typedef struct
{
bool is_grant;
GrantObjectType objtype;
List *objects;
bool all_privs;
AclMode privileges;
List *grantees;
bool grant_option;
DropBehavior behavior;
} InternalGrant;
/*
* routines used internally
*/
......@@ -221,9 +241,7 @@ extern Datum hash_aclitem(PG_FUNCTION_ARGS);
* prototypes for functions in aclchk.c
*/
extern void ExecuteGrantStmt(GrantStmt *stmt);
extern void ExecGrantStmt_oids(bool is_grant, GrantObjectType objtype,
List *objects, bool all_privs, AclMode privileges,
List *grantees, bool grant_option, DropBehavior behavior);
extern void ExecGrantStmt_oids(InternalGrant *istmt);
extern AclMode pg_class_aclmask(Oid table_oid, Oid roleid,
AclMode mask, AclMaskHow how);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment