List:Commits« Previous MessageNext Message »
From:Dao-Gang.Qu Date:September 30 2009 2:50am
Subject:bzr push into mysql-pe branch (Dao-Gang.Qu:3612 to 3613) Bug#46998
View as plain text  
 3613 Dao-Gang.Qu@stripped	2009-09-30 [merge]
      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/suite/binlog/t/binlog_row_mysqlbinlog_db_filter.test
        The test case is updated due to the patch of 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
    modified:
      client/mysqlbinlog.cc
      mysql-test/r/mysqlbinlog.result
      mysql-test/suite/binlog/t/binlog_row_mysqlbinlog_db_filter.test
      mysql-test/t/mysqlbinlog.test
 3612 Tatiana A. Nurnberg	2009-09-29
      merge fixies

    modified:
      libmysqld/lib_sql.cc
=== modified file 'client/mysqlbinlog.cc'
--- a/client/mysqlbinlog.cc	2009-09-27 21:00:41 +0000
+++ b/client/mysqlbinlog.cc	2009-09-30 02:45:14 +0000
@@ -733,7 +733,10 @@ Exit_status process_event(PRINT_EVENT_IN
 
     switch (ev_type) {
     case QUERY_EVENT:
-      if (shall_skip_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) &&  
+          shall_skip_database(((Query_log_event*)ev)->db))
         goto end;
       if (opt_base64_output_mode == BASE64_OUTPUT_ALWAYS)
       {

=== modified file 'mysql-test/r/mysqlbinlog.result'
--- a/mysql-test/r/mysqlbinlog.result	2009-09-29 12:37:09 +0000
+++ b/mysql-test/r/mysqlbinlog.result	2009-09-30 02:45:14 +0000
@@ -473,5 +473,94 @@ IS NOT NULL
 SET @@global.server_id= 1;
 RESET MASTER;
 FLUSH LOGS;
+RESET MASTER;
+FLUSH LOGS;
+#
+# Test if the 'BEGIN', 'ROLLBACK' and 'COMMIT' are output if the database specified is exist
+/*!40019 SET @@session.max_insert_delayed_threads=0*/;
+/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
+DELIMITER /*!*/;
+ROLLBACK/*!*/;
+use test/*!*/;
+SET TIMESTAMP=1253783037/*!*/;
+SET @@session.pseudo_thread_id=999999999/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.sql_mode=0/*!*/;
+SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
+/*!\C latin1 *//*!*/;
+SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
+SET @@session.lc_time_names=0/*!*/;
+SET @@session.collation_database=DEFAULT/*!*/;
+create table t1(a int) engine= innodb
+/*!*/;
+SET TIMESTAMP=1253783037/*!*/;
+BEGIN
+/*!*/;
+SET TIMESTAMP=1253783037/*!*/;
+insert into t1 (a) values (1)
+/*!*/;
+COMMIT/*!*/;
+SET TIMESTAMP=1253783037/*!*/;
+create table t3(a int) engine= innodb
+/*!*/;
+SET TIMESTAMP=1253783037/*!*/;
+BEGIN
+/*!*/;
+SET TIMESTAMP=1253783037/*!*/;
+insert into t3 (a) values (2)
+/*!*/;
+SET TIMESTAMP=1253783037/*!*/;
+ROLLBACK
+/*!*/;
+SET TIMESTAMP=1253783037/*!*/;
+create table t5(a int) engine= NDB
+/*!*/;
+SET TIMESTAMP=1253783037/*!*/;
+BEGIN
+/*!*/;
+SET TIMESTAMP=1253783037/*!*/;
+insert into t5 (a) values (3)
+/*!*/;
+SET TIMESTAMP=1253783037/*!*/;
+COMMIT
+/*!*/;
+DELIMITER ;
+# End of log file
+ROLLBACK /* added by mysqlbinlog */;
+/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
+#
+# Test if the 'BEGIN', 'ROLLBACK' 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 /*!*/;
+ROLLBACK/*!*/;
+SET TIMESTAMP=1253783037/*!*/;
+SET @@session.pseudo_thread_id=999999999/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.sql_mode=0/*!*/;
+SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
+/*!\C latin1 *//*!*/;
+SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
+SET @@session.lc_time_names=0/*!*/;
+SET @@session.collation_database=DEFAULT/*!*/;
+BEGIN
+/*!*/;
+COMMIT/*!*/;
+SET TIMESTAMP=1253783037/*!*/;
+BEGIN
+/*!*/;
+SET TIMESTAMP=1253783037/*!*/;
+ROLLBACK
+/*!*/;
+SET TIMESTAMP=1253783037/*!*/;
+BEGIN
+/*!*/;
+SET TIMESTAMP=1253783037/*!*/;
+COMMIT
+/*!*/;
+DELIMITER ;
+# End of log file
+ROLLBACK /* added by mysqlbinlog */;
+/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
 End of 5.0 tests
 End of 5.1 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-30 02:01:52 +0000 differ

=== modified file 'mysql-test/suite/binlog/t/binlog_row_mysqlbinlog_db_filter.test'
--- a/mysql-test/suite/binlog/t/binlog_row_mysqlbinlog_db_filter.test	2009-06-07 22:28:08 +0000
+++ b/mysql-test/suite/binlog/t/binlog_row_mysqlbinlog_db_filter.test	2009-09-30 02:31:25 +0000
@@ -112,17 +112,22 @@ while($i)
   # remove unecessary files
   -- remove_file $outfile.1
   -- remove_file $outfile.2
-
+  
+  #
+  # The two tests are canceled since we introduced the patch of bug#46998,  
+  # which will make mydsqlbinlog output the 'BEGIN', 'COMMIT' and 'ROLLBACK' 
+  # in regardless of database filtering
+  #
   # assertion: events for database test are filtered
-  if (`SELECT INSTR(@b42941_output.1, 'test')`)
-  {
-    -- echo **** ERROR **** Database name 'test' FOUND in mysqlbinlog output ($flags $outfile.1).
-  }
-
-  if (`SELECT INSTR(@b42941_output.2, 'test')`)
-  {
-    -- echo **** ERROR **** Database name 'test' FOUND in mysqlbinlog output ($flags $outfile.2).
-  }
+  #if (`SELECT INSTR(@b42941_output.1, 'test')`)
+  #{
+    #-- echo **** ERROR **** Database name 'test' FOUND in mysqlbinlog output ($flags $outfile.1).
+  #}
+
+  #if (`SELECT INSTR(@b42941_output.2, 'test')`)
+  #{
+    #-- echo **** ERROR **** Database name 'test' FOUND in mysqlbinlog output ($flags $outfile.2).
+  #}
 
   # assertion: events for database b42941 are not filtered
   if (!`SELECT INSTR(@b42941_output.1, 'b42941')`)

=== modified file 'mysql-test/t/mysqlbinlog.test'
--- a/mysql-test/t/mysqlbinlog.test	2009-09-29 12:37:09 +0000
+++ b/mysql-test/t/mysqlbinlog.test	2009-09-30 02:45:14 +0000
@@ -377,6 +377,68 @@ 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;
+
+# The following three test cases were wrtten into binlog_transaction.000001
+# Test case1: Test if the 'BEGIN' and 'COMMIT' are output for the 'test' database 
+# in transaction1 base on innodb engine tables
+# use test;
+# create table t1(a int) engine= innodb;
+# use mysql;
+# create table t2(a int) engine= innodb;
+# Transaction1 begin
+# begin;
+# use test;
+# insert into t1 (a) values (1);
+# use mysql;
+# insert into t2 (a) values (1);
+# commit;
+# Transaction1 end
+
+# Test case2: Test if the 'BEGIN' and 'ROLLBACK' are output for the 'test' database 
+# in transaction2 base on innodb and myisam engine tables
+# use test;
+# create table t3(a int) engine= innodb;
+# use mysql;
+# create table t4(a int) engine= myisam;
+# Transaction2 begin
+# begin;
+# use test;
+# insert into t3 (a) values (2);
+# use mysql;
+# insert into t4 (a) values (2);
+# rollback;
+# Transaction2 end
+
+# Test case3: Test if the 'BEGIN' and 'COMMIT' are output for the 'test' database 
+# in transaction3 base on NDB engine tables
+# use test;
+# create table t5(a int) engine= NDB;
+# use mysql;
+# create table t6(a int) engine= NDB;
+# Transaction3 begin
+# begin;
+# use test;
+# insert into t5 (a) values (3);
+# use mysql;
+# insert into t6 (a) values (3);
+# commit;
+# Transaction3 end
+
+--echo #
+--echo # Test if the 'BEGIN', 'ROLLBACK' and 'COMMIT' are output if the database specified is exist
+--exec $MYSQL_BINLOG --database=test --short-form $MYSQLTEST_VARDIR/std_data/binlog_transaction.000001
+--echo #
+--echo # Test if the 'BEGIN', 'ROLLBACK' and 'COMMIT' are output if the database specified is not exist
+--exec $MYSQL_BINLOG --database=not_exist --short-form $MYSQLTEST_VARDIR/std_data/binlog_transaction.000001
+
 --echo End of 5.0 tests
 
 --echo End of 5.1 tests


Attachment: [text/bzr-bundle] bzr/dao-gang.qu@sun.com-20090930024514-kuup19wk6u99uomd.bundle
Thread
bzr push into mysql-pe branch (Dao-Gang.Qu:3612 to 3613) Bug#46998Dao-Gang.Qu30 Sep