Re: alter user/role CURRENT_USER - Mailing list pgsql-hackers

From Kyotaro HORIGUCHI
Subject Re: alter user/role CURRENT_USER
Date
Msg-id 20141024.172928.175497798.horiguchi.kyotaro@lab.ntt.co.jp
Whole thread Raw
In response to Re: alter user/role CURRENT_USER  (Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>)
Responses Re: alter user/role CURRENT_USER
Re: alter user/role CURRENT_USER
List pgsql-hackers
Hi, here is the revised patch.

Attached files are the followings
- 0001-ALTER-ROLE-CURRENT_USER_v2.patch  - the patch.
- testset.tar.bz2 - test set. Run by typing 'make check' as a  superuser of the running postgreSQL server. It creates
"testdb" and some roles.
 

Documents are not edited this time.

---- 

Considering your comments, I found more points to modify.
- CREATE SCHEMA (IF NOT EXISTS) .. AUTHORIZATION <role> ...
- ALTER AGGREAGE/COLLATION/etc... OWNER TO <role>
- CREATE/ALTER/DROP USER MAPPING FOR <role> SERVER ..

GRANT/REVOKE also takes role as an arguemnt but CURRENT_USER and
the similar keywords seem to be useless for them.

Finally, the new patch modifies the following points.

In gram.y,
- RoleId's are replaced with RoleId_or_curruser in more places.  It accepts
CURRENT_USER/USER/CURRENT_ROLE/SESSION_USER.
- ALTER USER ALL syntax is added. (not changed from the previous patch)
- The non-terminal auth_ident now uses RoleId_or_curruser  instead of RoleId. This affects CREATE/ALTER/DROP USER
MAPPING

In user.c, new function ResolveRoleId() is added and used for all
role ID resolutions that correspond to the syntax changes in
parser. It is AlterRole() in user.c.

In foreigncmds.c, GetUserOidFromMapping() is removed and
ResolveRoleId is used instead.

In alter.c and tablecmds.c, all calls to get_role_oid()
correspond the the grammer change were replaced with
ResolveRoleId().

The modifications are a bit complicated so I provided a
comprehensive test set.


regards,

-- 
Kyotaro Horiguchi
NTT Open Source Software Center

pgsql-hackers by date:

Previous
From: Ali Akbar
Date:
Subject: Re: Function array_agg(array)
Next
From: Michael Paquier
Date:
Subject: Re: make pg_controldata accept "-D dirname"