GrantStmt *action = stmt->action;
InternalDefaultACL iacls;
ListCell *cell;
- List *rolenames = NIL;
+ List *rolespecs = NIL;
List *nspnames = NIL;
- DefElem *drolenames = NULL;
+ DefElem *drolespecs = NULL;
DefElem *dnspnames = NULL;
AclMode all_privileges;
const char *errormsg;
}
else if (strcmp(defel->defname, "roles") == 0)
{
- if (drolenames)
+ if (drolespecs)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options")));
- drolenames = defel;
+ drolespecs = defel;
}
else
elog(ERROR, "option \"%s\" not recognized", defel->defname);
if (dnspnames)
nspnames = (List *) dnspnames->arg;
- if (drolenames)
- rolenames = (List *) drolenames->arg;
+ if (drolespecs)
+ rolespecs = (List *) drolespecs->arg;
/* Prepare the InternalDefaultACL representation of the statement */
/* roleid to be filled below */
}
}
- if (rolenames == NIL)
+ if (rolespecs == NIL)
{
/* Set permissions for myself */
iacls.roleid = GetUserId();
/* Look up the role OIDs and do permissions checks */
ListCell *rolecell;
- foreach(rolecell, rolenames)
+ foreach(rolecell, rolespecs)
{
- char *rolename = strVal(lfirst(rolecell));
+ RoleSpec *rolespec = lfirst(rolecell);
- iacls.roleid = get_role_oid(rolename, false);
+ iacls.roleid = get_rolespec_oid((Node *) rolespec, false);
/*
* We insist that calling user be a member of each target role. If
*/
foreach(item, addroleto)
{
- char *oldrolename = strVal(lfirst(item));
- Oid oldroleid = get_role_oid(oldrolename, false);
+ RoleSpec *oldrole = lfirst(item);
+ HeapTuple oldroletup = get_rolespec_tuple((Node *) oldrole);
+ Oid oldroleid = HeapTupleGetOid(oldroletup);
+ char *oldrolename = NameStr(((Form_pg_authid) GETSTRUCT(oldroletup))->rolname);
AddRoleMems(oldrolename, oldroleid,
list_make1(makeString(stmt->role)),
list_make1_oid(roleid),
GetUserId(), false);
+
+ ReleaseSysCache(oldroletup);
}
/*