Commit 7dda6987 authored by Sergei Golubchik's avatar Sergei Golubchik

rename columns in mysql.roles_mapping to be consistent with other privilege tables

parent b2f16628
......@@ -4,12 +4,12 @@ create user u1;
set role r1;
grant r1 to u1;
select * from mysql.roles_mapping;
HostFk UserFk RoleFk
Host User Role
% u1 r1
localhost root r1
drop user u1;
select * from mysql.roles_mapping;
HostFk UserFk RoleFk
Host User Role
localhost root r1
show grants;
Grants for root@localhost
......@@ -19,7 +19,7 @@ GRANT PROXY ON ''@'%' TO 'root'@'localhost' WITH GRANT OPTION
GRANT USAGE ON *.* TO 'r1'
drop role r1;
select * from mysql.roles_mapping;
HostFk UserFk RoleFk
Host User Role
show grants;
Grants for root@localhost
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION
......
......@@ -14,7 +14,7 @@ show grants for u2;
Grants for u2@%
GRANT USAGE ON *.* TO 'u2'@'%'
select * from mysql.roles_mapping;
HostFk UserFk RoleFk
Host User Role
% u1 r1
revoke r1 from u1;
revoke r1 from u1;
......@@ -23,7 +23,7 @@ show grants for u1;
Grants for u1@%
GRANT USAGE ON *.* TO 'u1'@'%'
select * from mysql.roles_mapping;
HostFk UserFk RoleFk
Host User Role
grant r1 to u1;
grant r1 to u1;
ERROR HY000: Cannot grant role 'r1' to: 'u1'.
......@@ -32,23 +32,23 @@ Grants for u1@%
GRANT r1 TO 'u1'@'%'
GRANT USAGE ON *.* TO 'u1'@'%'
select * from mysql.roles_mapping;
HostFk UserFk RoleFk
Host User Role
% u1 r1
drop role r1;
show grants for u1;
Grants for u1@%
GRANT USAGE ON *.* TO 'u1'@'%'
select * from mysql.roles_mapping;
HostFk UserFk RoleFk
Host User Role
create role r1;
grant r1 to u1;
select * from mysql.roles_mapping;
HostFk UserFk RoleFk
Host User Role
% u1 r1
drop user u1;
show grants for u1;
ERROR 42000: There is no such grant defined for user 'u1' on host '%'
select * from mysql.roles_mapping;
HostFk UserFk RoleFk
Host User Role
drop role r1;
drop user u2;
create user test_user@localhost;
create role test_role1;
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('localhost',
'test_user',
'test_role1');
insert into mysql.roles_mapping values ('localhost', 'test_user', 'test_role1');
create role test_role2;
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('',
'test_role1',
'test_role2');
insert into mysql.roles_mapping values ('', 'test_role1', 'test_role2');
flush privileges;
use mysql;
select * from roles_mapping;
HostFk UserFk RoleFk
Host User Role
test_role1 test_role2
localhost test_user test_role1
rename user 'test_user'@'localhost' to 'test_user_rm'@'newhost';
......@@ -20,7 +16,7 @@ test_role1
test_role2
test_user_rm newhost
select * from roles_mapping;
HostFk UserFk RoleFk
Host User Role
test_role1 test_role2
newhost test_user_rm test_role1
delete from mysql.roles_mapping;
......
create user 'test_user'@'localhost';
create role test_role1;
create role test_role2;
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('localhost',
'test_user',
'test_role1');
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('localhost',
'test_user',
'test_role2');
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('',
'test_role1',
'test_role2');
insert into mysql.roles_mapping values ('localhost', 'test_user', 'test_role1');
insert into mysql.roles_mapping values ('localhost', 'test_user', 'test_role2');
insert into mysql.roles_mapping values ('', 'test_role1', 'test_role2');
select user, host from mysql.user where user not like 'root';
user host
test_role1
test_role2
test_user localhost
select * from mysql.roles_mapping;
HostFk UserFk RoleFk
Host User Role
test_role1 test_role2
localhost test_user test_role1
localhost test_user test_role2
......@@ -37,7 +31,7 @@ select current_user(), current_role();
current_user() current_role()
test_user@localhost test_role1
select * from mysql.roles_mapping;
HostFk UserFk RoleFk
Host User Role
test_role1 test_role2
localhost test_user test_role1
localhost test_user test_role2
......@@ -52,7 +46,7 @@ select current_user(), current_role();
current_user() current_role()
test_user@localhost test_role2
select * from mysql.roles_mapping;
HostFk UserFk RoleFk
Host User Role
test_role1 test_role2
localhost test_user test_role1
localhost test_user test_role2
......@@ -60,6 +54,6 @@ drop user 'test_user'@'localhost';
revoke select on mysql.* from test_role2;
delete from mysql.user where user='test_role1';
delete from mysql.user where user='test_role2';
delete from mysql.roles_mapping where RoleFk='test_role1';
delete from mysql.roles_mapping where RoleFk='test_role2';
delete from mysql.roles_mapping where Role='test_role1';
delete from mysql.roles_mapping where Role='test_role2';
flush privileges;
create user 'test_user'@'localhost';
create role test_role1;
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('localhost',
'test_user',
'test_role1');
insert into mysql.roles_mapping values ('localhost', 'test_user', 'test_role1');
select user, host from mysql.user where user not like 'root';
user host
test_role1
test_user localhost
select * from mysql.roles_mapping;
HostFk UserFk RoleFk
Host User Role
localhost test_user test_role1
flush privileges;
grant select on mysql.* to test_role1;
......@@ -24,14 +22,12 @@ select current_user(), current_role();
current_user() current_role()
test_user@localhost test_role1
select * from mysql.roles_mapping;
HostFk UserFk RoleFk
Host User Role
localhost test_user test_role1
insert into mysql.user (user, host) values ('Dummy', 'Dummy');
ERROR 42000: INSERT command denied to user 'test_user'@'localhost' for table 'user'
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('localhost',
'test_user',
'test_role2');
delete from mysql.roles_mapping where RoleFk='test_role2';
insert into mysql.roles_mapping values ('localhost', 'test_user', 'test_role2');
delete from mysql.roles_mapping where Role='test_role2';
use mysql;
set role none;
select current_user(), current_role();
......@@ -43,15 +39,13 @@ select * from mysql.roles_mapping;
ERROR 42000: SELECT command denied to user 'test_user'@'localhost' for table 'roles_mapping'
insert into mysql.user (user, host) values ('Dummy', 'Dummy');
ERROR 42000: INSERT command denied to user 'test_user'@'localhost' for table 'user'
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('localhost',
'test_user',
'test_role2');
insert into mysql.roles_mapping values ('localhost', 'test_user', 'test_role2');
ERROR 42000: INSERT command denied to user 'test_user'@'localhost' for table 'roles_mapping'
delete from mysql.roles_mapping where RoleFk='test_role2';
delete from mysql.roles_mapping where Role='test_role2';
ERROR 42000: DELETE command denied to user 'test_user'@'localhost' for table 'roles_mapping'
drop user 'test_user'@'localhost';
revoke select on mysql.* from test_role1;
revoke insert, delete on mysql.roles_mapping from test_role1;
drop role test_role1;
delete from mysql.roles_mapping where RoleFk='test_role1';
delete from mysql.roles_mapping where Role='test_role1';
flush privileges;
......@@ -35,27 +35,13 @@ Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv D
select * from mysql.user where user='r_rld';
Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv Create_tablespace_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin authentication_string is_role
% r_rld N N N N N N Y N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 Y
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('localhost',
'test_user',
'r_sel');
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('localhost',
'test_user',
'r_ins');
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('localhost',
'test_user',
'r_upd');
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('localhost',
'test_user',
'r_del');
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('localhost',
'test_user',
'r_crt');
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('localhost',
'test_user',
'r_drp');
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('localhost',
'test_user',
'r_rld');
insert into mysql.roles_mapping values ('localhost', 'test_user', 'r_sel');
insert into mysql.roles_mapping values ('localhost', 'test_user', 'r_ins');
insert into mysql.roles_mapping values ('localhost', 'test_user', 'r_upd');
insert into mysql.roles_mapping values ('localhost', 'test_user', 'r_del');
insert into mysql.roles_mapping values ('localhost', 'test_user', 'r_crt');
insert into mysql.roles_mapping values ('localhost', 'test_user', 'r_drp');
insert into mysql.roles_mapping values ('localhost', 'test_user', 'r_rld');
flush privileges;
select * from mysql.roles_mapping;
ERROR 42000: SELECT command denied to user 'test_user'@'localhost' for table 'roles_mapping'
......@@ -88,7 +74,7 @@ GRANT r_rld TO 'test_user'@'localhost'
GRANT r_sel TO 'test_user'@'localhost'
GRANT r_upd TO 'test_user'@'localhost'
select * from mysql.roles_mapping;
HostFk UserFk RoleFk
Host User Role
localhost test_user r_crt
localhost test_user r_del
localhost test_user r_drp
......@@ -113,9 +99,7 @@ GRANT r_sel TO 'test_user'@'localhost'
GRANT r_upd TO 'test_user'@'localhost'
select * from mysql.roles_mapping;
ERROR 42000: SELECT command denied to user 'test_user'@'localhost' for table 'roles_mapping'
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('',
'r_sel',
'r_rld');
insert into mysql.roles_mapping values ('', 'r_sel', 'r_rld');
flush privileges;
ERROR 42000: Access denied; you need (at least one of) the RELOAD privilege(s) for this operation
set role r_rld;
......@@ -138,21 +122,11 @@ set role r_ins;
select current_user(), current_role();
current_user() current_role()
test_user@localhost r_ins
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('',
'r_sel',
'r_upd');
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('',
'r_sel',
'r_del');
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('',
'r_sel',
'r_crt');
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('',
'r_sel',
'r_drp');
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('',
'r_del',
'r_ins');
insert into mysql.roles_mapping values ('', 'r_sel', 'r_upd');
insert into mysql.roles_mapping values ('', 'r_sel', 'r_del');
insert into mysql.roles_mapping values ('', 'r_sel', 'r_crt');
insert into mysql.roles_mapping values ('', 'r_sel', 'r_drp');
insert into mysql.roles_mapping values ('', 'r_del', 'r_ins');
set role r_rld;
select current_user(), current_role();
current_user() current_role()
......@@ -162,7 +136,7 @@ set role r_sel;
select current_user(), current_role();
current_user() current_role()
test_user@localhost r_sel
update mysql.roles_mapping set RoleFk='r_ins' where RoleFk='r_ins_wrong';
update mysql.roles_mapping set Role='r_ins' where Role='r_ins_wrong';
flush privileges;
set role r_sel;
select current_user(), current_role();
......@@ -173,7 +147,7 @@ insert into mysql.random_test_table values (1);
select * from mysql.random_test_table;
id
1
delete from mysql.roles_mapping where RoleFk='r_ins';
delete from mysql.roles_mapping where Role='r_ins';
flush privileges;
set role r_sel;
select current_user(), current_role();
......@@ -183,6 +157,6 @@ insert into mysql.random_test_table values (1);
ERROR 42000: INSERT command denied to user 'test_user'@'localhost' for table 'random_test_table'
drop table mysql.random_test_table;
delete from mysql.user where user like 'r\_%';
delete from mysql.roles_mapping where RoleFk like 'r\_%';
delete from mysql.roles_mapping where Role like 'r\_%';
flush privileges;
drop user 'test_user'@'localhost';
create user 'test_user'@'localhost';
create user 'test_role1'@'';
update mysql.user set is_role='Y' where user='test_role1';
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('localhost',
'test_user',
'test_role1');
insert into mysql.roles_mapping values ('localhost', 'test_user', 'test_role1');
create user 'test_role2'@'';
update mysql.user set is_role='Y' where user='test_role2';
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('',
'test_role1',
'test_role2');
insert into mysql.roles_mapping values ('', 'test_role1', 'test_role2');
flush privileges;
select user, host from mysql.user where user not like 'root';
user host
test_role1 %
test_role2 %
test_user localhost
select * from mysql.roles_mapping where UserFk like 'test_user';
HostFk UserFk RoleFk
select * from mysql.roles_mapping where User like 'test_user';
Host User Role
localhost test_user test_role1
select * from mysql.roles_mapping where UserFk like 'test_role1';
HostFk UserFk RoleFk
select * from mysql.roles_mapping where User like 'test_role1';
Host User Role
test_role1 test_role2
grant select on *.* to 'test_role2'@'';
select * from mysql.user where user like 'test_role1';
......@@ -49,8 +45,8 @@ GRANT USAGE ON *.* TO 'test_role1'
GRANT USAGE ON *.* TO 'test_user'@'localhost'
GRANT test_role1 TO 'test_user'@'localhost'
GRANT test_role2 TO 'test_role1'
select * from mysql.roles_mapping where HostFk='';
HostFk UserFk RoleFk
select * from mysql.roles_mapping where Host='';
Host User Role
test_role1 test_role2
show grants;
Grants for test_user@localhost
......@@ -99,8 +95,8 @@ GRANT USAGE ON *.* TO 'test_role1'
GRANT USAGE ON *.* TO 'test_user'@'localhost'
GRANT test_role1 TO 'test_user'@'localhost'
GRANT test_role2 TO 'test_role1'
select * from mysql.roles_mapping where HostFk='';
HostFk UserFk RoleFk
select * from mysql.roles_mapping where Host='';
Host User Role
test_role1 test_role2
show grants;
Grants for test_user@localhost
......
......@@ -2,15 +2,9 @@ create user 'test_user'@'localhost';
create role test_role1;
create role test_role2;
create role test_role3;
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('localhost',
'test_user',
'test_role1');
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('localhost',
'test_user',
'test_role3');
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('',
'test_role1',
'test_role2');
insert into mysql.roles_mapping values ('localhost', 'test_user', 'test_role1');
insert into mysql.roles_mapping values ('localhost', 'test_user', 'test_role3');
insert into mysql.roles_mapping values ('', 'test_role1', 'test_role2');
select user, host from mysql.user where user not like 'root';
user host
test_role1
......@@ -18,7 +12,7 @@ test_role2
test_role3
test_user localhost
select * from mysql.roles_mapping;
HostFk UserFk RoleFk
Host User Role
test_role1 test_role2
localhost test_user test_role1
localhost test_user test_role3
......@@ -101,7 +95,7 @@ revoke execute on function mysql.test_func from test_role2;
revoke execute on procedure mysql.test_proc from test_role2;
revoke execute on mysql.* from test_role3;
delete from mysql.user where user like'test_%';
delete from mysql.roles_mapping where RoleFk like 'test%';
delete from mysql.roles_mapping where Role like 'test%';
drop function mysql.test_func;
drop procedure mysql.test_proc;
Warnings:
......
create user 'test_user'@'localhost';
create user 'test_role1'@'';
update mysql.user set is_role='Y' where user='test_role1';
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('localhost',
'test_user',
'test_role1');
insert into mysql.roles_mapping values ('localhost', 'test_user', 'test_role1');
select user, host from mysql.user where user not like 'root';
user host
test_role1 %
test_user localhost
select * from mysql.roles_mapping;
HostFk UserFk RoleFk
Host User Role
localhost test_user test_role1
grant select on *.* to 'test_role1'@'';
select * from mysql.user where user='test_role1';
......@@ -35,7 +33,7 @@ GRANT SELECT ON *.* TO 'test_role1'
GRANT USAGE ON *.* TO 'test_user'@'localhost'
GRANT test_role1 TO 'test_user'@'localhost'
select * from mysql.roles_mapping;
HostFk UserFk RoleFk
Host User Role
localhost test_user test_role1
set role none;
select current_user(), current_role();
......@@ -44,6 +42,6 @@ test_user@localhost NULL
select * from mysql.roles_mapping;
ERROR 42000: SELECT command denied to user 'test_user'@'localhost' for table 'roles_mapping'
delete from mysql.user where user='test_role1';
delete from mysql.roles_mapping where RoleFk='test_role1';
delete from mysql.roles_mapping where Role='test_role1';
flush privileges;
drop user 'test_user'@'localhost';
create user 'test_user'@'localhost';
create role test_role1;
create role test_role2;
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('localhost',
'test_user',
'test_role1');
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('',
'test_role1',
'test_role2');
insert into mysql.roles_mapping values ('localhost', 'test_user', 'test_role1');
insert into mysql.roles_mapping values ('', 'test_role1', 'test_role2');
select user, host from mysql.user where user not like 'root';
user host
test_role1
test_role2
test_user localhost
select * from mysql.roles_mapping;
HostFk UserFk RoleFk
Host User Role
test_role1 test_role2
localhost test_user test_role1
grant select (RoleFk) on mysql.roles_mapping to test_role2;
grant select (Role) on mysql.roles_mapping to test_role2;
flush privileges;
select * from mysql.roles_mapping;
ERROR 42000: SELECT command denied to user 'test_user'@'localhost' for table 'roles_mapping'
......@@ -33,21 +29,21 @@ current_user() current_role()
test_user@localhost test_role1
show grants;
Grants for test_user@localhost
GRANT SELECT (RoleFk) ON `mysql`.`roles_mapping` TO 'test_role2'
GRANT SELECT (Role) ON `mysql`.`roles_mapping` TO 'test_role2'
GRANT USAGE ON *.* TO 'test_role1'
GRANT USAGE ON *.* TO 'test_role2'
GRANT USAGE ON *.* TO 'test_user'@'localhost'
GRANT test_role1 TO 'test_user'@'localhost'
GRANT test_role2 TO 'test_role1'
select * from mysql.roles_mapping;
ERROR 42000: SELECT command denied to user 'test_user'@'localhost' for column 'HostFk' in table 'roles_mapping'
select RoleFk from mysql.roles_mapping;
RoleFk
ERROR 42000: SELECT command denied to user 'test_user'@'localhost' for column 'Host' in table 'roles_mapping'
select Role from mysql.roles_mapping;
Role
test_role1
test_role2
show grants;
Grants for test_user@localhost
GRANT SELECT (RoleFk) ON `mysql`.`roles_mapping` TO 'test_role2'
GRANT SELECT (Role) ON `mysql`.`roles_mapping` TO 'test_role2'
GRANT USAGE ON *.* TO 'test_role1'
GRANT USAGE ON *.* TO 'test_role2'
GRANT USAGE ON *.* TO 'test_user'@'localhost'
......@@ -58,7 +54,7 @@ set role none;
select current_user(), current_role();
current_user() current_role()
test_user@localhost NULL
select RoleFk from mysql.roles_mapping;
select Role from mysql.roles_mapping;
ERROR 42000: SELECT command denied to user 'test_user'@'localhost' for table 'roles_mapping'
drop user 'test_user'@'localhost';
select * from mysql.tables_priv;
......@@ -66,5 +62,5 @@ Host Db User Table_name Grantor Timestamp Table_priv Column_priv
mysql test_role2 roles_mapping root@localhost 0000-00-00 00:00:00 Select
revoke select on mysql.roles_mapping from test_role2;
delete from mysql.user where user like'test_%';
delete from mysql.roles_mapping where RoleFk like 'test%';
delete from mysql.roles_mapping where Role like 'test%';
flush privileges;
create user 'test_user'@'localhost';
create role test_role1;
create role test_role2;
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('localhost',
'test_user',
'test_role1');
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('',
'test_role1',
'test_role2');
insert into mysql.roles_mapping values ('localhost', 'test_user', 'test_role1');
insert into mysql.roles_mapping values ('', 'test_role1', 'test_role2');
select user, host from mysql.user where user not like 'root';
user host
test_role1
test_role2
test_user localhost
select * from mysql.roles_mapping;
HostFk UserFk RoleFk
Host User Role
test_role1 test_role2
localhost test_user test_role1
grant select on mysql.roles_mapping to test_role2;
......@@ -40,7 +36,7 @@ GRANT USAGE ON *.* TO 'test_user'@'localhost'
GRANT test_role1 TO 'test_user'@'localhost'
GRANT test_role2 TO 'test_role1'
select * from mysql.roles_mapping;
HostFk UserFk RoleFk
Host User Role
test_role1 test_role2
localhost test_user test_role1
show grants;
......@@ -64,5 +60,5 @@ Host Db User Table_name Grantor Timestamp Table_priv Column_priv
mysql test_role2 roles_mapping root@localhost 0000-00-00 00:00:00 Select
revoke select on mysql.roles_mapping from test_role2;
delete from mysql.user where user like'test_%';
delete from mysql.roles_mapping where RoleFk like 'test%';
delete from mysql.roles_mapping where Role like 'test%';
flush privileges;
create user 'test_user'@'localhost';
create role test_role1;
create role test_role2;
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('localhost',
'test_user',
'test_role1');
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('localhost',
'test_user',
'test_role2');
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('',
'test_role1',
'test_role2');
insert into mysql.roles_mapping values ('localhost', 'test_user', 'test_role1');
insert into mysql.roles_mapping values ('localhost', 'test_user', 'test_role2');
insert into mysql.roles_mapping values ('', 'test_role1', 'test_role2');
select user, host from mysql.user where user not like 'root';
user host
test_role1
test_role2
test_user localhost
select * from mysql.roles_mapping;
HostFk UserFk RoleFk
Host User Role
test_role1 test_role2
localhost test_user test_role1
localhost test_user test_role2
......@@ -145,6 +139,6 @@ drop user 'test_user'@'localhost';
revoke select on mysql.* from test_role2;
drop role test_role1;
drop role test_role2;
delete from mysql.roles_mapping where RoleFk='test_role1';
delete from mysql.roles_mapping where RoleFk='test_role2';
delete from mysql.roles_mapping where Role='test_role1';
delete from mysql.roles_mapping where Role='test_role2';
flush privileges;
......@@ -161,9 +161,9 @@ def mysql proxies_priv Proxied_user 4 NO char 16 48 NULL NULL NULL utf8 utf8_bi
def mysql proxies_priv Timestamp 7 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL 0 NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references
def mysql proxies_priv User 2 NO char 16 48 NULL NULL NULL utf8 utf8_bin char(16) PRI select,insert,update,references
def mysql proxies_priv With_grant 5 0 NO tinyint NULL NULL 3 0 NULL NULL NULL tinyint(1) select,insert,update,references
def mysql roles_mapping HostFk 1 NO char 60 60 NULL NULL NULL latin1 latin1_bin char(60) PRI select,insert,update,references
def mysql roles_mapping RoleFk 3 NO char 16 16 NULL NULL NULL latin1 latin1_bin char(16) PRI select,insert,update,references
def mysql roles_mapping UserFk 2 NO char 16 16 NULL NULL NULL latin1 latin1_bin char(16) PRI select,insert,update,references
def mysql roles_mapping Host 1 NO char 60 60 NULL NULL NULL latin1 latin1_bin char(60) PRI select,insert,update,references
def mysql roles_mapping Role 3 NO char 16 16 NULL NULL NULL latin1 latin1_bin char(16) PRI select,insert,update,references
def mysql roles_mapping User 2 NO char 16 16 NULL NULL NULL latin1 latin1_bin char(16) PRI select,insert,update,references
def mysql servers Db 3 NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references
def mysql servers Host 2 NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references
def mysql servers Owner 9 NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references
......@@ -484,9 +484,9 @@ NULL mysql procs_priv Timestamp timestamp NULL NULL NULL NULL timestamp
NULL mysql proxies_priv With_grant tinyint NULL NULL NULL NULL tinyint(1)
3.0000 mysql proxies_priv Grantor char 77 231 utf8 utf8_bin char(77)
NULL mysql proxies_priv Timestamp timestamp NULL NULL NULL NULL timestamp
1.0000 mysql roles_mapping HostFk char 60 60 latin1 latin1_bin char(60)
1.0000 mysql roles_mapping UserFk char 16 16 latin1 latin1_bin char(16)
1.0000 mysql roles_mapping RoleFk char 16 16 latin1 latin1_bin char(16)
1.0000 mysql roles_mapping Host char 60 60 latin1 latin1_bin char(60)
1.0000 mysql roles_mapping User char 16 16 latin1 latin1_bin char(16)
1.0000 mysql roles_mapping Role char 16 16 latin1 latin1_bin char(16)
3.0000 mysql servers Server_name char 64 192 utf8 utf8_general_ci char(64)
3.0000 mysql servers Host char 64 192 utf8 utf8_general_ci char(64)
3.0000 mysql servers Db char 64 192 utf8 utf8_general_ci char(64)
......
......@@ -119,9 +119,9 @@ def mysql PRIMARY def mysql proxies_priv Host
def mysql PRIMARY def mysql proxies_priv User
def mysql PRIMARY def mysql proxies_priv Proxied_host
def mysql PRIMARY def mysql proxies_priv Proxied_user
def mysql HostFk def mysql roles_mapping HostFk
def mysql HostFk def mysql roles_mapping UserFk
def mysql HostFk def mysql roles_mapping RoleFk
def mysql Host def mysql roles_mapping Host
def mysql Host def mysql roles_mapping User
def mysql Host def mysql roles_mapping Role
def mysql PRIMARY def mysql servers Server_name
def mysql PRIMARY def mysql table_stats db_name
def mysql PRIMARY def mysql table_stats table_name
......
......@@ -132,9 +132,9 @@ def mysql proxies_priv mysql PRIMARY
def mysql proxies_priv mysql PRIMARY
def mysql proxies_priv mysql PRIMARY
def mysql proxies_priv mysql Grantor
def mysql roles_mapping mysql HostFk
def mysql roles_mapping mysql HostFk
def mysql roles_mapping mysql HostFk
def mysql roles_mapping mysql Host
def mysql roles_mapping mysql Host
def mysql roles_mapping mysql Host
def mysql servers mysql PRIMARY
def mysql table_stats mysql PRIMARY
def mysql table_stats mysql PRIMARY
......
......@@ -54,9 +54,9 @@ def mysql proxies_priv 0 mysql PRIMARY 1 Host A #CARD# NULL NULL BTREE
def mysql proxies_priv 0 mysql PRIMARY 2 User A #CARD# NULL NULL BTREE
def mysql proxies_priv 0 mysql PRIMARY 3 Proxied_host A #CARD# NULL NULL BTREE
def mysql proxies_priv 0 mysql PRIMARY 4 Proxied_user A #CARD# NULL NULL BTREE
def mysql roles_mapping 0 mysql HostFk 1 HostFk A #CARD# NULL NULL BTREE
def mysql roles_mapping 0 mysql HostFk 2 UserFk A #CARD# NULL NULL BTREE
def mysql roles_mapping 0 mysql HostFk 3 RoleFk A #CARD# NULL NULL BTREE
def mysql roles_mapping 0 mysql Host 1 Host A #CARD# NULL NULL BTREE
def mysql roles_mapping 0 mysql Host 2 User A #CARD# NULL NULL BTREE
def mysql roles_mapping 0 mysql Host 3 Role A #CARD# NULL NULL BTREE
def mysql servers 0 mysql PRIMARY 1 Server_name A #CARD# NULL NULL BTREE
def mysql tables_priv 1 mysql Grantor 1 Grantor A #CARD# NULL NULL BTREE
def mysql tables_priv 0 mysql PRIMARY 1 Host A #CARD# NULL NULL BTREE
......
......@@ -77,7 +77,7 @@ def mysql PRIMARY mysql plugin
def mysql PRIMARY mysql proc
def mysql PRIMARY mysql procs_priv
def mysql PRIMARY mysql proxies_priv
def mysql HostFk mysql roles_mapping
def mysql Host mysql roles_mapping
def mysql PRIMARY mysql servers
def mysql PRIMARY mysql table_stats
def mysql PRIMARY mysql tables_priv
......
......@@ -27,7 +27,7 @@ def mysql PRIMARY mysql plugin PRIMARY KEY
def mysql PRIMARY mysql proc PRIMARY KEY
def mysql PRIMARY mysql procs_priv PRIMARY KEY
def mysql PRIMARY mysql proxies_priv PRIMARY KEY
def mysql HostFk mysql roles_mapping UNIQUE
def mysql Host mysql roles_mapping UNIQUE
def mysql PRIMARY mysql servers PRIMARY KEY
def mysql PRIMARY mysql tables_priv PRIMARY KEY
def mysql PRIMARY mysql table_stats PRIMARY KEY
......
......@@ -2,13 +2,9 @@
#create a user with no privileges
create user test_user@localhost;
create role test_role1;
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('localhost',
'test_user',
'test_role1');
insert into mysql.roles_mapping values ('localhost', 'test_user', 'test_role1');
create role test_role2;
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('',
'test_role1',
'test_role2');
insert into mysql.roles_mapping values ('', 'test_role1', 'test_role2');
flush privileges;
use mysql;
......
......@@ -3,15 +3,9 @@ create user 'test_user'@'localhost';
create role test_role1;
create role test_role2;
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('localhost',
'test_user',
'test_role1');
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('localhost',
'test_user',
'test_role2');
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('',
'test_role1',
'test_role2');
insert into mysql.roles_mapping values ('localhost', 'test_user', 'test_role1');
insert into mysql.roles_mapping values ('localhost', 'test_user', 'test_role2');
insert into mysql.roles_mapping values ('', 'test_role1', 'test_role2');
--sorted_result
select user, host from mysql.user where user not like 'root';
--sorted_result
......@@ -48,6 +42,6 @@ drop user 'test_user'@'localhost';
revoke select on mysql.* from test_role2;
delete from mysql.user where user='test_role1';
delete from mysql.user where user='test_role2';
delete from mysql.roles_mapping where RoleFk='test_role1';
delete from mysql.roles_mapping where RoleFk='test_role2';
delete from mysql.roles_mapping where Role='test_role1';
delete from mysql.roles_mapping where Role='test_role2';
flush privileges;
......@@ -2,9 +2,7 @@
create user 'test_user'@'localhost';
create role test_role1;
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('localhost',
'test_user',
'test_role1');
insert into mysql.roles_mapping values ('localhost', 'test_user', 'test_role1');
--sorted_result
select user, host from mysql.user where user not like 'root';
--sorted_result
......@@ -27,10 +25,8 @@ select current_user(), current_role();
select * from mysql.roles_mapping;
--error ER_TABLEACCESS_DENIED_ERROR
insert into mysql.user (user, host) values ('Dummy', 'Dummy');
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('localhost',
'test_user',
'test_role2');
delete from mysql.roles_mapping where RoleFk='test_role2';
insert into mysql.roles_mapping values ('localhost', 'test_user', 'test_role2');
delete from mysql.roles_mapping where Role='test_role2';
use mysql;
......@@ -44,17 +40,15 @@ select * from mysql.roles_mapping;
--error ER_TABLEACCESS_DENIED_ERROR
insert into mysql.user (user, host) values ('Dummy', 'Dummy');
--error ER_TABLEACCESS_DENIED_ERROR
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('localhost',
'test_user',
'test_role2');
insert into mysql.roles_mapping values ('localhost', 'test_user', 'test_role2');
--error ER_TABLEACCESS_DENIED_ERROR
delete from mysql.roles_mapping where RoleFk='test_role2';
delete from mysql.roles_mapping where Role='test_role2';
change_user 'root';
drop user 'test_user'@'localhost';
revoke select on mysql.* from test_role1;
revoke insert, delete on mysql.roles_mapping from test_role1;
drop role test_role1;
delete from mysql.roles_mapping where RoleFk='test_role1';
delete from mysql.roles_mapping where Role='test_role1';
flush privileges;
......@@ -29,27 +29,13 @@ select * from mysql.user where user='r_rld';
#####################################
#set up roles mapping
#####################################
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('localhost',
'test_user',
'r_sel');
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('localhost',
'test_user',
'r_ins');
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('localhost',
'test_user',
'r_upd');
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('localhost',
'test_user',
'r_del');
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('localhost',
'test_user',
'r_crt');
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('localhost',
'test_user',
'r_drp');
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('localhost',
'test_user',
'r_rld');
insert into mysql.roles_mapping values ('localhost', 'test_user', 'r_sel');
insert into mysql.roles_mapping values ('localhost', 'test_user', 'r_ins');
insert into mysql.roles_mapping values ('localhost', 'test_user', 'r_upd');
insert into mysql.roles_mapping values ('localhost', 'test_user', 'r_del');
insert into mysql.roles_mapping values ('localhost', 'test_user', 'r_crt');
insert into mysql.roles_mapping values ('localhost', 'test_user', 'r_drp');
insert into mysql.roles_mapping values ('localhost', 'test_user', 'r_rld');
flush privileges;
change_user 'test_user';
......@@ -73,9 +59,7 @@ select current_user(), current_role();
show grants;
--error ER_TABLEACCESS_DENIED_ERROR
select * from mysql.roles_mapping;
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('',
'r_sel',
'r_rld');
insert into mysql.roles_mapping values ('', 'r_sel', 'r_rld');
--error ER_SPECIFIC_ACCESS_DENIED_ERROR
flush privileges;
set role r_rld;
......@@ -91,27 +75,17 @@ flush privileges;
set role r_ins;
select current_user(), current_role();
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('',
'r_sel',
'r_upd');
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('',
'r_sel',
'r_del');
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('',
'r_sel',
'r_crt');
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('',
'r_sel',
'r_drp');
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('',
'r_del',
'r_ins');
insert into mysql.roles_mapping values ('', 'r_sel', 'r_upd');
insert into mysql.roles_mapping values ('', 'r_sel', 'r_del');
insert into mysql.roles_mapping values ('', 'r_sel', 'r_crt');
insert into mysql.roles_mapping values ('', 'r_sel', 'r_drp');
insert into mysql.roles_mapping values ('', 'r_del', 'r_ins');
set role r_rld;
select current_user(), current_role();
flush privileges;
set role r_sel;
select current_user(), current_role();
update mysql.roles_mapping set RoleFk='r_ins' where RoleFk='r_ins_wrong';
update mysql.roles_mapping set Role='r_ins' where Role='r_ins_wrong';
flush privileges;
set role r_sel;
select current_user(), current_role();
......@@ -120,7 +94,7 @@ create table mysql.random_test_table (id INT);
insert into mysql.random_test_table values (1);
--sorted_result
select * from mysql.random_test_table;
delete from mysql.roles_mapping where RoleFk='r_ins';
delete from mysql.roles_mapping where Role='r_ins';
flush privileges;
set role r_sel;
select current_user(), current_role();
......@@ -130,6 +104,6 @@ drop table mysql.random_test_table;
change_user 'root';
delete from mysql.user where user like 'r\_%';
delete from mysql.roles_mapping where RoleFk like 'r\_%';
delete from mysql.roles_mapping where Role like 'r\_%';
flush privileges;
drop user 'test_user'@'localhost';
......@@ -4,23 +4,19 @@ create user 'test_user'@'localhost';
create user 'test_role1'@'';
#manualy create role
update mysql.user set is_role='Y' where user='test_role1';
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('localhost',
'test_user',
'test_role1');
insert into mysql.roles_mapping values ('localhost', 'test_user', 'test_role1');
create user 'test_role2'@'';
#manualy create role
update mysql.user set is_role='Y' where user='test_role2';
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('',
'test_role1',
'test_role2');
insert into mysql.roles_mapping values ('', 'test_role1', 'test_role2');
flush privileges;
--sorted_result
select user, host from mysql.user where user not like 'root';
--sorted_result
select * from mysql.roles_mapping where UserFk like 'test_user';
select * from mysql.roles_mapping where User like 'test_user';
--sorted_result
select * from mysql.roles_mapping where UserFk like 'test_role1';
select * from mysql.roles_mapping where User like 'test_role1';
grant select on *.* to 'test_role2'@'';
--sorted_result
select * from mysql.user where user like 'test_role1';
......@@ -40,7 +36,7 @@ set role test_role1;
select current_user(), current_role();
--sorted_result
show grants;
select * from mysql.roles_mapping where HostFk='';
select * from mysql.roles_mapping where Host='';
--sorted_result
show grants;
......@@ -69,7 +65,7 @@ select current_user(), current_role();
--sorted_result
show grants;
--sorted_result
select * from mysql.roles_mapping where HostFk='';
select * from mysql.roles_mapping where Host='';
--sorted_result
show grants;
......
......@@ -3,16 +3,10 @@ create role test_role1;
create role test_role2;
create role test_role3;
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('localhost',
'test_user',
'test_role1');
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('localhost',
'test_user',
'test_role3');
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('',
'test_role1',
'test_role2');
insert into mysql.roles_mapping values ('localhost', 'test_user', 'test_role1');
insert into mysql.roles_mapping values ('localhost', 'test_user', 'test_role3');
insert into mysql.roles_mapping values ('', 'test_role1', 'test_role2');
--sorted_result
select user, host from mysql.user where user not like 'root';
--sorted_result
......@@ -82,7 +76,7 @@ revoke execute on function mysql.test_func from test_role2;
revoke execute on procedure mysql.test_proc from test_role2;
revoke execute on mysql.* from test_role3;
delete from mysql.user where user like'test_%';
delete from mysql.roles_mapping where RoleFk like 'test%';
delete from mysql.roles_mapping where Role like 'test%';
drop function mysql.test_func;
drop procedure mysql.test_proc;
flush privileges;
......@@ -4,9 +4,7 @@ create user 'test_user'@'localhost';
create user 'test_role1'@'';
#manualy create role
update mysql.user set is_role='Y' where user='test_role1';
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('localhost',
'test_user',
'test_role1');
insert into mysql.roles_mapping values ('localhost', 'test_user', 'test_role1');
--sorted_result
select user, host from mysql.user where user not like 'root';
--sorted_result
......@@ -38,6 +36,6 @@ select * from mysql.roles_mapping;
change_user 'root';
delete from mysql.user where user='test_role1';
delete from mysql.roles_mapping where RoleFk='test_role1';
delete from mysql.roles_mapping where Role='test_role1';
flush privileges;
drop user 'test_user'@'localhost';
......@@ -2,18 +2,14 @@ create user 'test_user'@'localhost';
create role test_role1;
create role test_role2;
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('localhost',
'test_user',
'test_role1');
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('',
'test_role1',
'test_role2');
insert into mysql.roles_mapping values ('localhost', 'test_user', 'test_role1');
insert into mysql.roles_mapping values ('', 'test_role1', 'test_role2');
--sorted_result
select user, host from mysql.user where user not like 'root';
--sorted_result
select * from mysql.roles_mapping;
grant select (RoleFk) on mysql.roles_mapping to test_role2;
grant select (Role) on mysql.roles_mapping to test_role2;
flush privileges;
......@@ -36,7 +32,7 @@ show grants;
select * from mysql.roles_mapping;
--sorted_result
select RoleFk from mysql.roles_mapping;
select Role from mysql.roles_mapping;
--sorted_result
show grants;
......@@ -48,13 +44,13 @@ select current_user(), current_role();
--sorted_result
--error ER_TABLEACCESS_DENIED_ERROR
select RoleFk from mysql.roles_mapping;
select Role from mysql.roles_mapping;
change_user 'root';
drop user 'test_user'@'localhost';
select * from mysql.tables_priv;
revoke select on mysql.roles_mapping from test_role2;
delete from mysql.user where user like'test_%';
delete from mysql.roles_mapping where RoleFk like 'test%';
delete from mysql.roles_mapping where Role like 'test%';
flush privileges;
......@@ -2,12 +2,8 @@ create user 'test_user'@'localhost';
create role test_role1;
create role test_role2;
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('localhost',
'test_user',
'test_role1');
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('',
'test_role1',
'test_role2');
insert into mysql.roles_mapping values ('localhost', 'test_user', 'test_role1');
insert into mysql.roles_mapping values ('', 'test_role1', 'test_role2');
--sorted_result
select user, host from mysql.user where user not like 'root';
--sorted_result
......@@ -52,6 +48,6 @@ drop user 'test_user'@'localhost';
select * from mysql.tables_priv;
revoke select on mysql.roles_mapping from test_role2;
delete from mysql.user where user like'test_%';
delete from mysql.roles_mapping where RoleFk like 'test%';
delete from mysql.roles_mapping where Role like 'test%';
flush privileges;
......@@ -3,15 +3,9 @@ create user 'test_user'@'localhost';
create role test_role1;
create role test_role2;
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('localhost',
'test_user',
'test_role1');
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('localhost',
'test_user',
'test_role2');
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('',
'test_role1',
'test_role2');
insert into mysql.roles_mapping values ('localhost', 'test_user', 'test_role1');
insert into mysql.roles_mapping values ('localhost', 'test_user', 'test_role2');
insert into mysql.roles_mapping values ('', 'test_role1', 'test_role2');
--sorted_result
select user, host from mysql.user where user not like 'root';
--sorted_result
......@@ -90,6 +84,6 @@ drop user 'test_user'@'localhost';
revoke select on mysql.* from test_role2;
drop role test_role1;
drop role test_role2;
delete from mysql.roles_mapping where RoleFk='test_role1';
delete from mysql.roles_mapping where RoleFk='test_role2';
delete from mysql.roles_mapping where Role='test_role1';
delete from mysql.roles_mapping where Role='test_role2';
flush privileges;
......@@ -41,7 +41,7 @@ CREATE TABLE IF NOT EXISTS user ( Host char(60) binary DEFAULT '' NOT NULL, Us
-- Remember for later if user table already existed
set @had_user_table= @@warning_count != 0;
CREATE TABLE IF NOT EXISTS roles_mapping (HostFk char(60) binary DEFAULT '' NOT NULL, UserFk char(16) binary DEFAULT '' NOT NULL, RoleFk char(16) binary DEFAULT '' NOT NULL, unique index (HostFk, UserFk, RoleFk));
CREATE TABLE IF NOT EXISTS roles_mapping (Host char(60) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Role char(16) binary DEFAULT '' NOT NULL, unique index (Host, User, Role));
CREATE TABLE IF NOT EXISTS func ( name char(64) binary DEFAULT '' NOT NULL, ret tinyint(1) DEFAULT '0' NOT NULL, dl char(128) DEFAULT '' NOT NULL, type enum ('function','aggregate') COLLATE utf8_general_ci NOT NULL, PRIMARY KEY (name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='User defined functions';
......
......@@ -8072,10 +8072,10 @@ static int handle_roles_mappings_table(TABLE *table, bool drop,
LEX_USER *user_from, LEX_USER *user_to)
{
/*
All entries (HostFK, UserFk) that match user_from will be renamed,
as well as all RoleFk entries that match if user_from.host.str == ""
All entries (Host, User) that match user_from will be renamed,
as well as all Role entries that match if user_from.host.str == ""
Otherwise, only matching (HostFk, UserFk) will be renamed.
Otherwise, only matching (Host, User) will be renamed.
*/
DBUG_ENTER("handle_roles_mappings_table");
......
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