Commit 89939843 authored by Sergei Golubchik's avatar Sergei Golubchik

CURRENT_ROLE() should return NULL, not "NONE"

parent 97c39894
...@@ -31,7 +31,7 @@ select * from mysql.roles_mapping; ...@@ -31,7 +31,7 @@ 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(); select current_user(), current_role();
current_user() current_role() current_user() current_role()
test_user@localhost NONE test_user@localhost NULL
set role test_role1; set role test_role1;
select current_user(), current_role(); select current_user(), current_role();
current_user() current_role() current_user() current_role()
...@@ -44,7 +44,7 @@ localhost test_user test_role2 ...@@ -44,7 +44,7 @@ localhost test_user test_role2
set role none; set role none;
select current_user(), current_role(); select current_user(), current_role();
current_user() current_role() current_user() current_role()
test_user@localhost NONE test_user@localhost NULL
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;
......
...@@ -18,7 +18,7 @@ select * from mysql.roles_mapping; ...@@ -18,7 +18,7 @@ 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(); select current_user(), current_role();
current_user() current_role() current_user() current_role()
test_user@localhost NONE test_user@localhost NULL
set role test_role1; set role test_role1;
select current_user(), current_role(); select current_user(), current_role();
current_user() current_role() current_user() current_role()
...@@ -36,7 +36,7 @@ use mysql; ...@@ -36,7 +36,7 @@ use mysql;
set role none; set role none;
select current_user(), current_role(); select current_user(), current_role();
current_user() current_role() current_user() current_role()
test_user@localhost NONE test_user@localhost NULL
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;
......
...@@ -71,7 +71,7 @@ GRANT r_sel TO 'test_user'@'localhost' ...@@ -71,7 +71,7 @@ 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(); select current_user(), current_role();
current_user() current_role() current_user() current_role()
test_user@localhost NONE test_user@localhost NULL
set role r_sel; set role r_sel;
select current_user(), current_role(); select current_user(), current_role();
current_user() current_role() current_user() current_role()
...@@ -131,7 +131,7 @@ flush privileges; ...@@ -131,7 +131,7 @@ flush privileges;
set role none; set role none;
select current_user(), current_role(); select current_user(), current_role();
current_user() current_role() current_user() current_role()
test_user@localhost NONE test_user@localhost NULL
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;
......
...@@ -37,7 +37,7 @@ GRANT USAGE ON *.* TO 'test_user'@'localhost' ...@@ -37,7 +37,7 @@ 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(); select current_user(), current_role();
current_user() current_role() current_user() current_role()
test_user@localhost NONE test_user@localhost NULL
set role test_role1; set role test_role1;
select current_user(), current_role(); select current_user(), current_role();
current_user() current_role() current_user() current_role()
...@@ -62,7 +62,7 @@ GRANT test_role2 TO 'test_role1' ...@@ -62,7 +62,7 @@ GRANT test_role2 TO 'test_role1'
set role none; set role none;
select current_user(), current_role(); select current_user(), current_role();
current_user() current_role() current_user() current_role()
test_user@localhost NONE test_user@localhost NULL
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,7 +77,7 @@ set role test_role2; ...@@ -77,7 +77,7 @@ 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(); select current_user(), current_role();
current_user() current_role() current_user() current_role()
test_user@localhost NONE test_user@localhost NULL
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'
...@@ -112,7 +112,7 @@ GRANT test_role2 TO 'test_role1' ...@@ -112,7 +112,7 @@ GRANT test_role2 TO 'test_role1'
set role none; set role none;
select current_user(), current_role(); select current_user(), current_role();
current_user() current_role() current_user() current_role()
test_user@localhost NONE test_user@localhost NULL
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'
......
...@@ -42,7 +42,7 @@ use mysql; ...@@ -42,7 +42,7 @@ 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(); select current_user(), current_role();
current_user() current_role() current_user() current_role()
test_user@localhost NONE test_user@localhost NULL
set role test_role1; set role test_role1;
select current_user(), current_role(); select current_user(), current_role();
current_user() current_role() current_user() current_role()
...@@ -68,7 +68,7 @@ GRANT test_role3 TO 'test_user'@'localhost' ...@@ -68,7 +68,7 @@ GRANT test_role3 TO 'test_user'@'localhost'
set role none; set role none;
select current_user(), current_role(); select current_user(), current_role();
current_user() current_role() current_user() current_role()
test_user@localhost NONE test_user@localhost NULL
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'
......
...@@ -24,7 +24,7 @@ GRANT USAGE ON *.* TO 'test_user'@'localhost' ...@@ -24,7 +24,7 @@ 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(); select current_user(), current_role();
current_user() current_role() current_user() current_role()
test_user@localhost NONE test_user@localhost NULL
set role test_role1; set role test_role1;
select current_user(), current_role(); select current_user(), current_role();
current_user() current_role() current_user() current_role()
...@@ -40,7 +40,7 @@ localhost test_user test_role1 ...@@ -40,7 +40,7 @@ localhost test_user test_role1
set role none; set role none;
select current_user(), current_role(); select current_user(), current_role();
current_user() current_role() current_user() current_role()
test_user@localhost NONE test_user@localhost NULL
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';
......
...@@ -26,7 +26,7 @@ GRANT USAGE ON *.* TO 'test_user'@'localhost' ...@@ -26,7 +26,7 @@ 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(); select current_user(), current_role();
current_user() current_role() current_user() current_role()
test_user@localhost NONE test_user@localhost NULL
set role test_role1; set role test_role1;
select current_user(), current_role(); select current_user(), current_role();
current_user() current_role() current_user() current_role()
...@@ -57,7 +57,7 @@ use mysql; ...@@ -57,7 +57,7 @@ use mysql;
set role none; set role none;
select current_user(), current_role(); select current_user(), current_role();
current_user() current_role() current_user() current_role()
test_user@localhost NONE test_user@localhost NULL
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';
......
...@@ -26,7 +26,7 @@ GRANT USAGE ON *.* TO 'test_user'@'localhost' ...@@ -26,7 +26,7 @@ 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(); select current_user(), current_role();
current_user() current_role() current_user() current_role()
test_user@localhost NONE test_user@localhost NULL
set role test_role1; set role test_role1;
select current_user(), current_role(); select current_user(), current_role();
current_user() current_role() current_user() current_role()
...@@ -55,7 +55,7 @@ use mysql; ...@@ -55,7 +55,7 @@ use mysql;
set role none; set role none;
select current_user(), current_role(); select current_user(), current_role();
current_user() current_role() current_user() current_role()
test_user@localhost NONE test_user@localhost NULL
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';
......
...@@ -34,7 +34,7 @@ GRANT test_role1 TO 'test_user'@'localhost' ...@@ -34,7 +34,7 @@ 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(); select current_user(), current_role();
current_user() current_role() current_user() current_role()
test_user@localhost NONE test_user@localhost NULL
set role test_role1; set role test_role1;
select current_user(), current_role(); select current_user(), current_role();
current_user() current_role() current_user() current_role()
...@@ -51,7 +51,7 @@ GRANT test_role2 TO 'test_user'@'localhost' ...@@ -51,7 +51,7 @@ GRANT test_role2 TO 'test_user'@'localhost'
set role none; set role none;
select current_user(), current_role(); select current_user(), current_role();
current_user() current_role() current_user() current_role()
test_user@localhost NONE test_user@localhost NULL
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'
......
...@@ -2345,20 +2345,17 @@ bool Item_func_current_role::fix_fields(THD *thd, Item **ref) ...@@ -2345,20 +2345,17 @@ bool Item_func_current_role::fix_fields(THD *thd, Item **ref)
Security_context *ctx= context->security_ctx Security_context *ctx= context->security_ctx
? context->security_ctx : thd->security_ctx; ? context->security_ctx : thd->security_ctx;
LEX_STRING role;
if (ctx->priv_role[0]) if (ctx->priv_role[0])
{ {
role.str= ctx->priv_role; if (str_value.copy(ctx->priv_role, strlen(ctx->priv_role),
role.length= strlen(role.str); system_charset_info))
}
else
role= none_role;
if (str_value.copy(role.str, role.length, system_charset_info))
return 1; return 1;
str_value.mark_as_const(); str_value.mark_as_const();
return 0; return 0;
}
null_value= maybe_null= 1;
return 0;
} }
......
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