List:Commits« Previous MessageNext Message »
From:Dao-Gang.Qu Date:September 24 2009 7:57am
Subject:bzr commit into mysql-5.0-bugteam branch (Dao-Gang.Qu:2812) Bug#46998
View as plain text  
#At file:///home/daogangqu/mysql/bzrwork/bug46998/mysql-5.0-bugteam/ based on revid:sergey.glukhov@stripped

 2812 Dao-Gang.Qu@stripped	2009-09-24
      Bug #46998  mysqlbinlog can't output BEGIN even if the database is included in a transaction
      
      The 'BEGIN/COMMIT/ROLLBACK' log event could be filtered out if the
      database is not selected by --database option of mysqlbinlog command.
      This can result in problem if there are some statements in the
      transaction are not filtered out.
      
      To fix the problem, mysqlbinlog will output 'BEGIN/ROLLBACK/COMMIT' 
      in regardless of the database filtering rules.
     @ client/mysqlbinlog.cc
        Skip the database check for BEGIN/COMMIT/ROLLBACK log events.
     @ mysql-test/r/mysqlbinlog.result
        Test result for bug#46998
     @ mysql-test/t/mysqlbinlog.test
        Added test to verify if the 'BEGIN', 'COMMIT' and 'ROLLBACK' are output
        in regardless of database filtering

    added:
      mysql-test/std_data/binlog_transaction.000001
      mysql-test/std_data/binlog_transaction.000002
      mysql-test/std_data/binlog_transaction.000003
    modified:
      client/mysqlbinlog.cc
      mysql-test/r/mysqlbinlog.result
      mysql-test/t/mysqlbinlog.test
