diff options
-rw-r--r-- | mysql-test/r/grant5.result | 2 | ||||
-rw-r--r-- | mysql-test/t/grant5.test | 7 | ||||
-rw-r--r-- | sql/sql_parse.cc | 5 |
3 files changed, 12 insertions, 2 deletions
diff --git a/mysql-test/r/grant5.result b/mysql-test/r/grant5.result new file mode 100644 index 00000000000..2df394c0432 --- /dev/null +++ b/mysql-test/r/grant5.result @@ -0,0 +1,2 @@ +SHOW GRANTS FOR root@invalid_host; +ERROR 42000: There is no such grant defined for user 'root' on host 'invalid_host' diff --git a/mysql-test/t/grant5.test b/mysql-test/t/grant5.test new file mode 100644 index 00000000000..db953d97fb3 --- /dev/null +++ b/mysql-test/t/grant5.test @@ -0,0 +1,7 @@ +-- source include/not_embedded.inc + +# +# MDEV-6625 SHOW GRANTS for current_user_name@wrong_host_name +# +--error ER_NONEXISTING_GRANT +SHOW GRANTS FOR root@invalid_host; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 4070a833f82..30fcac6e12a 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4335,8 +4335,9 @@ end_with_restore_list: if (!grant_user) goto error; - if (grant_user->user.str && - !strcmp(thd->security_ctx->priv_user, grant_user->user.str)) + if (grant_user->user.str && grant_user->host.str && + !strcmp(thd->security_ctx->priv_user, grant_user->user.str) && + !strcmp(thd->security_ctx->priv_host, grant_user->host.str)) grant_user->user= current_user; if (grant_user->user.str == current_user.str || |