diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result index 16be3eb966d..0fe8ab444a7 100644 --- a/mysql-test/r/grant.result +++ b/mysql-test/r/grant.result @@ -1246,6 +1246,11 @@ drop user 'greg'@'localhost'; drop view v1; drop table test; drop function test_function; +SELECT CURRENT_USER(); +CURRENT_USER() +root@localhost +SET PASSWORD FOR CURRENT_USER() = PASSWORD("admin"); +SET PASSWORD FOR CURRENT_USER() = PASSWORD(""); End of 5.0 tests set names utf8; grant select on test.* to юзер_юзер@localhost; diff --git a/mysql-test/t/grant.test b/mysql-test/t/grant.test index 3fac767468e..26b735856af 100644 --- a/mysql-test/t/grant.test +++ b/mysql-test/t/grant.test @@ -1294,6 +1294,13 @@ drop view v1; drop table test; drop function test_function; +# +# Bug#41456 SET PASSWORD hates CURRENT_USER() +# +SELECT CURRENT_USER(); +SET PASSWORD FOR CURRENT_USER() = PASSWORD("admin"); +SET PASSWORD FOR CURRENT_USER() = PASSWORD(""); + --echo End of 5.0 tests # diff --git a/sql/set_var.cc b/sql/set_var.cc index a371c1113ef..00b7a6d7e76 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -3548,6 +3548,7 @@ int set_var_password::check(THD *thd) #ifndef NO_EMBEDDED_ACCESS_CHECKS if (!user->host.str) { + DBUG_ASSERT(thd->security_ctx->priv_host); if (*thd->security_ctx->priv_host != 0) { user->host.str= (char *) thd->security_ctx->priv_host; @@ -3559,6 +3560,12 @@ int set_var_password::check(THD *thd) user->host.length= 1; } } + if (!user->user.str) + { + DBUG_ASSERT(thd->security_ctx->priv_user); + user->user.str= (char *) thd->security_ctx->priv_user; + user->user.length= strlen(thd->security_ctx->priv_user); + } /* Returns 1 as the function sends error to client */ return check_change_password(thd, user->host.str, user->user.str, password, strlen(password)) ? 1 : 0;