Skip to content

Commit 7907816

Browse files
MDEV-17753 ALTER USER fail to replicate
Change mysql_alter_user to log alter user command.
1 parent 7331c66 commit 7907816

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

mysql-test/suite/rpl/r/rpl_user.result

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ Host User
3131
fakehost barbar
3232
fakehost foofoo
3333
connection master;
34+
alter user 'foofoo'@'fakehost' identified by 'foo';
35+
alter user 'non_exist_user1'@'fakehost' identified by 'foo', 'barbar'@'fakehost' identified by 'bar';
36+
ERROR HY000: Operation ALTER USER failed for 'non_exist_user1'@'fakehost'
37+
alter user 'non_exist_user1'@'fakehost' identified by 'foo', 'non_exist_user2'@'fakehost' identified by 'bar';
38+
ERROR HY000: Operation ALTER USER failed for 'non_exist_user1'@'fakehost','non_exist_user2'@'fakehost'
39+
connection slave;
40+
connection master;
3441
drop user 'foofoo'@'fakehost';
3542
drop user 'not_exist_user1'@'fakehost', 'barbar'@'fakehost';
3643
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
5158
master-bin.000001 # Gtid # # GTID #-#-#
5259
master-bin.000001 # Query # # use `test`; rename user 'not_exist_user1'@'fakehost' to 'foobar'@'fakehost', 'bar'@'fakehost' to 'barbar'@'fakehost'
5360
master-bin.000001 # Gtid # # GTID #-#-#
61+
master-bin.000001 # Query # # use `test`; alter user 'foofoo'@'fakehost' identified by 'foo'
62+
master-bin.000001 # Gtid # # GTID #-#-#
63+
master-bin.000001 # Query # # use `test`; alter user 'non_exist_user1'@'fakehost' identified by 'foo', 'barbar'@'fakehost' identified by 'bar'
64+
master-bin.000001 # Gtid # # GTID #-#-#
5465
master-bin.000001 # Query # # use `test`; drop user 'foofoo'@'fakehost'
5566
master-bin.000001 # Gtid # # GTID #-#-#
5667
master-bin.000001 # Query # # use `test`; drop user 'not_exist_user1'@'fakehost', 'barbar'@'fakehost'

mysql-test/suite/rpl/t/rpl_user.test

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,17 @@ rename user 'not_exist_user1'@'fakehost' to 'foobar'@'fakehost', 'not_exist_user
4141
sync_slave_with_master;
4242
select Host,User from mysql.user where Host='fakehost';
4343

44+
#
45+
# Test alter user
46+
#
47+
connection master;
48+
alter user 'foofoo'@'fakehost' identified by 'foo';
49+
--error ER_CANNOT_USER
50+
alter user 'non_exist_user1'@'fakehost' identified by 'foo', 'barbar'@'fakehost' identified by 'bar';
51+
--error ER_CANNOT_USER
52+
alter user 'non_exist_user1'@'fakehost' identified by 'foo', 'non_exist_user2'@'fakehost' identified by 'bar';
53+
sync_slave_with_master;
54+
4455
#
4556
# Test drop user
4657
#

sql/sql_acl.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10478,6 +10478,7 @@ int mysql_alter_user(THD* thd, List<LEX_USER> &users_list)
1047810478
DBUG_ENTER("mysql_alter_user");
1047910479
int result= 0;
1048010480
String wrong_users;
10481+
bool some_users_altered= false;
1048110482

1048210483
/* The only table we're altering is the user table. */
1048310484
Grant_tables tables(Table_user, TL_WRITE);
@@ -10503,6 +10504,7 @@ int mysql_alter_user(THD* thd, List<LEX_USER> &users_list)
1050310504
result= TRUE;
1050410505
continue;
1050510506
}
10507+
some_users_altered= true;
1050610508
}
1050710509

1050810510
/* Unlock ACL data structures. */
@@ -10527,6 +10529,10 @@ int mysql_alter_user(THD* thd, List<LEX_USER> &users_list)
1052710529
wrong_users.c_ptr_safe());
1052810530
}
1052910531
}
10532+
10533+
if (some_users_altered)
10534+
result|= write_bin_log(thd, FALSE, thd->query(),
10535+
thd->query_length());
1053010536
DBUG_RETURN(result);
1053110537
}
1053210538

0 commit comments

Comments
 (0)