Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
8122996a
Commit
8122996a
authored
Oct 18, 2013
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CURRENT_ROLE() function
parent
1ac0b920
Changes
21
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
213 additions
and
10 deletions
+213
-10
mysql-test/r/acl_roles_set_role-database-recursive.result
mysql-test/r/acl_roles_set_role-database-recursive.result
+12
-0
mysql-test/r/acl_roles_set_role-database-simple.result
mysql-test/r/acl_roles_set_role-database-simple.result
+9
-0
mysql-test/r/acl_roles_set_role-multiple-role.result
mysql-test/r/acl_roles_set_role-multiple-role.result
+33
-0
mysql-test/r/acl_roles_set_role-recursive.result
mysql-test/r/acl_roles_set_role-recursive.result
+18
-0
mysql-test/r/acl_roles_set_role-routine-simple.result
mysql-test/r/acl_roles_set_role-routine-simple.result
+12
-3
mysql-test/r/acl_roles_set_role-simple.result
mysql-test/r/acl_roles_set_role-simple.result
+9
-0
mysql-test/r/acl_roles_set_role-table-column-priv.result
mysql-test/r/acl_roles_set_role-table-column-priv.result
+9
-0
mysql-test/r/acl_roles_set_role-table-simple.result
mysql-test/r/acl_roles_set_role-table-simple.result
+9
-0
mysql-test/r/acl_roles_show_grants.result
mysql-test/r/acl_roles_show_grants.result
+12
-0
mysql-test/t/acl_roles_set_role-database-recursive.test
mysql-test/t/acl_roles_set_role-database-recursive.test
+4
-0
mysql-test/t/acl_roles_set_role-database-simple.test
mysql-test/t/acl_roles_set_role-database-simple.test
+3
-0
mysql-test/t/acl_roles_set_role-multiple-role.test
mysql-test/t/acl_roles_set_role-multiple-role.test
+11
-0
mysql-test/t/acl_roles_set_role-recursive.test
mysql-test/t/acl_roles_set_role-recursive.test
+6
-0
mysql-test/t/acl_roles_set_role-routine-simple.test
mysql-test/t/acl_roles_set_role-routine-simple.test
+4
-0
mysql-test/t/acl_roles_set_role-simple.test
mysql-test/t/acl_roles_set_role-simple.test
+3
-0
mysql-test/t/acl_roles_set_role-table-column-priv.test
mysql-test/t/acl_roles_set_role-table-column-priv.test
+3
-0
mysql-test/t/acl_roles_set_role-table-simple.test
mysql-test/t/acl_roles_set_role-table-simple.test
+3
-0
mysql-test/t/acl_roles_show_grants.test
mysql-test/t/acl_roles_show_grants.test
+4
-0
sql/item_strfunc.cc
sql/item_strfunc.cc
+19
-7
sql/item_strfunc.h
sql/item_strfunc.h
+22
-0
sql/sql_yacc.yy
sql/sql_yacc.yy
+8
-0
No files found.
mysql-test/r/acl_roles_set_role-database-recursive.result
View file @
8122996a
...
@@ -31,16 +31,28 @@ grant select on mysql.* to test_role2@'';
...
@@ -31,16 +31,28 @@ grant select on mysql.* to test_role2@'';
flush privileges;
flush privileges;
select * from mysql.roles_mapping;
select * from mysql.roles_mapping;
ERROR 42000: SELECT command denied to user 'test_user'@'localhost' for table 'roles_mapping'
ERROR 42000: SELECT command denied to user 'test_user'@'localhost' for table 'roles_mapping'
select current_user(), current_role();
current_user() current_role()
test_user@localhost NONE
set role test_role1;
set role test_role1;
select current_user(), current_role();
current_user() current_role()
test_user@localhost test_role1
select * from mysql.roles_mapping;
select * from mysql.roles_mapping;
HostFk UserFk RoleFk
HostFk UserFk RoleFk
test_role1 test_role2
test_role1 test_role2
localhost test_user test_role1
localhost test_user test_role1
localhost test_user test_role2
localhost test_user test_role2
set role none;
set role none;
select current_user(), current_role();
current_user() current_role()
test_user@localhost NONE
select * from mysql.roles_mapping;
select * from mysql.roles_mapping;
ERROR 42000: SELECT command denied to user 'test_user'@'localhost' for table 'roles_mapping'
ERROR 42000: SELECT command denied to user 'test_user'@'localhost' for table 'roles_mapping'
set role test_role2;
set role test_role2;
select current_user(), current_role();
current_user() current_role()
test_user@localhost test_role2
select * from mysql.roles_mapping;
select * from mysql.roles_mapping;
HostFk UserFk RoleFk
HostFk UserFk RoleFk
test_role1 test_role2
test_role1 test_role2
...
...
mysql-test/r/acl_roles_set_role-database-simple.result
View file @
8122996a
...
@@ -17,7 +17,13 @@ grant insert, delete on mysql.roles_mapping to test_role1@'';
...
@@ -17,7 +17,13 @@ grant insert, delete on mysql.roles_mapping to test_role1@'';
grant reload on *.* to test_role1@'';
grant reload on *.* to test_role1@'';
select * from mysql.roles_mapping;
select * from mysql.roles_mapping;
ERROR 42000: SELECT command denied to user 'test_user'@'localhost' for table 'roles_mapping'
ERROR 42000: SELECT command denied to user 'test_user'@'localhost' for table 'roles_mapping'
select current_user(), current_role();
current_user() current_role()
test_user@localhost NONE
set role test_role1;
set role test_role1;
select current_user(), current_role();
current_user() current_role()
test_user@localhost test_role1
select * from mysql.roles_mapping;
select * from mysql.roles_mapping;
HostFk UserFk RoleFk
HostFk UserFk RoleFk
localhost test_user test_role1
localhost test_user test_role1
...
@@ -29,6 +35,9 @@ insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('localhost',
...
@@ -29,6 +35,9 @@ insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('localhost',
delete from mysql.roles_mapping where RoleFk='test_role2';
delete from mysql.roles_mapping where RoleFk='test_role2';
use mysql;
use mysql;
set role none;
set role none;
select current_user(), current_role();
current_user() current_role()
test_user@localhost NONE
use mysql;
use mysql;
ERROR 42000: Access denied for user 'test_user'@'localhost' to database 'mysql'
ERROR 42000: Access denied for user 'test_user'@'localhost' to database 'mysql'
select * from mysql.roles_mapping;
select * from mysql.roles_mapping;
...
...
mysql-test/r/acl_roles_set_role-multiple-role.result
View file @
8122996a
...
@@ -69,7 +69,13 @@ GRANT r_ins TO 'test_user'@'localhost'
...
@@ -69,7 +69,13 @@ GRANT r_ins TO 'test_user'@'localhost'
GRANT r_rld TO 'test_user'@'localhost'
GRANT r_rld TO 'test_user'@'localhost'
GRANT r_sel TO 'test_user'@'localhost'
GRANT r_sel TO 'test_user'@'localhost'
GRANT r_upd TO 'test_user'@'localhost'
GRANT r_upd TO 'test_user'@'localhost'
select current_user(), current_role();
current_user() current_role()
test_user@localhost NONE
set role r_sel;
set role r_sel;
select current_user(), current_role();
current_user() current_role()
test_user@localhost r_sel
show grants;
show grants;
Grants for test_user@localhost
Grants for test_user@localhost
GRANT SELECT ON *.* TO 'r_sel'
GRANT SELECT ON *.* TO 'r_sel'
...
@@ -91,6 +97,9 @@ localhost test_user r_rld
...
@@ -91,6 +97,9 @@ localhost test_user r_rld
localhost test_user r_sel
localhost test_user r_sel
localhost test_user r_upd
localhost test_user r_upd
set role r_ins;
set role r_ins;
select current_user(), current_role();
current_user() current_role()
test_user@localhost r_ins
show grants;
show grants;
Grants for test_user@localhost
Grants for test_user@localhost
GRANT INSERT ON *.* TO 'r_ins'
GRANT INSERT ON *.* TO 'r_ins'
...
@@ -110,13 +119,25 @@ insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('',
...
@@ -110,13 +119,25 @@ insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('',
flush privileges;
flush privileges;
ERROR 42000: Access denied; you need (at least one of) the RELOAD privilege(s) for this operation
ERROR 42000: Access denied; you need (at least one of) the RELOAD privilege(s) for this operation
set role r_rld;
set role r_rld;
select current_user(), current_role();
current_user() current_role()
test_user@localhost r_rld
flush privileges;
flush privileges;
set role r_sel;
set role r_sel;
select current_user(), current_role();
current_user() current_role()
test_user@localhost r_sel
flush privileges;
flush privileges;
set role none;
set role none;
select current_user(), current_role();
current_user() current_role()
test_user@localhost NONE
flush privileges;
flush privileges;
ERROR 42000: Access denied; you need (at least one of) the RELOAD privilege(s) for this operation
ERROR 42000: Access denied; you need (at least one of) the RELOAD privilege(s) for this operation
set role r_ins;
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 ('',
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('',
'r_sel',
'r_sel',
'r_upd');
'r_upd');
...
@@ -133,11 +154,20 @@ insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('',
...
@@ -133,11 +154,20 @@ insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('',
'r_del',
'r_del',
'r_ins');
'r_ins');
set role r_rld;
set role r_rld;
select current_user(), current_role();
current_user() current_role()
test_user@localhost r_rld
flush privileges;
flush privileges;
set role r_sel;
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 RoleFk='r_ins' where RoleFk='r_ins_wrong';
flush privileges;
flush privileges;
set role r_sel;
set role r_sel;
select current_user(), current_role();
current_user() current_role()
test_user@localhost r_sel
create table mysql.random_test_table (id INT);
create table mysql.random_test_table (id INT);
insert into mysql.random_test_table values (1);
insert into mysql.random_test_table values (1);
select * from mysql.random_test_table;
select * from mysql.random_test_table;
...
@@ -146,6 +176,9 @@ id
...
@@ -146,6 +176,9 @@ id
delete from mysql.roles_mapping where RoleFk='r_ins';
delete from mysql.roles_mapping where RoleFk='r_ins';
flush privileges;
flush privileges;
set role r_sel;
set role r_sel;
select current_user(), current_role();
current_user() current_role()
test_user@localhost r_sel
insert into mysql.random_test_table values (1);
insert into mysql.random_test_table values (1);
ERROR 42000: INSERT command denied to user 'test_user'@'localhost' for table 'random_test_table'
ERROR 42000: INSERT command denied to user 'test_user'@'localhost' for table 'random_test_table'
drop table mysql.random_test_table;
drop table mysql.random_test_table;
...
...
mysql-test/r/acl_roles_set_role-recursive.result
View file @
8122996a
...
@@ -35,7 +35,13 @@ show grants;
...
@@ -35,7 +35,13 @@ show grants;
Grants for test_user@localhost
Grants for test_user@localhost
GRANT USAGE ON *.* TO 'test_user'@'localhost'
GRANT USAGE ON *.* TO 'test_user'@'localhost'
GRANT test_role1 TO 'test_user'@'localhost'
GRANT test_role1 TO 'test_user'@'localhost'
select current_user(), current_role();
current_user() current_role()
test_user@localhost NONE
set role test_role1;
set role test_role1;
select current_user(), current_role();
current_user() current_role()
test_user@localhost test_role1
show grants;
show grants;
Grants for test_user@localhost
Grants for test_user@localhost
GRANT SELECT ON *.* TO 'test_role2'
GRANT SELECT ON *.* TO 'test_role2'
...
@@ -54,6 +60,9 @@ GRANT USAGE ON *.* TO 'test_user'@'localhost'
...
@@ -54,6 +60,9 @@ GRANT USAGE ON *.* TO 'test_user'@'localhost'
GRANT test_role1 TO 'test_user'@'localhost'
GRANT test_role1 TO 'test_user'@'localhost'
GRANT test_role2 TO 'test_role1'
GRANT test_role2 TO 'test_role1'
set role none;
set role none;
select current_user(), current_role();
current_user() current_role()
test_user@localhost NONE
show grants;
show grants;
Grants for test_user@localhost
Grants for test_user@localhost
GRANT USAGE ON *.* TO 'test_user'@'localhost'
GRANT USAGE ON *.* TO 'test_user'@'localhost'
...
@@ -66,6 +75,9 @@ GRANT USAGE ON *.* TO 'test_user'@'localhost'
...
@@ -66,6 +75,9 @@ GRANT USAGE ON *.* TO 'test_user'@'localhost'
GRANT test_role1 TO 'test_user'@'localhost'
GRANT test_role1 TO 'test_user'@'localhost'
set role test_role2;
set role test_role2;
ERROR HY000: The role 'test_role2' has not been granted or is invalid.
ERROR HY000: The role 'test_role2' has not been granted or is invalid.
select current_user(), current_role();
current_user() current_role()
test_user@localhost NONE
show grants;
show grants;
Grants for test_user@localhost
Grants for test_user@localhost
GRANT USAGE ON *.* TO 'test_user'@'localhost'
GRANT USAGE ON *.* TO 'test_user'@'localhost'
...
@@ -77,6 +89,9 @@ Grants for test_user@localhost
...
@@ -77,6 +89,9 @@ Grants for test_user@localhost
GRANT USAGE ON *.* TO 'test_user'@'localhost'
GRANT USAGE ON *.* TO 'test_user'@'localhost'
GRANT test_role1 TO 'test_user'@'localhost'
GRANT test_role1 TO 'test_user'@'localhost'
set role test_role1;
set role test_role1;
select current_user(), current_role();
current_user() current_role()
test_user@localhost test_role1
show grants;
show grants;
Grants for test_user@localhost
Grants for test_user@localhost
GRANT SELECT ON *.* TO 'test_role2'
GRANT SELECT ON *.* TO 'test_role2'
...
@@ -95,6 +110,9 @@ GRANT USAGE ON *.* TO 'test_user'@'localhost'
...
@@ -95,6 +110,9 @@ GRANT USAGE ON *.* TO 'test_user'@'localhost'
GRANT test_role1 TO 'test_user'@'localhost'
GRANT test_role1 TO 'test_user'@'localhost'
GRANT test_role2 TO 'test_role1'
GRANT test_role2 TO 'test_role1'
set role none;
set role none;
select current_user(), current_role();
current_user() current_role()
test_user@localhost NONE
show grants;
show grants;
Grants for test_user@localhost
Grants for test_user@localhost
GRANT USAGE ON *.* TO 'test_user'@'localhost'
GRANT USAGE ON *.* TO 'test_user'@'localhost'
...
...
mysql-test/r/acl_roles_set_role-routine-simple.result
View file @
8122996a
...
@@ -40,7 +40,13 @@ GRANT test_role1 TO 'test_user'@'localhost'
...
@@ -40,7 +40,13 @@ GRANT test_role1 TO 'test_user'@'localhost'
GRANT test_role3 TO 'test_user'@'localhost'
GRANT test_role3 TO 'test_user'@'localhost'
use mysql;
use mysql;
ERROR 42000: Access denied for user 'test_user'@'localhost' to database 'mysql'
ERROR 42000: Access denied for user 'test_user'@'localhost' to database 'mysql'
select current_user(), current_role();
current_user() current_role()
test_user@localhost NONE
set role test_role1;
set role test_role1;
select current_user(), current_role();
current_user() current_role()
test_user@localhost test_role1
use mysql;
use mysql;
call test_proc(@a);
call test_proc(@a);
SELECT @a;
SELECT @a;
...
@@ -60,6 +66,9 @@ GRANT test_role1 TO 'test_user'@'localhost'
...
@@ -60,6 +66,9 @@ GRANT test_role1 TO 'test_user'@'localhost'
GRANT test_role2 TO 'test_role1'
GRANT test_role2 TO 'test_role1'
GRANT test_role3 TO 'test_user'@'localhost'
GRANT test_role3 TO 'test_user'@'localhost'
set role none;
set role none;
select current_user(), current_role();
current_user() current_role()
test_user@localhost NONE
show grants;
show grants;
Grants for test_user@localhost
Grants for test_user@localhost
GRANT USAGE ON *.* TO 'test_user'@'localhost'
GRANT USAGE ON *.* TO 'test_user'@'localhost'
...
@@ -70,6 +79,9 @@ ERROR 42000: execute command denied to user 'test_user'@'localhost' for routine
...
@@ -70,6 +79,9 @@ ERROR 42000: execute command denied to user 'test_user'@'localhost' for routine
SELECT test_func('AABBCCDD');
SELECT test_func('AABBCCDD');
ERROR 42000: execute command denied to user 'test_user'@'localhost' for routine 'mysql.test_func'
ERROR 42000: execute command denied to user 'test_user'@'localhost' for routine 'mysql.test_func'
set role test_role3;
set role test_role3;
select current_user(), current_role();
current_user() current_role()
test_user@localhost test_role3
show grants;
show grants;
Grants for test_user@localhost
Grants for test_user@localhost
GRANT EXECUTE ON `mysql`.* TO 'test_role3'
GRANT EXECUTE ON `mysql`.* TO 'test_role3'
...
@@ -91,10 +103,7 @@ revoke execute on mysql.* from test_role3@'';
...
@@ -91,10 +103,7 @@ revoke execute on mysql.* from test_role3@'';
delete from mysql.user where user like'test_%';
delete from mysql.user where user like'test_%';
delete from mysql.roles_mapping where RoleFk like 'test%';
delete from mysql.roles_mapping where RoleFk like 'test%';
drop function mysql.test_func;
drop function mysql.test_func;
Warnings:
Warning 1403 There is no such grant defined for user 'test_role1' on host '' on routine 'test_func'
drop procedure mysql.test_proc;
drop procedure mysql.test_proc;
Warnings:
Warnings:
Warning 1403 There is no such grant defined for user 'test_role1' on host '' on routine 'test_proc'
Warning 1403 There is no such grant defined for user 'test_role1' on host '' on routine 'test_proc'
Warning 1403 There is no such grant defined for user 'test_role1' on host '' on routine 'test_proc'
flush privileges;
flush privileges;
mysql-test/r/acl_roles_set_role-simple.result
View file @
8122996a
...
@@ -22,7 +22,13 @@ show grants;
...
@@ -22,7 +22,13 @@ show grants;
Grants for test_user@localhost
Grants for test_user@localhost
GRANT USAGE ON *.* TO 'test_user'@'localhost'
GRANT USAGE ON *.* TO 'test_user'@'localhost'
GRANT test_role1 TO 'test_user'@'localhost'
GRANT test_role1 TO 'test_user'@'localhost'
select current_user(), current_role();
current_user() current_role()
test_user@localhost NONE
set role test_role1;
set role test_role1;
select current_user(), current_role();
current_user() current_role()
test_user@localhost test_role1
show grants;
show grants;
Grants for test_user@localhost
Grants for test_user@localhost
GRANT SELECT ON *.* TO 'test_role1'
GRANT SELECT ON *.* TO 'test_role1'
...
@@ -32,6 +38,9 @@ select * from mysql.roles_mapping;
...
@@ -32,6 +38,9 @@ select * from mysql.roles_mapping;
HostFk UserFk RoleFk
HostFk UserFk RoleFk
localhost test_user test_role1
localhost test_user test_role1
set role none;
set role none;
select current_user(), current_role();
current_user() current_role()
test_user@localhost NONE
select * from mysql.roles_mapping;
select * from mysql.roles_mapping;
ERROR 42000: SELECT command denied to user 'test_user'@'localhost' for table '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.user where user='test_role1';
...
...
mysql-test/r/acl_roles_set_role-table-column-priv.result
View file @
8122996a
...
@@ -24,7 +24,13 @@ show grants;
...
@@ -24,7 +24,13 @@ show grants;
Grants for test_user@localhost
Grants for test_user@localhost
GRANT USAGE ON *.* TO 'test_user'@'localhost'
GRANT USAGE ON *.* TO 'test_user'@'localhost'
GRANT test_role1 TO 'test_user'@'localhost'
GRANT test_role1 TO 'test_user'@'localhost'
select current_user(), current_role();
current_user() current_role()
test_user@localhost NONE
set role test_role1;
set role test_role1;
select current_user(), current_role();
current_user() current_role()
test_user@localhost test_role1
show grants;
show grants;
Grants for test_user@localhost
Grants for test_user@localhost
GRANT SELECT (RoleFk) ON `mysql`.`roles_mapping` TO 'test_role2'
GRANT SELECT (RoleFk) ON `mysql`.`roles_mapping` TO 'test_role2'
...
@@ -49,6 +55,9 @@ GRANT test_role1 TO 'test_user'@'localhost'
...
@@ -49,6 +55,9 @@ GRANT test_role1 TO 'test_user'@'localhost'
GRANT test_role2 TO 'test_role1'
GRANT test_role2 TO 'test_role1'
use mysql;
use mysql;
set role none;
set role none;
select current_user(), current_role();
current_user() current_role()
test_user@localhost NONE
select RoleFk from mysql.roles_mapping;
select RoleFk from mysql.roles_mapping;
ERROR 42000: SELECT command denied to user 'test_user'@'localhost' for table 'roles_mapping'
ERROR 42000: SELECT command denied to user 'test_user'@'localhost' for table 'roles_mapping'
drop user 'test_user'@'localhost';
drop user 'test_user'@'localhost';
...
...
mysql-test/r/acl_roles_set_role-table-simple.result
View file @
8122996a
...
@@ -24,7 +24,13 @@ show grants;
...
@@ -24,7 +24,13 @@ show grants;
Grants for test_user@localhost
Grants for test_user@localhost
GRANT USAGE ON *.* TO 'test_user'@'localhost'
GRANT USAGE ON *.* TO 'test_user'@'localhost'
GRANT test_role1 TO 'test_user'@'localhost'
GRANT test_role1 TO 'test_user'@'localhost'
select current_user(), current_role();
current_user() current_role()
test_user@localhost NONE
set role test_role1;
set role test_role1;
select current_user(), current_role();
current_user() current_role()
test_user@localhost test_role1
show grants;
show grants;
Grants for test_user@localhost
Grants for test_user@localhost
GRANT SELECT ON `mysql`.`roles_mapping` TO 'test_role2'
GRANT SELECT ON `mysql`.`roles_mapping` TO 'test_role2'
...
@@ -47,6 +53,9 @@ GRANT test_role1 TO 'test_user'@'localhost'
...
@@ -47,6 +53,9 @@ GRANT test_role1 TO 'test_user'@'localhost'
GRANT test_role2 TO 'test_role1'
GRANT test_role2 TO 'test_role1'
use mysql;
use mysql;
set role none;
set role none;
select current_user(), current_role();
current_user() current_role()
test_user@localhost NONE
select * from mysql.roles_mapping;
select * from mysql.roles_mapping;
ERROR 42000: SELECT command denied to user 'test_user'@'localhost' for table 'roles_mapping'
ERROR 42000: SELECT command denied to user 'test_user'@'localhost' for table 'roles_mapping'
drop user 'test_user'@'localhost';
drop user 'test_user'@'localhost';
...
...
mysql-test/r/acl_roles_show_grants.result
View file @
8122996a
...
@@ -34,7 +34,13 @@ Grants for test_user@localhost
...
@@ -34,7 +34,13 @@ Grants for test_user@localhost
GRANT USAGE ON *.* TO 'test_user'@'localhost'
GRANT USAGE ON *.* TO 'test_user'@'localhost'
GRANT test_role1 TO 'test_user'@'localhost'
GRANT test_role1 TO 'test_user'@'localhost'
GRANT test_role2 TO 'test_user'@'localhost'
GRANT test_role2 TO 'test_user'@'localhost'
select current_user(), current_role();
current_user() current_role()
test_user@localhost NONE
set role test_role1;
set role test_role1;
select current_user(), current_role();
current_user() current_role()
test_user@localhost test_role1
show grants;
show grants;
Grants for test_user@localhost
Grants for test_user@localhost
GRANT SELECT ON `mysql`.* TO 'test_role2'
GRANT SELECT ON `mysql`.* TO 'test_role2'
...
@@ -45,6 +51,9 @@ GRANT test_role1 TO 'test_user'@'localhost'
...
@@ -45,6 +51,9 @@ GRANT test_role1 TO 'test_user'@'localhost'
GRANT test_role2 TO 'test_role1'
GRANT test_role2 TO 'test_role1'
GRANT test_role2 TO 'test_user'@'localhost'
GRANT test_role2 TO 'test_user'@'localhost'
set role none;
set role none;
select current_user(), current_role();
current_user() current_role()
test_user@localhost NONE
show grants;
show grants;
Grants for test_user@localhost
Grants for test_user@localhost
GRANT USAGE ON *.* TO 'test_user'@'localhost'
GRANT USAGE ON *.* TO 'test_user'@'localhost'
...
@@ -71,6 +80,9 @@ ERROR 42000: There is no such grant defined for user 'test_user' on host 'localh
...
@@ -71,6 +80,9 @@ ERROR 42000: There is no such grant defined for user 'test_user' on host 'localh
show grants for CURRENT_ROLE();
show grants for CURRENT_ROLE();
ERROR 42000: There is no such grant defined for user 'test_user' on host 'localhost'
ERROR 42000: There is no such grant defined for user 'test_user' on host 'localhost'
set role test_role2;
set role test_role2;
select current_user(), current_role();
current_user() current_role()
test_user@localhost test_role2
show grants;
show grants;
Grants for test_user@localhost
Grants for test_user@localhost
GRANT SELECT ON `mysql`.* TO 'test_role2'
GRANT SELECT ON `mysql`.* TO 'test_role2'
...
...
mysql-test/t/acl_roles_set_role-database-recursive.test
View file @
8122996a
...
@@ -31,13 +31,17 @@ change_user 'test_user';
...
@@ -31,13 +31,17 @@ change_user 'test_user';
--
error
ER_TABLEACCESS_DENIED_ERROR
--
error
ER_TABLEACCESS_DENIED_ERROR
select
*
from
mysql
.
roles_mapping
;
select
*
from
mysql
.
roles_mapping
;
select
current_user
(),
current_role
();
set
role
test_role1
;
set
role
test_role1
;
select
current_user
(),
current_role
();
--
sorted_result
--
sorted_result
select
*
from
mysql
.
roles_mapping
;
select
*
from
mysql
.
roles_mapping
;
set
role
none
;
set
role
none
;
select
current_user
(),
current_role
();
--
error
ER_TABLEACCESS_DENIED_ERROR
--
error
ER_TABLEACCESS_DENIED_ERROR
select
*
from
mysql
.
roles_mapping
;
select
*
from
mysql
.
roles_mapping
;
set
role
test_role2
;
set
role
test_role2
;
select
current_user
(),
current_role
();
--
sorted_result
--
sorted_result
select
*
from
mysql
.
roles_mapping
;
select
*
from
mysql
.
roles_mapping
;
...
...
mysql-test/t/acl_roles_set_role-database-simple.test
View file @
8122996a
...
@@ -22,7 +22,9 @@ change_user 'test_user';
...
@@ -22,7 +22,9 @@ change_user 'test_user';
--
error
ER_TABLEACCESS_DENIED_ERROR
--
error
ER_TABLEACCESS_DENIED_ERROR
select
*
from
mysql
.
roles_mapping
;
select
*
from
mysql
.
roles_mapping
;
select
current_user
(),
current_role
();
set
role
test_role1
;
set
role
test_role1
;
select
current_user
(),
current_role
();
select
*
from
mysql
.
roles_mapping
;
select
*
from
mysql
.
roles_mapping
;
--
error
ER_TABLEACCESS_DENIED_ERROR
--
error
ER_TABLEACCESS_DENIED_ERROR
insert
into
mysql
.
user
(
user
,
host
)
values
(
'Dummy'
,
'Dummy'
);
insert
into
mysql
.
user
(
user
,
host
)
values
(
'Dummy'
,
'Dummy'
);
...
@@ -34,6 +36,7 @@ delete from mysql.roles_mapping where RoleFk='test_role2';
...
@@ -34,6 +36,7 @@ delete from mysql.roles_mapping where RoleFk='test_role2';
use
mysql
;
use
mysql
;
set
role
none
;
set
role
none
;
select
current_user
(),
current_role
();
--
error
ER_DBACCESS_DENIED_ERROR
--
error
ER_DBACCESS_DENIED_ERROR
use
mysql
;
use
mysql
;
...
...
mysql-test/t/acl_roles_set_role-multiple-role.test
View file @
8122996a
...
@@ -59,13 +59,16 @@ select * from mysql.roles_mapping;
...
@@ -59,13 +59,16 @@ select * from mysql.roles_mapping;
--
sorted_result
--
sorted_result
show
grants
;
show
grants
;
select
current_user
(),
current_role
();
set
role
r_sel
;
set
role
r_sel
;
select
current_user
(),
current_role
();
--
sorted_result
--
sorted_result
show
grants
;
show
grants
;
--
sorted_result
--
sorted_result
select
*
from
mysql
.
roles_mapping
;
select
*
from
mysql
.
roles_mapping
;
set
role
r_ins
;
set
role
r_ins
;
select
current_user
(),
current_role
();
--
sorted_result
--
sorted_result
show
grants
;
show
grants
;
--
error
ER_TABLEACCESS_DENIED_ERROR
--
error
ER_TABLEACCESS_DENIED_ERROR
...
@@ -76,14 +79,18 @@ insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('',
...
@@ -76,14 +79,18 @@ insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('',
--
error
ER_SPECIFIC_ACCESS_DENIED_ERROR
--
error
ER_SPECIFIC_ACCESS_DENIED_ERROR
flush
privileges
;
flush
privileges
;
set
role
r_rld
;
set
role
r_rld
;
select
current_user
(),
current_role
();
flush
privileges
;
flush
privileges
;
set
role
r_sel
;
set
role
r_sel
;
select
current_user
(),
current_role
();
flush
privileges
;
flush
privileges
;
set
role
none
;
set
role
none
;
select
current_user
(),
current_role
();
--
error
ER_SPECIFIC_ACCESS_DENIED_ERROR
--
error
ER_SPECIFIC_ACCESS_DENIED_ERROR
flush
privileges
;
flush
privileges
;
set
role
r_ins
;
set
role
r_ins
;
select
current_user
(),
current_role
();
insert
into
mysql
.
roles_mapping
(
HostFk
,
UserFk
,
RoleFk
)
values
(
''
,
insert
into
mysql
.
roles_mapping
(
HostFk
,
UserFk
,
RoleFk
)
values
(
''
,
'r_sel'
,
'r_sel'
,
'r_upd'
);
'r_upd'
);
...
@@ -100,11 +107,14 @@ insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('',
...
@@ -100,11 +107,14 @@ insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('',
'r_del'
,
'r_del'
,
'r_ins'
);
'r_ins'
);
set
role
r_rld
;
set
role
r_rld
;
select
current_user
(),
current_role
();
flush
privileges
;
flush
privileges
;
set
role
r_sel
;
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
RoleFk
=
'r_ins'
where
RoleFk
=
'r_ins_wrong'
;
flush
privileges
;
flush
privileges
;
set
role
r_sel
;
set
role
r_sel
;
select
current_user
(),
current_role
();
create
table
mysql
.
random_test_table
(
id
INT
);
create
table
mysql
.
random_test_table
(
id
INT
);
insert
into
mysql
.
random_test_table
values
(
1
);
insert
into
mysql
.
random_test_table
values
(
1
);
...
@@ -113,6 +123,7 @@ select * from mysql.random_test_table;
...
@@ -113,6 +123,7 @@ select * from mysql.random_test_table;
delete
from
mysql
.
roles_mapping
where
RoleFk
=
'r_ins'
;
delete
from
mysql
.
roles_mapping
where
RoleFk
=
'r_ins'
;
flush
privileges
;
flush
privileges
;
set
role
r_sel
;
set
role
r_sel
;
select
current_user
(),
current_role
();
--
error
ER_TABLEACCESS_DENIED_ERROR
--
error
ER_TABLEACCESS_DENIED_ERROR
insert
into
mysql
.
random_test_table
values
(
1
);
insert
into
mysql
.
random_test_table
values
(
1
);
drop
table
mysql
.
random_test_table
;
drop
table
mysql
.
random_test_table
;
...
...
mysql-test/t/acl_roles_set_role-recursive.test
View file @
8122996a
...
@@ -35,7 +35,9 @@ select * from mysql.roles_mapping;
...
@@ -35,7 +35,9 @@ select * from mysql.roles_mapping;
--
sorted_result
--
sorted_result
show
grants
;
show
grants
;
select
current_user
(),
current_role
();
set
role
test_role1
;
set
role
test_role1
;
select
current_user
(),
current_role
();
--
sorted_result
--
sorted_result
show
grants
;
show
grants
;
select
*
from
mysql
.
roles_mapping
where
HostFk
=
''
;
select
*
from
mysql
.
roles_mapping
where
HostFk
=
''
;
...
@@ -43,6 +45,7 @@ select * from mysql.roles_mapping where HostFk='';
...
@@ -43,6 +45,7 @@ select * from mysql.roles_mapping where HostFk='';
--
sorted_result
--
sorted_result
show
grants
;
show
grants
;
set
role
none
;
set
role
none
;
select
current_user
(),
current_role
();
--
sorted_result
--
sorted_result
show
grants
;
show
grants
;
--
error
ER_TABLEACCESS_DENIED_ERROR
--
error
ER_TABLEACCESS_DENIED_ERROR
...
@@ -52,6 +55,7 @@ select * from mysql.roles_mapping;
...
@@ -52,6 +55,7 @@ select * from mysql.roles_mapping;
show
grants
;
show
grants
;
--
error
ER_INVALID_ROLE
--
error
ER_INVALID_ROLE
set
role
test_role2
;
set
role
test_role2
;
select
current_user
(),
current_role
();
--
sorted_result
--
sorted_result
show
grants
;
show
grants
;
--
error
ER_TABLEACCESS_DENIED_ERROR
--
error
ER_TABLEACCESS_DENIED_ERROR
...
@@ -61,6 +65,7 @@ select * from mysql.roles_mapping;
...
@@ -61,6 +65,7 @@ select * from mysql.roles_mapping;
--
sorted_result
--
sorted_result
show
grants
;
show
grants
;
set
role
test_role1
;
set
role
test_role1
;
select
current_user
(),
current_role
();
--
sorted_result
--
sorted_result
show
grants
;
show
grants
;
--
sorted_result
--
sorted_result
...
@@ -69,6 +74,7 @@ select * from mysql.roles_mapping where HostFk='';
...
@@ -69,6 +74,7 @@ select * from mysql.roles_mapping where HostFk='';
--
sorted_result
--
sorted_result
show
grants
;
show
grants
;
set
role
none
;
set
role
none
;
select
current_user
(),
current_role
();
--
sorted_result
--
sorted_result
show
grants
;
show
grants
;
--
error
ER_TABLEACCESS_DENIED_ERROR
--
error
ER_TABLEACCESS_DENIED_ERROR
...
...
mysql-test/t/acl_roles_set_role-routine-simple.test
View file @
8122996a
...
@@ -44,7 +44,9 @@ show grants;
...
@@ -44,7 +44,9 @@ show grants;
--
error
ER_DBACCESS_DENIED_ERROR
--
error
ER_DBACCESS_DENIED_ERROR
use
mysql
;
use
mysql
;
select
current_user
(),
current_role
();
set
role
test_role1
;
set
role
test_role1
;
select
current_user
(),
current_role
();
use
mysql
;
use
mysql
;
call
test_proc
(
@
a
);
call
test_proc
(
@
a
);
...
@@ -55,6 +57,7 @@ SELECT test_func('AABBCCDD');
...
@@ -55,6 +57,7 @@ SELECT test_func('AABBCCDD');
--
sorted_result
--
sorted_result
show
grants
;
show
grants
;
set
role
none
;
set
role
none
;
select
current_user
(),
current_role
();
--
sorted_result
--
sorted_result
show
grants
;
show
grants
;
...
@@ -65,6 +68,7 @@ call test_proc(@a);
...
@@ -65,6 +68,7 @@ call test_proc(@a);
SELECT
test_func
(
'AABBCCDD'
);
SELECT
test_func
(
'AABBCCDD'
);
set
role
test_role3
;
set
role
test_role3
;
select
current_user
(),
current_role
();
--
sorted_result
--
sorted_result
show
grants
;
show
grants
;
call
test_proc
(
@
a
);
call
test_proc
(
@
a
);
...
...
mysql-test/t/acl_roles_set_role-simple.test
View file @
8122996a
...
@@ -23,13 +23,16 @@ select * from mysql.roles_mapping;
...
@@ -23,13 +23,16 @@ select * from mysql.roles_mapping;
--
sorted_result
--
sorted_result
show
grants
;
show
grants
;
select
current_user
(),
current_role
();
set
role
test_role1
;
set
role
test_role1
;
select
current_user
(),
current_role
();
--
sorted_result
--
sorted_result
show
grants
;
show
grants
;
--
sorted_result
--
sorted_result
select
*
from
mysql
.
roles_mapping
;
select
*
from
mysql
.
roles_mapping
;
set
role
none
;
set
role
none
;
select
current_user
(),
current_role
();
--
error
ER_TABLEACCESS_DENIED_ERROR
--
error
ER_TABLEACCESS_DENIED_ERROR
select
*
from
mysql
.
roles_mapping
;
select
*
from
mysql
.
roles_mapping
;
...
...
mysql-test/t/acl_roles_set_role-table-column-priv.test
View file @
8122996a
...
@@ -25,7 +25,9 @@ select * from mysql.roles_mapping;
...
@@ -25,7 +25,9 @@ select * from mysql.roles_mapping;
--
sorted_result
--
sorted_result
show
grants
;
show
grants
;
select
current_user
(),
current_role
();
set
role
test_role1
;
set
role
test_role1
;
select
current_user
(),
current_role
();
--
sorted_result
--
sorted_result
show
grants
;
show
grants
;
...
@@ -42,6 +44,7 @@ show grants;
...
@@ -42,6 +44,7 @@ show grants;
use
mysql
;
use
mysql
;
set
role
none
;
set
role
none
;
select
current_user
(),
current_role
();
--
sorted_result
--
sorted_result
--
error
ER_TABLEACCESS_DENIED_ERROR
--
error
ER_TABLEACCESS_DENIED_ERROR
...
...
mysql-test/t/acl_roles_set_role-table-simple.test
View file @
8122996a
...
@@ -25,7 +25,9 @@ select * from mysql.roles_mapping;
...
@@ -25,7 +25,9 @@ select * from mysql.roles_mapping;
--
sorted_result
--
sorted_result
show
grants
;
show
grants
;
select
current_user
(),
current_role
();
set
role
test_role1
;
set
role
test_role1
;
select
current_user
(),
current_role
();
--
sorted_result
--
sorted_result
show
grants
;
show
grants
;
...
@@ -39,6 +41,7 @@ show grants;
...
@@ -39,6 +41,7 @@ show grants;
use
mysql
;
use
mysql
;
set
role
none
;
set
role
none
;
select
current_user
(),
current_role
();
--
sorted_result
--
sorted_result
--
error
ER_TABLEACCESS_DENIED_ERROR
--
error
ER_TABLEACCESS_DENIED_ERROR
...
...
mysql-test/t/acl_roles_show_grants.test
View file @
8122996a
...
@@ -30,10 +30,13 @@ change_user 'test_user';
...
@@ -30,10 +30,13 @@ change_user 'test_user';
--
sorted_result
--
sorted_result
show
grants
;
show
grants
;
select
current_user
(),
current_role
();
set
role
test_role1
;
set
role
test_role1
;
select
current_user
(),
current_role
();
--
sorted_result
--
sorted_result
show
grants
;
show
grants
;
set
role
none
;
set
role
none
;
select
current_user
(),
current_role
();
--
sorted_result
--
sorted_result
show
grants
;
show
grants
;
...
@@ -53,6 +56,7 @@ show grants for CURRENT_ROLE;
...
@@ -53,6 +56,7 @@ show grants for CURRENT_ROLE;
show
grants
for
CURRENT_ROLE
();
show
grants
for
CURRENT_ROLE
();
set
role
test_role2
;
set
role
test_role2
;
select
current_user
(),
current_role
();
--
sorted_result
--
sorted_result
show
grants
;
show
grants
;
--
sorted_result
--
sorted_result
...
...
sql/item_strfunc.cc
View file @
8122996a
...
@@ -2332,16 +2332,28 @@ bool Item_func_current_user::fix_fields(THD *thd, Item **ref)
...
@@ -2332,16 +2332,28 @@ bool Item_func_current_user::fix_fields(THD *thd, Item **ref)
if
(
Item_func_sysconst
::
fix_fields
(
thd
,
ref
))
if
(
Item_func_sysconst
::
fix_fields
(
thd
,
ref
))
return
TRUE
;
return
TRUE
;
Security_context
*
ctx
=
Security_context
*
ctx
=
context
->
security_ctx
#ifndef NO_EMBEDDED_ACCESS_CHECKS
?
context
->
security_ctx
:
thd
->
security_ctx
;
(
context
->
security_ctx
?
context
->
security_ctx
:
thd
->
security_ctx
);
#else
thd
->
security_ctx
;
#endif
/*NO_EMBEDDED_ACCESS_CHECKS*/
return
init
(
ctx
->
priv_user
,
ctx
->
priv_host
);
return
init
(
ctx
->
priv_user
,
ctx
->
priv_host
);
}
}
bool
Item_func_current_role
::
fix_fields
(
THD
*
thd
,
Item
**
ref
)
{
if
(
Item_func_sysconst
::
fix_fields
(
thd
,
ref
))
return
1
;
Security_context
*
ctx
=
context
->
security_ctx
?
context
->
security_ctx
:
thd
->
security_ctx
;
const
char
*
role
=
ctx
->
priv_role
[
0
]
?
ctx
->
priv_role
:
NONE_ROLE
;
if
(
str_value
.
copy
(
role
,
strlen
(
role
),
system_charset_info
))
return
1
;
str_value
.
mark_as_const
();
return
0
;
}
void
Item_func_soundex
::
fix_length_and_dec
()
void
Item_func_soundex
::
fix_length_and_dec
()
{
{
...
...
sql/item_strfunc.h
View file @
8122996a
...
@@ -580,6 +580,28 @@ public:
...
@@ -580,6 +580,28 @@ public:
};
};
class
Item_func_current_role
:
public
Item_func_sysconst
{
Name_resolution_context
*
context
;
public:
Item_func_current_role
(
Name_resolution_context
*
context_arg
)
:
context
(
context_arg
)
{}
bool
fix_fields
(
THD
*
thd
,
Item
**
ref
);
void
fix_length_and_dec
()
{
max_length
=
username_char_length
*
SYSTEM_CHARSET_MBMAXLEN
;
}
int
save_in_field
(
Field
*
field
,
bool
no_conversions
)
{
return
save_str_value_in_field
(
field
,
&
str_value
);
}
const
char
*
func_name
()
const
{
return
"current_role"
;
}
const
char
*
fully_qualified_func_name
()
const
{
return
"current_role()"
;
}
String
*
val_str
(
String
*
)
{
DBUG_ASSERT
(
fixed
==
1
);
return
(
null_value
?
0
:
&
str_value
);
}
};
class
Item_func_soundex
:
public
Item_str_func
class
Item_func_soundex
:
public
Item_str_func
{
{
String
tmp_value
;
String
tmp_value
;
...
...
sql/sql_yacc.yy
View file @
8122996a
...
@@ -8648,6 +8648,14 @@ function_call_keyword:
...
@@ -8648,6 +8648,14 @@ function_call_keyword:
Lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
Lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
Lex->safe_to_cache_query= 0;
Lex->safe_to_cache_query= 0;
}
}
| CURRENT_ROLE optional_braces
{
$$= new (thd->mem_root) Item_func_current_role(Lex->current_context());
if ($$ == NULL)
MYSQL_YYABORT;
Lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
Lex->safe_to_cache_query= 0;
}
| DATE_SYM '(' expr ')'
| DATE_SYM '(' expr ')'
{
{
$$= new (thd->mem_root) Item_date_typecast($3);
$$= new (thd->mem_root) Item_date_typecast($3);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment