[Commits] MDEV-17753 ALTER USER fail to replicate
commit 364f7583d9514963ec30e27876c366678c8af240 Author: Sachin <sachin.setiya@mariadb.com> Date: Wed Dec 19 22:30:28 2018 +0530 MDEV-17753 ALTER USER fail to replicate Change mysql_alter_user to log alter user command. diff --git a/mysql-test/suite/rpl/r/rpl_user.result b/mysql-test/suite/rpl/r/rpl_user.result index 34f15d41209..2a8bf69501c 100644 --- a/mysql-test/suite/rpl/r/rpl_user.result +++ b/mysql-test/suite/rpl/r/rpl_user.result @@ -31,6 +31,13 @@ Host User fakehost barbar fakehost foofoo connection master; +alter user 'foofoo'@'fakehost' identified by 'foo'; +alter user 'non_exist_user1'@'fakehost' identified by 'foo', 'barbar'@'fakehost' identified by 'bar'; +ERROR HY000: Operation ALTER USER failed for 'non_exist_user1'@'fakehost' +alter user 'non_exist_user1'@'fakehost' identified by 'foo', 'non_exist_user2'@'fakehost' identified by 'bar'; +ERROR HY000: Operation ALTER USER failed for 'non_exist_user1'@'fakehost','non_exist_user2'@'fakehost' +connection slave; +connection master; drop user 'foofoo'@'fakehost'; drop user 'not_exist_user1'@'fakehost', 'barbar'@'fakehost'; ERROR HY000: Operation DROP USER failed for 'not_exist_user1'@'fakehost' @@ -51,6 +58,10 @@ master-bin.000001 # Query # # use `test`; rename user 'foo'@'fakehost' to 'foofo master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; rename user 'not_exist_user1'@'fakehost' to 'foobar'@'fakehost', 'bar'@'fakehost' to 'barbar'@'fakehost' master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; alter user 'foofoo'@'fakehost' identified by 'foo' +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; alter user 'non_exist_user1'@'fakehost' identified by 'foo', 'barbar'@'fakehost' identified by 'bar' +master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; drop user 'foofoo'@'fakehost' master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; drop user 'not_exist_user1'@'fakehost', 'barbar'@'fakehost' diff --git a/mysql-test/suite/rpl/t/rpl_user.test b/mysql-test/suite/rpl/t/rpl_user.test index caa17b47733..079c2bf27d5 100644 --- a/mysql-test/suite/rpl/t/rpl_user.test +++ b/mysql-test/suite/rpl/t/rpl_user.test @@ -41,6 +41,17 @@ rename user 'not_exist_user1'@'fakehost' to 'foobar'@'fakehost', 'not_exist_user sync_slave_with_master; select Host,User from mysql.user where Host='fakehost'; +# +# Test alter user +# +connection master; +alter user 'foofoo'@'fakehost' identified by 'foo'; +--error ER_CANNOT_USER +alter user 'non_exist_user1'@'fakehost' identified by 'foo', 'barbar'@'fakehost' identified by 'bar'; +--error ER_CANNOT_USER +alter user 'non_exist_user1'@'fakehost' identified by 'foo', 'non_exist_user2'@'fakehost' identified by 'bar'; +sync_slave_with_master; + # # Test drop user # diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 50c9c33e8fa..37c5817ef8d 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -10476,6 +10476,7 @@ int mysql_alter_user(THD* thd, List<LEX_USER> &users_list) DBUG_ENTER("mysql_alter_user"); int result= 0; String wrong_users; + bool some_users_altered= false; /* The only table we're altering is the user table. */ Grant_tables tables(Table_user, TL_WRITE); @@ -10501,6 +10502,7 @@ int mysql_alter_user(THD* thd, List<LEX_USER> &users_list) result= TRUE; continue; } + some_users_altered= true; } /* Unlock ACL data structures. */ @@ -10525,6 +10527,10 @@ int mysql_alter_user(THD* thd, List<LEX_USER> &users_list) wrong_users.c_ptr_safe()); } } + + if (some_users_altered) + result|= write_bin_log(thd, FALSE, thd->query(), + thd->query_length()); DBUG_RETURN(result); } -- Regards Sachin Setiya Software Engineer at MariaDB
participants (1)
-
Sachin Setiya