summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/suite/rpl/r/rpl_user.result11
-rw-r--r--mysql-test/suite/rpl/t/rpl_user.test11
-rw-r--r--sql/sql_acl.cc6
3 files changed, 28 insertions, 0 deletions
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
@@ -42,6 +42,17 @@ 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
#
connection master;
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index b67bdbafa5c..76687dd0021 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -10478,6 +10478,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);
@@ -10503,6 +10504,7 @@ int mysql_alter_user(THD* thd, List<LEX_USER> &users_list)
result= TRUE;
continue;
}
+ some_users_altered= true;
}
/* Unlock ACL data structures. */
@@ -10527,6 +10529,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);
}