From 09ec8e2e2246f9fb67fd41631c5669d9ae26b2e5 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 30 Jul 2020 10:07:41 +0200 Subject: [PATCH] improve the error message for a dropped current role --- mysql-test/suite/roles/drop_current_role.result | 2 +- mysql-test/suite/roles/drop_current_role.test | 2 +- sql/sql_acl.cc | 8 +++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/mysql-test/suite/roles/drop_current_role.result b/mysql-test/suite/roles/drop_current_role.result index 79525a0ff50..d5eafc6c813 100644 --- a/mysql-test/suite/roles/drop_current_role.result +++ b/mysql-test/suite/roles/drop_current_role.result @@ -2,4 +2,4 @@ create role r; set role r; drop role r; revoke all on *.* from current_role; -ERROR 42000: There is no such grant defined for user 'r' on host '' +ERROR OP000: Invalid role specification `r`. diff --git a/mysql-test/suite/roles/drop_current_role.test b/mysql-test/suite/roles/drop_current_role.test index 1485b830eed..c8d6fc5d9df 100644 --- a/mysql-test/suite/roles/drop_current_role.test +++ b/mysql-test/suite/roles/drop_current_role.test @@ -5,5 +5,5 @@ create role r; set role r; drop role r; -error ER_NONEXISTING_GRANT; +error ER_INVALID_ROLE; revoke all on *.* from current_role; diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index fee337925fc..cf0b1d87bd7 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -3475,13 +3475,15 @@ static int replace_user_table(THD *thd, TABLE *table, LEX_USER &combo, table->key_info->key_length); if (table->file->ha_index_read_idx_map(table->record[0], 0, user_key, - HA_WHOLE_KEY, - HA_READ_KEY_EXACT)) + HA_WHOLE_KEY, HA_READ_KEY_EXACT)) { /* what == 'N' means revoke */ if (what == 'N') { - my_error(ER_NONEXISTING_GRANT, MYF(0), combo.user.str, combo.host.str); + if (combo.host.length) + my_error(ER_NONEXISTING_GRANT, MYF(0), combo.user.str, combo.host.str); + else + my_error(ER_INVALID_ROLE, MYF(0), combo.user.str); goto end; } /*