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;
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
test_user@localhost NULL
set role test_role1;
select current_user(), current_role();
current_user() current_role()
......@@ -44,7 +44,7 @@ localhost test_user test_role2
set role none;
select current_user(), current_role();
current_user() current_role()
test_user@localhost NONE
test_user@localhost NULL
select * from mysql.roles_mapping;
ERROR 42000: SELECT command denied to user 'test_user'@'localhost' for table 'roles_mapping'
set role test_role2;
......
......@@ -18,7 +18,7 @@ select * from mysql.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
test_user@localhost NULL
set role test_role1;
select current_user(), current_role();
current_user() current_role()
......@@ -36,7 +36,7 @@ use mysql;
set role none;
select current_user(), current_role();
current_user() current_role()
test_user@localhost NONE
test_user@localhost NULL
use mysql;
ERROR 42000: Access denied for user 'test_user'@'localhost' to database 'mysql'
select * from mysql.roles_mapping;
......
......@@ -71,7 +71,7 @@ GRANT r_sel TO 'test_user'@'localhost'
GRANT r_upd TO 'test_user'@'localhost'
select current_user(), current_role();
current_user() current_role()
test_user@localhost NONE
test_user@localhost NULL
set role r_sel;
select current_user(), current_role();
current_user() current_role()
......@@ -131,7 +131,7 @@ flush privileges;
set role none;
select current_user(), current_role();
current_user() current_role()
test_user@localhost NONE
test_user@localhost NULL
flush privileges;
ERROR 42000: Access denied; you need (at least one of) the RELOAD privilege(s) for this operation
set role r_ins;
......
......@@ -37,7 +37,7 @@ GRANT USAGE ON *.* TO 'test_user'@'localhost'
GRANT test_role1 TO 'test_user'@'localhost'
select current_user(), current_role();
current_user() current_role()
test_user@localhost NONE
test_user@localhost NULL
set role test_role1;
select current_user(), current_role();
current_user() current_role()
......@@ -62,7 +62,7 @@ GRANT test_role2 TO 'test_role1'
set role none;
select current_user(), current_role();
current_user() current_role()
test_user@localhost NONE
test_user@localhost NULL
show grants;
Grants for test_user@localhost
GRANT USAGE ON *.* TO 'test_user'@'localhost'
......@@ -77,7 +77,7 @@ set role test_role2;
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
test_user@localhost NULL
show grants;
Grants for test_user@localhost
GRANT USAGE ON *.* TO 'test_user'@'localhost'
......@@ -112,7 +112,7 @@ GRANT test_role2 TO 'test_role1'
set role none;
select current_user(), current_role();
current_user() current_role()
test_user@localhost NONE
test_user@localhost NULL
show grants;
Grants for test_user@localhost
GRANT USAGE ON *.* TO 'test_user'@'localhost'
......
......@@ -42,7 +42,7 @@ use 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
test_user@localhost NULL
set role test_role1;
select current_user(), current_role();
current_user() current_role()
......@@ -68,7 +68,7 @@ GRANT test_role3 TO 'test_user'@'localhost'
set role none;
select current_user(), current_role();
current_user() current_role()
test_user@localhost NONE
test_user@localhost NULL
show grants;
Grants for test_user@localhost
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'
select current_user(), current_role();
current_user() current_role()
test_user@localhost NONE
test_user@localhost NULL
set role test_role1;
select current_user(), current_role();
current_user() current_role()
......@@ -40,7 +40,7 @@ localhost test_user test_role1
set role none;
select current_user(), current_role();
current_user() current_role()
test_user@localhost NONE
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';
......
......@@ -26,7 +26,7 @@ GRANT USAGE ON *.* TO 'test_user'@'localhost'
GRANT test_role1 TO 'test_user'@'localhost'
select current_user(), current_role();
current_user() current_role()
test_user@localhost NONE
test_user@localhost NULL
set role test_role1;
select current_user(), current_role();
current_user() current_role()
......@@ -57,7 +57,7 @@ use mysql;
set role none;
select current_user(), current_role();
current_user() current_role()
test_user@localhost NONE
test_user@localhost NULL
select RoleFk from mysql.roles_mapping;
ERROR 42000: SELECT command denied to user 'test_user'@'localhost' for table 'roles_mapping'
drop user 'test_user'@'localhost';
......
......@@ -26,7 +26,7 @@ GRANT USAGE ON *.* TO 'test_user'@'localhost'
GRANT test_role1 TO 'test_user'@'localhost'
select current_user(), current_role();
current_user() current_role()
test_user@localhost NONE
test_user@localhost NULL
set role test_role1;
select current_user(), current_role();
current_user() current_role()
......@@ -55,7 +55,7 @@ use mysql;
set role none;
select current_user(), current_role();
current_user() current_role()
test_user@localhost NONE
test_user@localhost NULL
select * from mysql.roles_mapping;
ERROR 42000: SELECT command denied to user 'test_user'@'localhost' for table 'roles_mapping'
drop user 'test_user'@'localhost';
......
......@@ -34,7 +34,7 @@ GRANT test_role1 TO 'test_user'@'localhost'
GRANT test_role2 TO 'test_user'@'localhost'
select current_user(), current_role();
current_user() current_role()
test_user@localhost NONE
test_user@localhost NULL
set role test_role1;
select current_user(), current_role();
current_user() current_role()
......@@ -51,7 +51,7 @@ GRANT test_role2 TO 'test_user'@'localhost'
set role none;
select current_user(), current_role();
current_user() current_role()
test_user@localhost NONE
test_user@localhost NULL
show grants;
Grants for test_user@localhost
GRANT USAGE ON *.* TO 'test_user'@'localhost'
......
......@@ -2345,19 +2345,16 @@ bool Item_func_current_role::fix_fields(THD *thd, Item **ref)
Security_context *ctx= context->security_ctx
? context->security_ctx : thd->security_ctx;
LEX_STRING role;
if (ctx->priv_role[0])
{
role.str= ctx->priv_role;
role.length= strlen(role.str);
}
else
role= none_role;
if (str_value.copy(role.str, role.length, system_charset_info))
return 1;
if (str_value.copy(ctx->priv_role, strlen(ctx->priv_role),
system_charset_info))
return 1;
str_value.mark_as_const();
str_value.mark_as_const();
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