He Zhenxing,
> Hi Andrei
>
> Patch is OK to push, see some minor comments below!
>
> Andrei Elkin wrote:
>> #At file:///home/andrei/MySQL/BZR/mysql-5.1-5.1.29-rc/
>>
>> 2677 Andrei Elkin 2008-09-03
>> Bug #36099 replicate-do-db affects replaying RBR events with mysqlbinlog
>>
>> The bug is about to refuse execution of a BINLOG pseudo-query on the
>> server. The reason of the bug appeared to be an inappropiate applying
>> the replication slave side filtering rules. The rules are supposed to
>> be active only at times when the slave's sql thread executes an event.
>>
>
> The description of the bug is not quite clear, I would suggest some
> thing like:
>
> The replication filtering rules were inappropiately applied when
> executing BINLOG pseudo-query ...
>
agreed.
>> Fixed with correcting a condition to call replication rules only if
>> the slave sql thread executes the event.
>> added:
>> mysql-test/suite/rpl/r/rpl_binlog_query_filter_rules.result
>> mysql-test/suite/rpl/t/rpl_binlog_query_filter_rules-master.opt
>> mysql-test/suite/rpl/t/rpl_binlog_query_filter_rules.test
>> modified:
>> sql/log_event.cc
>>
>> per-file messages:
>> mysql-test/suite/rpl/r/rpl_binlog_query_filter_rules.result
>> new result file
>> mysql-test/suite/rpl/t/rpl_binlog_query_filter_rules-master.opt
>> a filtering option that would refuse to replicate a row event of the main
> test on
>> slave
>> mysql-test/suite/rpl/t/rpl_binlog_query_filter_rules.test
>> a regression test for the bug
>> sql/log_event.cc
>> avoiding to call the filtering rules if the execution thread is not a slave.
>> === added file 'mysql-test/suite/rpl/r/rpl_binlog_query_filter_rules.result'
>> --- a/mysql-test/suite/rpl/r/rpl_binlog_query_filter_rules.result 1970-01-01
> 00:00:00 +0000
>> +++ b/mysql-test/suite/rpl/r/rpl_binlog_query_filter_rules.result 2008-09-03
> 09:31:52 +0000
>> @@ -0,0 +1,12 @@
>> +drop table if exists t1;
>> +reset master;
>> +create table t1 (a int);
>> +set @@session.binlog_format=row;
>> +insert into t1 values (1);
>> +flush logs;
>> +drop table t1;
>> +must be 1
>> +select * from t1;
>> +a
>> +1
>> +drop table t1;
>>
>> === added file 'mysql-test/suite/rpl/t/rpl_binlog_query_filter_rules-master.opt'
>> --- a/mysql-test/suite/rpl/t/rpl_binlog_query_filter_rules-master.opt 1970-01-01
> 00:00:00 +0000
>> +++ b/mysql-test/suite/rpl/t/rpl_binlog_query_filter_rules-master.opt 2008-09-03
> 09:31:52 +0000
>> @@ -0,0 +1 @@
>> +--replicate-do-db='impossible_database'
>>
>> === added file 'mysql-test/suite/rpl/t/rpl_binlog_query_filter_rules.test'
>> --- a/mysql-test/suite/rpl/t/rpl_binlog_query_filter_rules.test 1970-01-01
> 00:00:00 +0000
>> +++ b/mysql-test/suite/rpl/t/rpl_binlog_query_filter_rules.test 2008-09-03
> 09:31:52 +0000
>> @@ -0,0 +1,32 @@
>> +# regression test for
>> +# Bug#36099 replicate-do-db affects replaying RBR events with mysqlbinlog
>> +# The test verifies that the slave side filtering rule does not affect
>> +# applying of row-events on master via mysqlbinlog
>> +
>> +-- source include/have_log_bin.inc
>> +-- source include/not_embedded.inc
>> +-- source include/have_binlog_format_row.inc
>> +
>> +--disable_warnings
>> +drop table if exists t1;
>> +--enable_warnings
>> +
>> +reset master;
>> +
>> +create table t1 (a int);
>> +set @@session.binlog_format=row;
>
> This can be removed
>
right.
>> +insert into t1 values (1);
>> +
>> +flush logs;
>> +--exec $MYSQL_BINLOG $MYSQLTEST_VARDIR/log/master-bin.000001 >
> $MYSQLTEST_VARDIR/tmp/bug36099.sql
>> +
>> +drop table t1;
>> +--exec $MYSQL -e "source $MYSQLTEST_VARDIR/tmp/bug36099.sql"
>> +
>> +--echo must be 1
>> +select * from t1;
>> +
>> +# cleanup
>> +
>> +drop table t1;
>> +remove_file $MYSQLTEST_VARDIR/tmp/bug36099.sql;
>>
>> === modified file 'sql/log_event.cc'
>> --- a/sql/log_event.cc 2008-08-27 18:52:44 +0000
>> +++ b/sql/log_event.cc 2008-09-03 09:31:52 +0000
>> @@ -7843,8 +7843,9 @@ int Table_map_log_event::do_apply_event(
>>
>> int error= 0;
>>
>> - if (!rpl_filter->db_ok(table_list->db) ||
>> - (rpl_filter->is_on() && !rpl_filter->tables_ok("",
> table_list)))
>> + if (rli->sql_thd->slave_thread /* filtering is for slave only */
> &&
>> + (!rpl_filter->db_ok(table_list->db) ||
>> + (rpl_filter->is_on() && !rpl_filter->tables_ok("",
> table_list))))
>> {
>> my_free(memory, MYF(MY_WME));
>> }
>>
>
cheers,
Andrei