From: Date: July 23 2007 12:10pm Subject: bk commit into 5.0 tree (gkodinov:1.2475) BUG#29749 List-Archive: http://lists.mysql.com/commits/31390 X-Bug: 29749 Message-Id: <200707231010.l6NAAaYf017959@magare.gmz> Below is the list of changes that have just been committed into a local 5.0 repository of kgeorge. When kgeorge does a push these changes will be propagated to the main repository and, within 24 hours after the push, to the public repository. For information on how to access the public repository see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html ChangeSet@stripped, 2007-07-23 13:10:33+03:00, gkodinov@stripped +3 -0 Bug #29749: Failed DROP USER still binlogged and replicated CREATE/RENAME/DROP USER can handle more than one user in a single command, e.g. DROP USER u1, u2; There's no need to log the operation to slave if all of the users cannot be processed (e.g. they don't exist). But the command must be logged if even one of the operations produces result. Fixed by not logging CREATE/RENAME/DROP USER if all of its sub-operations fail to execute on master. Note that if any of the sub-operations succeeds all of the statement is sent to the replication log (and will still cause disconnect on the SQL thread if any of the sub-operations fail). mysql-test/r/rpl_grant.result@stripped, 2007-07-23 13:10:31+03:00, gkodinov@stripped +60 -2 Bug #29749: test case + proper cleanup mysql-test/t/rpl_grant.test@stripped, 2007-07-23 13:10:31+03:00, gkodinov@stripped +38 -1 Bug #29749: test case + proper cleanup sql/sql_acl.cc@stripped, 2007-07-23 13:10:31+03:00, gkodinov@stripped +12 -3 Bug #29749: Don't log CREATE/RENAME/DROP USER if all of the operation fails diff -Nrup a/mysql-test/r/rpl_grant.result b/mysql-test/r/rpl_grant.result --- a/mysql-test/r/rpl_grant.result 2007-06-21 17:55:48 +03:00 +++ b/mysql-test/r/rpl_grant.result 2007-07-23 13:10:31 +03:00 @@ -48,7 +48,7 @@ Master_User root Master_Port MASTER_PORT Connect_Retry 1 Master_Log_File master-bin.000001 -Read_Master_Log_Pos 609 +Read_Master_Log_Pos # Relay_Log_File # Relay_Log_Pos # Relay_Master_Log_File master-bin.000001 @@ -63,7 +63,7 @@ Replicate_Wild_Ignore_Table Last_Errno 0 Last_Error Skip_Counter 0 -Exec_Master_Log_Pos 609 +Exec_Master_Log_Pos # Relay_Log_Space # Until_Condition None Until_Log_File @@ -75,3 +75,61 @@ Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # +reset master; +create user u1; +create user u1; +ERROR HY000: Operation CREATE USER failed for 'u1'@'%' +rename user 'notexists'@'localhost' to 'utopia'@'localhost'; +ERROR HY000: Operation RENAME USER failed for 'notexists'@'localhost' +drop user 'notexists'@'localhost'; +ERROR HY000: Operation DROP USER failed for 'notexists'@'localhost' +create user u1, u2; +ERROR HY000: Operation CREATE USER failed for 'u1'@'%' +rename user u2 to u3, 'notexists'@'localhost' to 'utopia'@'localhost'; +ERROR HY000: Operation RENAME USER failed for 'notexists'@'localhost' +drop user u1, u3, 'notexists'@'localhost'; +ERROR HY000: Operation DROP USER failed for 'notexists'@'localhost' +**** On Slave **** +DROP USER u1; +ERROR HY000: Operation DROP USER failed for 'u1'@'%' +show slave status; +Slave_IO_State x +Master_Host x +Master_User x +Master_Port x +Connect_Retry x +Master_Log_File x +Read_Master_Log_Pos x +Relay_Log_File x +Relay_Log_Pos x +Relay_Master_Log_File x +Slave_IO_Running Yes +Slave_SQL_Running Yes +Replicate_Do_DB x +Replicate_Ignore_DB x +Replicate_Do_Table x +Replicate_Ignore_Table x +Replicate_Wild_Do_Table x +Replicate_Wild_Ignore_Table x +Last_Errno x +Last_Error x +Skip_Counter x +Exec_Master_Log_Pos x +Relay_Log_Space x +Until_Condition x +Until_Log_File x +Until_Log_Pos x +Master_SSL_Allowed x +Master_SSL_CA_File x +Master_SSL_CA_Path x +Master_SSL_Cert x +Master_SSL_Cipher x +Master_SSL_Key x +Seconds_Behind_Master x +**** On Master **** +show binlog events limit 1, 100; +Log_name Pos Event_type Server_id End_log_pos Info +x x x x x use `test`; create user u1 +x x x x x use `test`; create user u1, u2 +x x x x x use `test`; rename user u2 to u3, 'notexists'@'localhost' to 'utopia'@'localhost' +x x x x x use `test`; drop user u1, u3, 'notexists'@'localhost' diff -Nrup a/mysql-test/t/rpl_grant.test b/mysql-test/t/rpl_grant.test --- a/mysql-test/t/rpl_grant.test 2007-06-21 17:55:49 +03:00 +++ b/mysql-test/t/rpl_grant.test 2007-07-23 13:10:31 +03:00 @@ -38,5 +38,42 @@ SELECT user,host FROM mysql.user WHERE u SELECT COUNT(*) FROM mysql.user; --replace_result $MASTER_MYPORT MASTER_PORT ---replace_column 1 # 8 # 9 # 23 # 33 # +--replace_column 1 # 7 # 8 # 9 # 22 # 23 # 33 # query_vertical SHOW SLAVE STATUS; +connection master; + +# +# Bug #29749: Failed DROP USER still binlogged and replicated +# + +reset master; +create user u1; +sync_slave_with_master; +connection master; +--error ER_CANNOT_USER +create user u1; +--error ER_CANNOT_USER +rename user 'notexists'@'localhost' to 'utopia'@'localhost'; +--error ER_CANNOT_USER +drop user 'notexists'@'localhost'; +--error ER_CANNOT_USER +create user u1, u2; +--error ER_CANNOT_USER +rename user u2 to u3, 'notexists'@'localhost' to 'utopia'@'localhost'; +--error ER_CANNOT_USER +drop user u1, u3, 'notexists'@'localhost'; + +sync_slave_with_master; +--echo **** On Slave **** +--error ER_CANNOT_USER +DROP USER u1; + +--vertical_results +--replace_column 1 x 2 x 3 x 4 x 5 x 6 x 7 x 8 x 9 x 10 x 13 x 14 x 15 x 16 x 17 x 18 x 19 x 20 x 21 x 22 x 23 x 24 x 25 x 26 x 27 x 28 x 29 x 30 x 31 x 32 x 33 x +show slave status; +--horizontal_results + +connection master; +--echo **** On Master **** +--replace_column 1 x 2 x 3 x 4 x 5 x +show binlog events limit 1, 100; diff -Nrup a/sql/sql_acl.cc b/sql/sql_acl.cc --- a/sql/sql_acl.cc 2007-06-20 15:24:27 +03:00 +++ b/sql/sql_acl.cc 2007-07-23 13:10:31 +03:00 @@ -5273,6 +5273,7 @@ bool mysql_create_user(THD *thd, List user_list(list); @@ -5310,12 +5311,14 @@ bool mysql_create_user(THD *thd, List lock)); - if (mysql_bin_log.is_open()) + if (mysql_bin_log.is_open() && !all_users_fail) { Query_log_event qinfo(thd, thd->query, thd->query_length, 0, FALSE); mysql_bin_log.write(&qinfo); @@ -5345,6 +5348,7 @@ bool mysql_create_user(THD *thd, List &list) { int result; + my_bool all_users_fail= TRUE; String wrong_users; LEX_USER *user_name, *tmp_user_name; List_iterator user_list(list); @@ -5370,7 +5374,9 @@ bool mysql_drop_user(THD *thd, List net.last_errno: %d", thd->net.last_errno)); DBUG_PRINT("info", ("thd->net.last_error: %s", thd->net.last_error)); - if (mysql_bin_log.is_open()) + if (mysql_bin_log.is_open() && !all_users_fail) { Query_log_event qinfo(thd, thd->query, thd->query_length, 0, FALSE); mysql_bin_log.write(&qinfo); @@ -5413,6 +5419,7 @@ bool mysql_rename_user(THD *thd, List user_list(list); @@ -5450,7 +5457,9 @@ bool mysql_rename_user(THD *thd, List lock)); - if (mysql_bin_log.is_open()) + if (mysql_bin_log.is_open() && !all_users_fail) { Query_log_event qinfo(thd, thd->query, thd->query_length, 0, FALSE); mysql_bin_log.write(&qinfo);