diff --git a/mysql-test/r/acl_roles_set_role-database-recursive.result b/mysql-test/r/acl_roles_set_role-database-recursive.result index 0038c82843c..04067afa253 100644 --- a/mysql-test/r/acl_roles_set_role-database-recursive.result +++ b/mysql-test/r/acl_roles_set_role-database-recursive.result @@ -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; diff --git a/mysql-test/r/acl_roles_set_role-database-simple.result b/mysql-test/r/acl_roles_set_role-database-simple.result index 32575638e4c..1cc3aba1a39 100644 --- a/mysql-test/r/acl_roles_set_role-database-simple.result +++ b/mysql-test/r/acl_roles_set_role-database-simple.result @@ -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; diff --git a/mysql-test/r/acl_roles_set_role-multiple-role.result b/mysql-test/r/acl_roles_set_role-multiple-role.result index 0aa105ec0d4..d4a432d6c03 100644 --- a/mysql-test/r/acl_roles_set_role-multiple-role.result +++ b/mysql-test/r/acl_roles_set_role-multiple-role.result @@ -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; diff --git a/mysql-test/r/acl_roles_set_role-recursive.result b/mysql-test/r/acl_roles_set_role-recursive.result index 505e1f5f730..864616cf255 100644 --- a/mysql-test/r/acl_roles_set_role-recursive.result +++ b/mysql-test/r/acl_roles_set_role-recursive.result @@ -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' diff --git a/mysql-test/r/acl_roles_set_role-routine-simple.result b/mysql-test/r/acl_roles_set_role-routine-simple.result index 2ca1a60b324..a57bfb9b3f2 100644 --- a/mysql-test/r/acl_roles_set_role-routine-simple.result +++ b/mysql-test/r/acl_roles_set_role-routine-simple.result @@ -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' diff --git a/mysql-test/r/acl_roles_set_role-simple.result b/mysql-test/r/acl_roles_set_role-simple.result index aa68052ae18..cadc63624aa 100644 --- a/mysql-test/r/acl_roles_set_role-simple.result +++ b/mysql-test/r/acl_roles_set_role-simple.result @@ -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'; diff --git a/mysql-test/r/acl_roles_set_role-table-column-priv.result b/mysql-test/r/acl_roles_set_role-table-column-priv.result index e5b43b0ded4..5e21dab3787 100644 --- a/mysql-test/r/acl_roles_set_role-table-column-priv.result +++ b/mysql-test/r/acl_roles_set_role-table-column-priv.result @@ -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'; diff --git a/mysql-test/r/acl_roles_set_role-table-simple.result b/mysql-test/r/acl_roles_set_role-table-simple.result index 780a416437a..01d84757ea4 100644 --- a/mysql-test/r/acl_roles_set_role-table-simple.result +++ b/mysql-test/r/acl_roles_set_role-table-simple.result @@ -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'; diff --git a/mysql-test/r/acl_roles_show_grants.result b/mysql-test/r/acl_roles_show_grants.result index 1e0c1626b75..cfe93392f41 100644 --- a/mysql-test/r/acl_roles_show_grants.result +++ b/mysql-test/r/acl_roles_show_grants.result @@ -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' diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 4f2c10c37ef..4f85dde1831 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -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); + if (str_value.copy(ctx->priv_role, strlen(ctx->priv_role), + system_charset_info)) + return 1; + + str_value.mark_as_const(); + return 0; } - else - role= none_role; - - if (str_value.copy(role.str, role.length, system_charset_info)) - return 1; - - str_value.mark_as_const(); + null_value= maybe_null= 1; return 0; }