From b1c41e112cf14bd32af3d24242d7458e074cd505 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Sat, 8 Dec 2018 01:16:05 +0100 Subject: [PATCH] MDEV-17932 : assertion in multi RENAME USER command. Sort acl_users inside the mysql_rename_user()'s loop, after every successful iteration. This is needed because on the next loop's iteration find_user_exact() is used, which requires correct sorting by name. --- mysql-test/main/grant.result | 8 ++++++++ mysql-test/main/grant.test | 9 +++++++++ sql/sql_acl.cc | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/mysql-test/main/grant.result b/mysql-test/main/grant.result index 74f86edd4ea..2b92a2bd797 100644 --- a/mysql-test/main/grant.result +++ b/mysql-test/main/grant.result @@ -2762,3 +2762,11 @@ DROP USER dummy@localhost; # # End of 10.2 tests # +# +# MDEV-17932 : Assertion upon double RENAME USER +# +CREATE USER foo@localhost; +CREATE USER bar2@localhost; +RENAME USER foo@localhost TO bar1@localhost, bar1@localhost TO bar3@localhost; +DROP USER bar2@localhost; +DROP USER bar3@localhost; diff --git a/mysql-test/main/grant.test b/mysql-test/main/grant.test index f54c4bd981d..10da0af4ea5 100644 --- a/mysql-test/main/grant.test +++ b/mysql-test/main/grant.test @@ -2258,3 +2258,12 @@ DROP USER dummy@localhost; --echo # --echo # End of 10.2 tests --echo # + +--echo # +--echo # MDEV-17932 : Assertion upon double RENAME USER +--echo # +CREATE USER foo@localhost; +CREATE USER bar2@localhost; +RENAME USER foo@localhost TO bar1@localhost, bar1@localhost TO bar3@localhost; +DROP USER bar2@localhost; +DROP USER bar3@localhost; diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 7f7bd447bad..f1612a7927f 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -10365,9 +10365,9 @@ bool mysql_rename_user(THD *thd, List &list) continue; } some_users_renamed= TRUE; + rebuild_acl_users(); } - rebuild_acl_users(); /* Rebuild 'acl_check_hosts' since 'acl_users' has been modified */ rebuild_check_host();