Commit 2c6f37ed authored by Peter Eisentraut's avatar Peter Eisentraut

Replace GrantObjectType with ObjectType

There used to be a lot of different *Type and *Kind symbol groups to
address objects within different commands, most of which have been
replaced by ObjectType, starting with
b256f242.  But this conversion was never
done for the ACL commands until now.

This change ends up being just a plain replacement of the types and
symbols, without any code restructuring needed, except deleting some now
redundant code.
Reviewed-by: default avatarMichael Paquier <michael.paquier@gmail.com>
Reviewed-by: default avatarStephen Frost <sfrost@snowman.net>
parent 42b58560
This diff is collapsed.
......@@ -1143,11 +1143,11 @@ heap_create_with_catalog(const char *relname,
case RELKIND_MATVIEW:
case RELKIND_FOREIGN_TABLE:
case RELKIND_PARTITIONED_TABLE:
relacl = get_user_default_acl(ACL_OBJECT_RELATION, ownerid,
relacl = get_user_default_acl(OBJECT_TABLE, ownerid,
relnamespace);
break;
case RELKIND_SEQUENCE:
relacl = get_user_default_acl(ACL_OBJECT_SEQUENCE, ownerid,
relacl = get_user_default_acl(OBJECT_SEQUENCE, ownerid,
relnamespace);
break;
default:
......
......@@ -63,7 +63,7 @@ NamespaceCreate(const char *nspName, Oid ownerId, bool isTemp)
errmsg("schema \"%s\" already exists", nspName)));
if (!isTemp)
nspacl = get_user_default_acl(ACL_OBJECT_NAMESPACE, ownerId,
nspacl = get_user_default_acl(OBJECT_SCHEMA, ownerId,
InvalidOid);
else
nspacl = NULL;
......
......@@ -582,7 +582,7 @@ ProcedureCreate(const char *procedureName,
/* Creating a new procedure */
/* First, get default permissions and set up proacl */
proacl = get_user_default_acl(ACL_OBJECT_FUNCTION, proowner,
proacl = get_user_default_acl(OBJECT_FUNCTION, proowner,
procNamespace);
if (proacl != NULL)
values[Anum_pg_proc_proacl - 1] = PointerGetDatum(proacl);
......
......@@ -380,7 +380,7 @@ TypeCreate(Oid newTypeOid,
else
nulls[Anum_pg_type_typdefault - 1] = true;
typacl = get_user_default_acl(ACL_OBJECT_TYPE, ownerId,
typacl = get_user_default_acl(OBJECT_TYPE, ownerId,
typeNamespace);
if (typacl != NULL)
values[Anum_pg_type_typacl - 1] = PointerGetDatum(typacl);
......
......@@ -159,8 +159,8 @@ static Oid insert_event_trigger_tuple(const char *trigname, const char *eventnam
static void validate_ddl_tags(const char *filtervar, List *taglist);
static void validate_table_rewrite_tags(const char *filtervar, List *taglist);
static void EventTriggerInvoke(List *fn_oid_list, EventTriggerData *trigdata);
static const char *stringify_grantobjtype(GrantObjectType objtype);
static const char *stringify_adefprivs_objtype(GrantObjectType objtype);
static const char *stringify_grant_objtype(ObjectType objtype);
static const char *stringify_adefprivs_objtype(ObjectType objtype);
/*
* Create an event trigger.
......@@ -1199,41 +1199,6 @@ EventTriggerSupportsObjectClass(ObjectClass objclass)
return false;
}
bool
EventTriggerSupportsGrantObjectType(GrantObjectType objtype)
{
switch (objtype)
{
case ACL_OBJECT_DATABASE:
case ACL_OBJECT_TABLESPACE:
/* no support for global objects */
return false;
case ACL_OBJECT_COLUMN:
case ACL_OBJECT_RELATION:
case ACL_OBJECT_SEQUENCE:
case ACL_OBJECT_DOMAIN:
case ACL_OBJECT_FDW:
case ACL_OBJECT_FOREIGN_SERVER:
case ACL_OBJECT_FUNCTION:
case ACL_OBJECT_LANGUAGE:
case ACL_OBJECT_LARGEOBJECT:
case ACL_OBJECT_NAMESPACE:
case ACL_OBJECT_PROCEDURE:
case ACL_OBJECT_ROUTINE:
case ACL_OBJECT_TYPE:
return true;
/*
* There's intentionally no default: case here; we want the
* compiler to warn if a new ACL class hasn't been handled above.
*/
}
/* Shouldn't get here, but if we do, say "no support" */
return false;
}
/*
* Prepare event trigger state for a new complete query to run, if necessary;
* returns whether this was done. If it was, EventTriggerEndCompleteQuery must
......@@ -2196,7 +2161,7 @@ pg_event_trigger_ddl_commands(PG_FUNCTION_ARGS)
values[i++] = CStringGetTextDatum(cmd->d.grant.istmt->is_grant ?
"GRANT" : "REVOKE");
/* object_type */
values[i++] = CStringGetTextDatum(stringify_grantobjtype(
values[i++] = CStringGetTextDatum(stringify_grant_objtype(
cmd->d.grant.istmt->objtype));
/* schema */
nulls[i++] = true;
......@@ -2219,92 +2184,164 @@ pg_event_trigger_ddl_commands(PG_FUNCTION_ARGS)
}
/*
* Return the GrantObjectType as a string, as it would appear in GRANT and
* Return the ObjectType as a string, as it would appear in GRANT and
* REVOKE commands.
*/
static const char *
stringify_grantobjtype(GrantObjectType objtype)
stringify_grant_objtype(ObjectType objtype)
{
switch (objtype)
{
case ACL_OBJECT_COLUMN:
case OBJECT_COLUMN:
return "COLUMN";
case ACL_OBJECT_RELATION:
case OBJECT_TABLE:
return "TABLE";
case ACL_OBJECT_SEQUENCE:
case OBJECT_SEQUENCE:
return "SEQUENCE";
case ACL_OBJECT_DATABASE:
case OBJECT_DATABASE:
return "DATABASE";
case ACL_OBJECT_DOMAIN:
case OBJECT_DOMAIN:
return "DOMAIN";
case ACL_OBJECT_FDW:
case OBJECT_FDW:
return "FOREIGN DATA WRAPPER";
case ACL_OBJECT_FOREIGN_SERVER:
case OBJECT_FOREIGN_SERVER:
return "FOREIGN SERVER";
case ACL_OBJECT_FUNCTION:
case OBJECT_FUNCTION:
return "FUNCTION";
case ACL_OBJECT_LANGUAGE:
case OBJECT_LANGUAGE:
return "LANGUAGE";
case ACL_OBJECT_LARGEOBJECT:
case OBJECT_LARGEOBJECT:
return "LARGE OBJECT";
case ACL_OBJECT_NAMESPACE:
case OBJECT_SCHEMA:
return "SCHEMA";
case ACL_OBJECT_PROCEDURE:
case OBJECT_PROCEDURE:
return "PROCEDURE";
case ACL_OBJECT_ROUTINE:
case OBJECT_ROUTINE:
return "ROUTINE";
case ACL_OBJECT_TABLESPACE:
case OBJECT_TABLESPACE:
return "TABLESPACE";
case ACL_OBJECT_TYPE:
case OBJECT_TYPE:
return "TYPE";
/* these currently aren't used */
case OBJECT_ACCESS_METHOD:
case OBJECT_AGGREGATE:
case OBJECT_AMOP:
case OBJECT_AMPROC:
case OBJECT_ATTRIBUTE:
case OBJECT_CAST:
case OBJECT_COLLATION:
case OBJECT_CONVERSION:
case OBJECT_DEFAULT:
case OBJECT_DEFACL:
case OBJECT_DOMCONSTRAINT:
case OBJECT_EVENT_TRIGGER:
case OBJECT_EXTENSION:
case OBJECT_FOREIGN_TABLE:
case OBJECT_INDEX:
case OBJECT_MATVIEW:
case OBJECT_OPCLASS:
case OBJECT_OPERATOR:
case OBJECT_OPFAMILY:
case OBJECT_POLICY:
case OBJECT_PUBLICATION:
case OBJECT_PUBLICATION_REL:
case OBJECT_ROLE:
case OBJECT_RULE:
case OBJECT_STATISTIC_EXT:
case OBJECT_SUBSCRIPTION:
case OBJECT_TABCONSTRAINT:
case OBJECT_TRANSFORM:
case OBJECT_TRIGGER:
case OBJECT_TSCONFIGURATION:
case OBJECT_TSDICTIONARY:
case OBJECT_TSPARSER:
case OBJECT_TSTEMPLATE:
case OBJECT_USER_MAPPING:
case OBJECT_VIEW:
elog(ERROR, "unsupported object type: %d", (int) objtype);
}
elog(ERROR, "unrecognized grant object type: %d", (int) objtype);
return "???"; /* keep compiler quiet */
}
/*
* Return the GrantObjectType as a string; as above, but use the spelling
* Return the ObjectType as a string; as above, but use the spelling
* in ALTER DEFAULT PRIVILEGES commands instead. Generally this is just
* the plural.
*/
static const char *
stringify_adefprivs_objtype(GrantObjectType objtype)
stringify_adefprivs_objtype(ObjectType objtype)
{
switch (objtype)
{
case ACL_OBJECT_COLUMN:
case OBJECT_COLUMN:
return "COLUMNS";
case ACL_OBJECT_RELATION:
case OBJECT_TABLE:
return "TABLES";
case ACL_OBJECT_SEQUENCE:
case OBJECT_SEQUENCE:
return "SEQUENCES";
case ACL_OBJECT_DATABASE:
case OBJECT_DATABASE:
return "DATABASES";
case ACL_OBJECT_DOMAIN:
case OBJECT_DOMAIN:
return "DOMAINS";
case ACL_OBJECT_FDW:
case OBJECT_FDW:
return "FOREIGN DATA WRAPPERS";
case ACL_OBJECT_FOREIGN_SERVER:
case OBJECT_FOREIGN_SERVER:
return "FOREIGN SERVERS";
case ACL_OBJECT_FUNCTION:
case OBJECT_FUNCTION:
return "FUNCTIONS";
case ACL_OBJECT_LANGUAGE:
case OBJECT_LANGUAGE:
return "LANGUAGES";
case ACL_OBJECT_LARGEOBJECT:
case OBJECT_LARGEOBJECT:
return "LARGE OBJECTS";
case ACL_OBJECT_NAMESPACE:
case OBJECT_SCHEMA:
return "SCHEMAS";
case ACL_OBJECT_PROCEDURE:
case OBJECT_PROCEDURE:
return "PROCEDURES";
case ACL_OBJECT_ROUTINE:
case OBJECT_ROUTINE:
return "ROUTINES";
case ACL_OBJECT_TABLESPACE:
case OBJECT_TABLESPACE:
return "TABLESPACES";
case ACL_OBJECT_TYPE:
case OBJECT_TYPE:
return "TYPES";
/* these currently aren't used */
case OBJECT_ACCESS_METHOD:
case OBJECT_AGGREGATE:
case OBJECT_AMOP:
case OBJECT_AMPROC:
case OBJECT_ATTRIBUTE:
case OBJECT_CAST:
case OBJECT_COLLATION:
case OBJECT_CONVERSION:
case OBJECT_DEFAULT:
case OBJECT_DEFACL:
case OBJECT_DOMCONSTRAINT:
case OBJECT_EVENT_TRIGGER:
case OBJECT_EXTENSION:
case OBJECT_FOREIGN_TABLE:
case OBJECT_INDEX:
case OBJECT_MATVIEW:
case OBJECT_OPCLASS:
case OBJECT_OPERATOR:
case OBJECT_OPFAMILY:
case OBJECT_POLICY:
case OBJECT_PUBLICATION:
case OBJECT_PUBLICATION_REL:
case OBJECT_ROLE:
case OBJECT_RULE:
case OBJECT_STATISTIC_EXT:
case OBJECT_SUBSCRIPTION:
case OBJECT_TABCONSTRAINT:
case OBJECT_TRANSFORM:
case OBJECT_TRIGGER:
case OBJECT_TSCONFIGURATION:
case OBJECT_TSDICTIONARY:
case OBJECT_TSPARSER:
case OBJECT_TSTEMPLATE:
case OBJECT_USER_MAPPING:
case OBJECT_VIEW:
elog(ERROR, "unsupported object type: %d", (int) objtype);
}
elog(ERROR, "unrecognized grant object type: %d", (int) objtype);
return "???"; /* keep compiler quiet */
}
......@@ -115,7 +115,7 @@
typedef struct PrivTarget
{
GrantTargetType targtype;
GrantObjectType objtype;
ObjectType objtype;
List *objs;
} PrivTarget;
......@@ -7027,7 +7027,7 @@ privilege_target:
{
PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget));
n->targtype = ACL_TARGET_OBJECT;
n->objtype = ACL_OBJECT_RELATION;
n->objtype = OBJECT_TABLE;
n->objs = $1;
$$ = n;
}
......@@ -7035,7 +7035,7 @@ privilege_target:
{
PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget));
n->targtype = ACL_TARGET_OBJECT;
n->objtype = ACL_OBJECT_RELATION;
n->objtype = OBJECT_TABLE;
n->objs = $2;
$$ = n;
}
......@@ -7043,7 +7043,7 @@ privilege_target:
{
PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget));
n->targtype = ACL_TARGET_OBJECT;
n->objtype = ACL_OBJECT_SEQUENCE;
n->objtype = OBJECT_SEQUENCE;
n->objs = $2;
$$ = n;
}
......@@ -7051,7 +7051,7 @@ privilege_target:
{
PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget));
n->targtype = ACL_TARGET_OBJECT;
n->objtype = ACL_OBJECT_FDW;
n->objtype = OBJECT_FDW;
n->objs = $4;
$$ = n;
}
......@@ -7059,7 +7059,7 @@ privilege_target:
{
PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget));
n->targtype = ACL_TARGET_OBJECT;
n->objtype = ACL_OBJECT_FOREIGN_SERVER;
n->objtype = OBJECT_FOREIGN_SERVER;
n->objs = $3;
$$ = n;
}
......@@ -7067,7 +7067,7 @@ privilege_target:
{
PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget));
n->targtype = ACL_TARGET_OBJECT;
n->objtype = ACL_OBJECT_FUNCTION;
n->objtype = OBJECT_FUNCTION;
n->objs = $2;
$$ = n;
}
......@@ -7075,7 +7075,7 @@ privilege_target:
{
PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget));
n->targtype = ACL_TARGET_OBJECT;
n->objtype = ACL_OBJECT_PROCEDURE;
n->objtype = OBJECT_PROCEDURE;
n->objs = $2;
$$ = n;
}
......@@ -7083,7 +7083,7 @@ privilege_target:
{
PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget));
n->targtype = ACL_TARGET_OBJECT;
n->objtype = ACL_OBJECT_ROUTINE;
n->objtype = OBJECT_ROUTINE;
n->objs = $2;
$$ = n;
}
......@@ -7091,7 +7091,7 @@ privilege_target:
{
PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget));
n->targtype = ACL_TARGET_OBJECT;
n->objtype = ACL_OBJECT_DATABASE;
n->objtype = OBJECT_DATABASE;
n->objs = $2;
$$ = n;
}
......@@ -7099,7 +7099,7 @@ privilege_target:
{
PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget));
n->targtype = ACL_TARGET_OBJECT;
n->objtype = ACL_OBJECT_DOMAIN;
n->objtype = OBJECT_DOMAIN;
n->objs = $2;
$$ = n;
}
......@@ -7107,7 +7107,7 @@ privilege_target:
{
PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget));
n->targtype = ACL_TARGET_OBJECT;
n->objtype = ACL_OBJECT_LANGUAGE;
n->objtype = OBJECT_LANGUAGE;
n->objs = $2;
$$ = n;
}
......@@ -7115,7 +7115,7 @@ privilege_target:
{
PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget));
n->targtype = ACL_TARGET_OBJECT;
n->objtype = ACL_OBJECT_LARGEOBJECT;
n->objtype = OBJECT_LARGEOBJECT;
n->objs = $3;
$$ = n;
}
......@@ -7123,7 +7123,7 @@ privilege_target:
{
PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget));
n->targtype = ACL_TARGET_OBJECT;
n->objtype = ACL_OBJECT_NAMESPACE;
n->objtype = OBJECT_SCHEMA;
n->objs = $2;
$$ = n;
}
......@@ -7131,7 +7131,7 @@ privilege_target:
{
PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget));
n->targtype = ACL_TARGET_OBJECT;
n->objtype = ACL_OBJECT_TABLESPACE;
n->objtype = OBJECT_TABLESPACE;
n->objs = $2;
$$ = n;
}
......@@ -7139,7 +7139,7 @@ privilege_target:
{
PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget));
n->targtype = ACL_TARGET_OBJECT;
n->objtype = ACL_OBJECT_TYPE;
n->objtype = OBJECT_TYPE;
n->objs = $2;
$$ = n;
}
......@@ -7147,7 +7147,7 @@ privilege_target:
{
PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget));
n->targtype = ACL_TARGET_ALL_IN_SCHEMA;
n->objtype = ACL_OBJECT_RELATION;
n->objtype = OBJECT_TABLE;
n->objs = $5;
$$ = n;
}
......@@ -7155,7 +7155,7 @@ privilege_target:
{
PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget));
n->targtype = ACL_TARGET_ALL_IN_SCHEMA;
n->objtype = ACL_OBJECT_SEQUENCE;
n->objtype = OBJECT_SEQUENCE;
n->objs = $5;
$$ = n;
}
......@@ -7163,7 +7163,7 @@ privilege_target:
{
PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget));
n->targtype = ACL_TARGET_ALL_IN_SCHEMA;
n->objtype = ACL_OBJECT_FUNCTION;
n->objtype = OBJECT_FUNCTION;
n->objs = $5;
$$ = n;
}
......@@ -7171,7 +7171,7 @@ privilege_target:
{
PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget));
n->targtype = ACL_TARGET_ALL_IN_SCHEMA;
n->objtype = ACL_OBJECT_PROCEDURE;
n->objtype = OBJECT_PROCEDURE;
n->objs = $5;
$$ = n;
}
......@@ -7179,7 +7179,7 @@ privilege_target:
{
PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget));
n->targtype = ACL_TARGET_ALL_IN_SCHEMA;
n->objtype = ACL_OBJECT_ROUTINE;
n->objtype = OBJECT_ROUTINE;
n->objs = $5;
$$ = n;
}
......@@ -7337,12 +7337,12 @@ DefACLAction:
;
defacl_privilege_target:
TABLES { $$ = ACL_OBJECT_RELATION; }
| FUNCTIONS { $$ = ACL_OBJECT_FUNCTION; }
| ROUTINES { $$ = ACL_OBJECT_FUNCTION; }
| SEQUENCES { $$ = ACL_OBJECT_SEQUENCE; }
| TYPES_P { $$ = ACL_OBJECT_TYPE; }
| SCHEMAS { $$ = ACL_OBJECT_NAMESPACE; }
TABLES { $$ = OBJECT_TABLE; }
| FUNCTIONS { $$ = OBJECT_FUNCTION; }
| ROUTINES { $$ = OBJECT_FUNCTION; }
| SEQUENCES { $$ = OBJECT_SEQUENCE; }
| TYPES_P { $$ = OBJECT_TYPE; }
| SCHEMAS { $$ = OBJECT_SCHEMA; }
;
......
......@@ -828,7 +828,7 @@ standard_ProcessUtility(PlannedStmt *pstmt,
{
GrantStmt *stmt = (GrantStmt *) parsetree;
if (EventTriggerSupportsGrantObjectType(stmt->objtype))
if (EventTriggerSupportsObjectType(stmt->objtype))
ProcessUtilitySlow(pstate, pstmt, queryString,
context, params, queryEnv,
dest, completionTag);
......
......@@ -745,7 +745,7 @@ hash_aclitem_extended(PG_FUNCTION_ARGS)
* absence of any pg_default_acl entry.
*/
Acl *
acldefault(GrantObjectType objtype, Oid ownerId)
acldefault(ObjectType objtype, Oid ownerId)
{
AclMode world_default;
AclMode owner_default;
......@@ -755,56 +755,56 @@ acldefault(GrantObjectType objtype, Oid ownerId)
switch (objtype)
{
case ACL_OBJECT_COLUMN:
case OBJECT_COLUMN:
/* by default, columns have no extra privileges */
world_default = ACL_NO_RIGHTS;
owner_default = ACL_NO_RIGHTS;
break;
case ACL_OBJECT_RELATION:
case OBJECT_TABLE:
world_default = ACL_NO_RIGHTS;
owner_default = ACL_ALL_RIGHTS_RELATION;
break;
case ACL_OBJECT_SEQUENCE:
case OBJECT_SEQUENCE:
world_default = ACL_NO_RIGHTS;
owner_default = ACL_ALL_RIGHTS_SEQUENCE;
break;
case ACL_OBJECT_DATABASE:
case OBJECT_DATABASE:
/* for backwards compatibility, grant some rights by default */
world_default = ACL_CREATE_TEMP | ACL_CONNECT;
owner_default = ACL_ALL_RIGHTS_DATABASE;
break;
case ACL_OBJECT_FUNCTION:
case OBJECT_FUNCTION:
/* Grant EXECUTE by default, for now */
world_default = ACL_EXECUTE;
owner_default = ACL_ALL_RIGHTS_FUNCTION;
break;
case ACL_OBJECT_LANGUAGE:
case OBJECT_LANGUAGE:
/* Grant USAGE by default, for now */
world_default = ACL_USAGE;
owner_default = ACL_ALL_RIGHTS_LANGUAGE;
break;
case ACL_OBJECT_LARGEOBJECT:
case OBJECT_LARGEOBJECT:
world_default = ACL_NO_RIGHTS;
owner_default = ACL_ALL_RIGHTS_LARGEOBJECT;
break;
case ACL_OBJECT_NAMESPACE:
case OBJECT_SCHEMA:
world_default = ACL_NO_RIGHTS;
owner_default = ACL_ALL_RIGHTS_NAMESPACE;
owner_default = ACL_ALL_RIGHTS_SCHEMA;
break;
case ACL_OBJECT_TABLESPACE:
case OBJECT_TABLESPACE:
world_default = ACL_NO_RIGHTS;
owner_default = ACL_ALL_RIGHTS_TABLESPACE;
break;
case ACL_OBJECT_FDW:
case OBJECT_FDW:
world_default = ACL_NO_RIGHTS;
owner_default = ACL_ALL_RIGHTS_FDW;
break;
case ACL_OBJECT_FOREIGN_SERVER:
case OBJECT_FOREIGN_SERVER:
world_default = ACL_NO_RIGHTS;
owner_default = ACL_ALL_RIGHTS_FOREIGN_SERVER;
break;
case ACL_OBJECT_DOMAIN:
case ACL_OBJECT_TYPE:
case OBJECT_DOMAIN:
case OBJECT_TYPE:
world_default = ACL_USAGE;
owner_default = ACL_ALL_RIGHTS_TYPE;
break;
......@@ -855,7 +855,7 @@ acldefault(GrantObjectType objtype, Oid ownerId)
/*
* SQL-accessible version of acldefault(). Hackish mapping from "char" type to
* ACL_OBJECT_* values, but it's only used in the information schema, not
* OBJECT_* values, but it's only used in the information schema, not
* documented for general use.
*/
Datum
......@@ -863,45 +863,45 @@ acldefault_sql(PG_FUNCTION_ARGS)
{
char objtypec = PG_GETARG_CHAR(0);
Oid owner = PG_GETARG_OID(1);
GrantObjectType objtype = 0;
ObjectType objtype = 0;
switch (objtypec)
{
case 'c':
objtype = ACL_OBJECT_COLUMN;
objtype = OBJECT_COLUMN;
break;
case 'r':
objtype = ACL_OBJECT_RELATION;
objtype = OBJECT_TABLE;
break;
case 's':
objtype = ACL_OBJECT_SEQUENCE;
objtype = OBJECT_SEQUENCE;
break;
case 'd':
objtype = ACL_OBJECT_DATABASE;
objtype = OBJECT_DATABASE;
break;
case 'f':
objtype = ACL_OBJECT_FUNCTION;
objtype = OBJECT_FUNCTION;
break;
case 'l':
objtype = ACL_OBJECT_LANGUAGE;
objtype = OBJECT_LANGUAGE;
break;
case 'L':
objtype = ACL_OBJECT_LARGEOBJECT;
objtype = OBJECT_LARGEOBJECT;
break;
case 'n':
objtype = ACL_OBJECT_NAMESPACE;
objtype = OBJECT_SCHEMA;
break;
case 't':
objtype = ACL_OBJECT_TABLESPACE;
objtype = OBJECT_TABLESPACE;
break;
case 'F':
objtype = ACL_OBJECT_FDW;
objtype = OBJECT_FDW;
break;
case 'S':
objtype = ACL_OBJECT_FOREIGN_SERVER;
objtype = OBJECT_FOREIGN_SERVER;
break;
case 'T':
objtype = ACL_OBJECT_TYPE;
objtype = OBJECT_TYPE;
break;
default:
elog(ERROR, "unrecognized objtype abbreviation: %c", objtypec);
......
......@@ -50,7 +50,6 @@ extern void AlterEventTriggerOwner_oid(Oid, Oid newOwnerId);
extern bool EventTriggerSupportsObjectType(ObjectType obtype);
extern bool EventTriggerSupportsObjectClass(ObjectClass objclass);
extern bool EventTriggerSupportsGrantObjectType(GrantObjectType objtype);
extern void EventTriggerDDLCommandStart(Node *parsetree);
extern void EventTriggerDDLCommandEnd(Node *parsetree);
extern void EventTriggerSQLDrop(Node *parsetree);
......
......@@ -1845,31 +1845,12 @@ typedef enum GrantTargetType
ACL_TARGET_DEFAULTS /* ALTER DEFAULT PRIVILEGES */
} GrantTargetType;
typedef enum GrantObjectType
{
ACL_OBJECT_COLUMN, /* column */
ACL_OBJECT_RELATION, /* table, view */
ACL_OBJECT_SEQUENCE, /* sequence */
ACL_OBJECT_DATABASE, /* database */
ACL_OBJECT_DOMAIN, /* domain */
ACL_OBJECT_FDW, /* foreign-data wrapper */
ACL_OBJECT_FOREIGN_SERVER, /* foreign server */
ACL_OBJECT_FUNCTION, /* function */
ACL_OBJECT_LANGUAGE, /* procedural language */
ACL_OBJECT_LARGEOBJECT, /* largeobject */
ACL_OBJECT_NAMESPACE, /* namespace */
ACL_OBJECT_PROCEDURE, /* procedure */
ACL_OBJECT_ROUTINE, /* routine */
ACL_OBJECT_TABLESPACE, /* tablespace */
ACL_OBJECT_TYPE /* type */
} GrantObjectType;
typedef struct GrantStmt
{
NodeTag type;
bool is_grant; /* true = GRANT, false = REVOKE */
GrantTargetType targtype; /* type of the grant target */
GrantObjectType objtype; /* kind of object being operated on */
ObjectType objtype; /* kind of object being operated on */
List *objects; /* list of RangeVar nodes, ObjectWithArgs
* nodes, or plain names (as Value strings) */
List *privileges; /* list of AccessPriv nodes */
......
......@@ -97,7 +97,7 @@ typedef struct CollectedCommand
/* ALTER DEFAULT PRIVILEGES */
struct
{
GrantObjectType objtype;
ObjectType objtype;
} defprivs;
} d;
} CollectedCommand;
......
......@@ -163,7 +163,7 @@ typedef ArrayType Acl;
#define ACL_ALL_RIGHTS_FUNCTION (ACL_EXECUTE)
#define ACL_ALL_RIGHTS_LANGUAGE (ACL_USAGE)
#define ACL_ALL_RIGHTS_LARGEOBJECT (ACL_SELECT|ACL_UPDATE)
#define ACL_ALL_RIGHTS_NAMESPACE (ACL_USAGE|ACL_CREATE)
#define ACL_ALL_RIGHTS_SCHEMA (ACL_USAGE|ACL_CREATE)
#define ACL_ALL_RIGHTS_TABLESPACE (ACL_CREATE)
#define ACL_ALL_RIGHTS_TYPE (ACL_USAGE)
......@@ -217,8 +217,8 @@ typedef enum AclObjectKind
/*
* routines used internally
*/
extern Acl *acldefault(GrantObjectType objtype, Oid ownerId);
extern Acl *get_user_default_acl(GrantObjectType objtype, Oid ownerId,
extern Acl *acldefault(ObjectType objtype, Oid ownerId);
extern Acl *get_user_default_acl(ObjectType objtype, Oid ownerId,
Oid nsp_oid);
extern Acl *aclupdate(const Acl *old_acl, const AclItem *mod_aip,
......
......@@ -26,12 +26,12 @@
* Note: 'all_privs' and 'privileges' represent object-level privileges only.
* There might also be column-level privilege specifications, which are
* represented in col_privs (this is a list of untransformed AccessPriv nodes).
* Column privileges are only valid for objtype ACL_OBJECT_RELATION.
* Column privileges are only valid for objtype OBJECT_TABLE.
*/
typedef struct
{
bool is_grant;
GrantObjectType objtype;
ObjectType objtype;
List *objects;
bool all_privs;
AclMode privileges;
......
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