diff options
author | Alvaro Herrera | 2015-03-09 20:00:43 +0000 |
---|---|---|
committer | Alvaro Herrera | 2015-03-09 20:00:43 +0000 |
commit | e3f1c24b992acb88e4ccf33118640aee4b11dd47 (patch) | |
tree | 29eaaf5267fd236cea1a43ebfa9276c8b63a973d /src/backend/commands | |
parent | 31eae6028eca4365e7165f5f33fee1ed0486aee0 (diff) |
Fix crasher bugs in previous commit
ALTER DEFAULT PRIVILEGES was trying to decode the list of roles in the
FOR clause as a list of names rather than of RoleSpecs; and the IN
clause in CREATE ROLE was doing the same thing. This was evidenced by
crashes on some buildfarm machines, though on my platform this doesn't
cause a failure by mere chance; I can reproduce the failures only by
adding some padding in struct RoleSpecs.
Fix by dereferencing those lists as being of RoleSpecs, not string
Values.
Diffstat (limited to 'src/backend/commands')
-rw-r--r-- | src/backend/commands/user.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/backend/commands/user.c b/src/backend/commands/user.c index c14465eb87b..75f1b3cd4f2 100644 --- a/src/backend/commands/user.c +++ b/src/backend/commands/user.c @@ -429,13 +429,17 @@ CreateRole(CreateRoleStmt *stmt) */ 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); } /* |