=== modified file 'client/mysqlbinlog.cc'
--- a/client/mysqlbinlog.cc	2009-06-29 13:17:01 +0000
+++ b/client/mysqlbinlog.cc	2009-09-24 07:57:05 +0000
@@ -557,7 +557,10 @@ int process_event(PRINT_EVENT_INFO *prin
 
     switch (ev_type) {
     case QUERY_EVENT:
-      if (check_database(((Query_log_event*)ev)->db))
+      if (strncmp(((Query_log_event*)ev)->query, "BEGIN", 5) && 
+          strncmp(((Query_log_event*)ev)->query, "COMMIT", 6) && 
+          strncmp(((Query_log_event*)ev)->query, "ROLLBACK", 8) &&  
+          check_database(((Query_log_event*)ev)->db))
         goto end;
       ev->print(result_file, print_event_info);
       break;

=== modified file 'mysql-test/r/mysqlbinlog.result'
--- a/mysql-test/r/mysqlbinlog.result	2009-05-07 14:31:02 +0000
+++ b/mysql-test/r/mysqlbinlog.result	2009-09-24 07:57:05 +0000
@@ -382,4 +382,164 @@ IS NOT NULL
 SET @@global.server_id= 1;
 RESET MASTER;
 FLUSH LOGS;
+RESET MASTER;
+FLUSH LOGS;
+# The following test case was wrtten into binlog_transaction.000001, 
+# binlog_transaction.000002 and binlog_transaction.000003
+# use test;
+# eval create table t1(a int) engine=;
+# use mysql;
+# eval create table t2(a int) engine=;
+# --echo # Transaction begin
+# begin;
+# use test;
+# insert into t1 (a) values (1);
+# use mysql;
+# insert into t2 (a) values (1);
+# eval ;
+# --echo # Transaction end
+# 
+# Test case1: Test if the 'BEGIN' and 'COMMIT' are output for the 'test' database 
+# in above transaction base on innodb engine tables with the following arguments:
+# let = innodb;
+# let = innodb;
+# let =commit;
+# 
+/*!40019 SET @@session.max_insert_delayed_threads=0*/;
+/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
+DELIMITER /*!*/;
+use test/*!*/;
+SET TIMESTAMP=1253689361/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1/*!*/;
+SET @@session.sql_mode=0/*!*/;
+/*!\C latin1 *//*!*/;
+SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
+create table t1(a int) engine=innodb
+/*!*/;
+SET TIMESTAMP=1253689361/*!*/;
+BEGIN
+/*!*/;
+SET TIMESTAMP=1253689361/*!*/;
+insert into t1 (a) values (1)
+/*!*/;
+COMMIT/*!*/;
+DELIMITER ;
+# End of log file
+ROLLBACK /* added by mysqlbinlog */;
+/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
+#
+# Test if the 'BEGIN' and 'commit' are output if the database specified is not exist
+/*!40019 SET @@session.max_insert_delayed_threads=0*/;
+/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
+DELIMITER /*!*/;
+SET TIMESTAMP=1253689361/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1/*!*/;
+SET @@session.sql_mode=0/*!*/;
+/*!\C latin1 *//*!*/;
+SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
+BEGIN
+/*!*/;
+COMMIT/*!*/;
+DELIMITER ;
+# End of log file
+ROLLBACK /* added by mysqlbinlog */;
+/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
+# Test case2: Test if the 'BEGIN' and 'ROLLBACK' are output for the 'test' database 
+# in above transaction base on innodb and myisam engine tables with the following arguments:
+# let = innodb;
+# let = myisam;
+# let =rollback;
+# 
+/*!40019 SET @@session.max_insert_delayed_threads=0*/;
+/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
+DELIMITER /*!*/;
+use test/*!*/;
+SET TIMESTAMP=1253690767/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1/*!*/;
+SET @@session.sql_mode=0/*!*/;
+/*!\C latin1 *//*!*/;
+SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
+create table t1(a int) engine=innodb
+/*!*/;
+SET TIMESTAMP=1253690767/*!*/;
+BEGIN
+/*!*/;
+SET TIMESTAMP=1253690767/*!*/;
+insert into t1 (a) values (1)
+/*!*/;
+SET TIMESTAMP=1253690767/*!*/;
+ROLLBACK
+/*!*/;
+DELIMITER ;
+# End of log file
+ROLLBACK /* added by mysqlbinlog */;
+/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
+#
+# Test if the 'BEGIN' and 'ROLLBACK' are output if the database specified is not exist
+/*!40019 SET @@session.max_insert_delayed_threads=0*/;
+/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
+DELIMITER /*!*/;
+SET TIMESTAMP=1253690767/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1/*!*/;
+SET @@session.sql_mode=0/*!*/;
+/*!\C latin1 *//*!*/;
+SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
+BEGIN
+/*!*/;
+SET TIMESTAMP=1253690767/*!*/;
+ROLLBACK
+/*!*/;
+DELIMITER ;
+# End of log file
+ROLLBACK /* added by mysqlbinlog */;
+/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
+# Test case3: Test if the 'BEGIN' and 'COMMIT' are output for the 'test' database 
+# in above transaction base on NDB engine tables with the following arguments:
+# let = NDB;
+# let = NDB;
+# let =commit;
+#
+/*!40019 SET @@session.max_insert_delayed_threads=0*/;
+/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
+DELIMITER /*!*/;
+use test/*!*/;
+SET TIMESTAMP=1253691047/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1/*!*/;
+SET @@session.sql_mode=0/*!*/;
+/*!\C latin1 *//*!*/;
+SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
+create table t1(a int) engine=NDB
+/*!*/;
+SET TIMESTAMP=1253691048/*!*/;
+BEGIN
+/*!*/;
+SET TIMESTAMP=1253691048/*!*/;
+insert into t1 (a) values (1)
+/*!*/;
+SET TIMESTAMP=1253691048/*!*/;
+COMMIT
+/*!*/;
+DELIMITER ;
+# End of log file
+ROLLBACK /* added by mysqlbinlog */;
+/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
+#
+# Test if the 'BEGIN' and 'COMMIT' are output if the database specified is not exist
+/*!40019 SET @@session.max_insert_delayed_threads=0*/;
+/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
+DELIMITER /*!*/;
+SET TIMESTAMP=1253691048/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1/*!*/;
+SET @@session.sql_mode=0/*!*/;
+/*!\C latin1 *//*!*/;
+SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
+BEGIN
+/*!*/;
+SET TIMESTAMP=1253691048/*!*/;
+COMMIT
+/*!*/;
+DELIMITER ;
+# End of log file
+ROLLBACK /* added by mysqlbinlog */;
+/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
 End of 5.0 tests

=== added file 'mysql-test/std_data/binlog_transaction.000001'
Binary files a/mysql-test/std_data/binlog_transaction.000001	1970-01-01 00:00:00 +0000 and b/mysql-test/std_data/binlog_transaction.000001	2009-09-24 07:57:05 +0000 differ

=== added file 'mysql-test/std_data/binlog_transaction.000002'
Binary files a/mysql-test/std_data/binlog_transaction.000002	1970-01-01 00:00:00 +0000 and b/mysql-test/std_data/binlog_transaction.000002	2009-09-24 07:57:05 +0000 differ

=== added file 'mysql-test/std_data/binlog_transaction.000003'
Binary files a/mysql-test/std_data/binlog_transaction.000003	1970-01-01 00:00:00 +0000 and b/mysql-test/std_data/binlog_transaction.000003	2009-09-24 07:57:05 +0000 differ

=== modified file 'mysql-test/t/mysqlbinlog.test'
--- a/mysql-test/t/mysqlbinlog.test	2009-05-07 14:31:02 +0000
+++ b/mysql-test/t/mysqlbinlog.test	2009-09-24 07:57:05 +0000
@@ -304,4 +304,62 @@ FLUSH LOGS;
 # We do not need the results, just make sure that mysqlbinlog does not crash
 --exec $MYSQL_BINLOG --hexdump --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT  master-bin.000001 >/dev/null
 
+#
+# #46998
+# This test verifies if the 'BEGIN', 'COMMIT' and 'ROLLBACK' are output 
+# in regardless of database filtering
+#
+
+RESET MASTER;
+FLUSH LOGS;
+
+--echo # The following test case was wrtten into binlog_transaction.000001, 
+--echo # binlog_transaction.000002 and binlog_transaction.000003
+--echo # use test;
+--echo # eval create table t1(a int) engine=$engine1_type;
+--echo # use mysql;
+--echo # eval create table t2(a int) engine=$engine2_type;
+--echo # --echo # Transaction begin
+--echo # begin;
+--echo # use test;
+--echo # insert into t1 (a) values (1);
+--echo # use mysql;
+--echo # insert into t2 (a) values (1);
+--echo # eval $transaction_end_type;
+--echo # --echo # Transaction end
+--echo # 
+
+--echo # Test case1: Test if the 'BEGIN' and 'COMMIT' are output for the 'test' database 
+--echo # in above transaction base on innodb engine tables with the following arguments:
+--echo # let $engine1_type= innodb;
+--echo # let $engine2_type= innodb;
+--echo # let $transaction_end_type=commit;
+--echo # 
+--exec $MYSQL_BINLOG --database=test --short-form $MYSQLTEST_VARDIR/std_data_ln/binlog_transaction.000001
+--echo #
+--echo # Test if the 'BEGIN' and 'commit' are output if the database specified is not exist
+--exec $MYSQL_BINLOG --database=not_exist --short-form $MYSQLTEST_VARDIR/std_data_ln/binlog_transaction.000001
+
+--echo # Test case2: Test if the 'BEGIN' and 'ROLLBACK' are output for the 'test' database 
+--echo # in above transaction base on innodb and myisam engine tables with the following arguments:
+--echo # let $engine1_type= innodb;
+--echo # let $engine2_type= myisam;
+--echo # let $transaction_end_type=rollback;
+--echo # 
+--exec $MYSQL_BINLOG --database=test --short-form $MYSQLTEST_VARDIR/std_data_ln/binlog_transaction.000002
+--echo #
+--echo # Test if the 'BEGIN' and 'ROLLBACK' are output if the database specified is not exist
+--exec $MYSQL_BINLOG --database=not_exist --short-form $MYSQLTEST_VARDIR/std_data_ln/binlog_transaction.000002
+
+--echo # Test case3: Test if the 'BEGIN' and 'COMMIT' are output for the 'test' database 
+--echo # in above transaction base on NDB engine tables with the following arguments:
+--echo # let $engine1_type= NDB;
+--echo # let $engine2_type= NDB;
+--echo # let $transaction_end_type=commit;
+--echo #
+--exec $MYSQL_BINLOG --database=test --short-form $MYSQLTEST_VARDIR/std_data_ln/binlog_transaction.000003
+--echo #
+--echo # Test if the 'BEGIN' and 'COMMIT' are output if the database specified is not exist
+--exec $MYSQL_BINLOG --database=not_exist --short-form $MYSQLTEST_VARDIR/std_data_ln/binlog_transaction.000003
+
 --echo End of 5.0 tests


Attachment: [text/bzr-bundle] bzr/dao-gang.qu@sun.com-20090924075705-lg7m8iuofcp0kt27.bundle
Thread
bzr commit into mysql-5.0-bugteam branch (Dao-Gang.Qu:2812) Bug#46998Dao-Gang.Qu24 Sep