Commit 485de9cb authored by lars@mysql.com's avatar lars@mysql.com

Fix for bug#5551 (Version 4).

The idea of the fix is that the administrative statements 
OPTIMIZE TABLE, REPAIR TABLE and ANALYZE TABLE should not 
generate binlog errors if there is no errors on the master.
parent 4650f0ac
...@@ -95,6 +95,7 @@ kaj@work.mysql.com ...@@ -95,6 +95,7 @@ kaj@work.mysql.com
kent@mysql.com kent@mysql.com
konstantin@mysql.com konstantin@mysql.com
kostja@oak.local kostja@oak.local
lars@mysql.com
lenz@kallisto.mysql.com lenz@kallisto.mysql.com
lenz@mysql.com lenz@mysql.com
magnus@neptunus.(none) magnus@neptunus.(none)
......
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
CREATE TABLE t1 ( a int ) ENGINE=InnoDB;
BEGIN;
INSERT INTO t1 VALUES (1);
OPTIMIZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 optimize status Operation failed
OPTIMIZE TABLE non_existing;
Table Op Msg_type Msg_text
test.non_existing optimize error Table 'test.non_existing' doesn't exist
source include/have_innodb.inc;
source include/master-slave.inc;
#
# BUG#5551 "Failed OPTIMIZE TABLE is logged to binary log"
# Replication should work when OPTIMIZE TABLE timeouts, and
# when OPTIMIZE TABLE is executed on a non-existing table
#
CREATE TABLE t1 ( a int ) ENGINE=InnoDB;
BEGIN;
INSERT INTO t1 VALUES (1);
connection master1;
OPTIMIZE TABLE t1;
OPTIMIZE TABLE non_existing;
sync_slave_with_master;
...@@ -2610,6 +2610,7 @@ mysql_execute_command(THD *thd) ...@@ -2610,6 +2610,7 @@ mysql_execute_command(THD *thd)
mysql_update_log.write(thd, thd->query, thd->query_length); mysql_update_log.write(thd, thd->query, thd->query_length);
if (mysql_bin_log.is_open()) if (mysql_bin_log.is_open())
{ {
thd->clear_error(); // No binlog error generated
Query_log_event qinfo(thd, thd->query, thd->query_length, 0); Query_log_event qinfo(thd, thd->query, thd->query_length, 0);
mysql_bin_log.write(&qinfo); mysql_bin_log.write(&qinfo);
} }
...@@ -2638,6 +2639,7 @@ mysql_execute_command(THD *thd) ...@@ -2638,6 +2639,7 @@ mysql_execute_command(THD *thd)
mysql_update_log.write(thd, thd->query, thd->query_length); mysql_update_log.write(thd, thd->query, thd->query_length);
if (mysql_bin_log.is_open()) if (mysql_bin_log.is_open())
{ {
thd->clear_error(); // No binlog error generated
Query_log_event qinfo(thd, thd->query, thd->query_length, 0); Query_log_event qinfo(thd, thd->query, thd->query_length, 0);
mysql_bin_log.write(&qinfo); mysql_bin_log.write(&qinfo);
} }
...@@ -2660,6 +2662,7 @@ mysql_execute_command(THD *thd) ...@@ -2660,6 +2662,7 @@ mysql_execute_command(THD *thd)
mysql_update_log.write(thd, thd->query, thd->query_length); mysql_update_log.write(thd, thd->query, thd->query_length);
if (mysql_bin_log.is_open()) if (mysql_bin_log.is_open())
{ {
thd->clear_error(); // No binlog error generated
Query_log_event qinfo(thd, thd->query, thd->query_length, 0); Query_log_event qinfo(thd, thd->query, thd->query_length, 0);
mysql_bin_log.write(&qinfo); mysql_bin_log.write(&qinfo);
} }
......
...@@ -1734,6 +1734,12 @@ static int prepare_for_repair(THD* thd, TABLE_LIST *table_list, ...@@ -1734,6 +1734,12 @@ static int prepare_for_repair(THD* thd, TABLE_LIST *table_list,
} }
/*
RETURN VALUES
0 Message sent to net (admin operation went ok)
-1 Message should be sent by caller
(admin operation or network communication failed)
*/
static int mysql_admin_table(THD* thd, TABLE_LIST* tables, static int mysql_admin_table(THD* thd, TABLE_LIST* tables,
HA_CHECK_OPT* check_opt, HA_CHECK_OPT* check_opt,
const char *operator_name, const char *operator_name,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment