List:Commits« Previous MessageNext Message »
From:Dao-Gang.Qu Date:September 18 2009 4:42am
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-18
      Bug #46998  mysqlbinlog can't output BEGIN even if the database is included in a transaction
      
      The 'BEGIN' just is output with associated database, so mysqlbinlog can't output BEGIN 
      with unassociated database even if the database is included in a transaction.
      
      To fix the problem, mysqlbinlog will output 'BEGIN' for the database included in transaction.
     @ client/mysqlbinlog.cc
        Added a judgement condition, so that mysqlbinlog will output 'BEGIN' 
        for the database included in transaction.
     @ mysql-test/r/binlog_transaction_complete.result
        Test result for bug#46998
     @ mysql-test/t/binlog_transaction_complete.test
        Added test to verify if the "BEGIN" is output for the database included in transaction.

    added:
      mysql-test/r/binlog_transaction_complete.result
      mysql-test/t/binlog_transaction_complete.test
    modified:
      client/mysqlbinlog.cc
=== modified file 'client/mysqlbinlog.cc'
--- a/client/mysqlbinlog.cc	2009-06-29 13:17:01 +0000
+++ b/client/mysqlbinlog.cc	2009-09-18 04:40:13 +0000
@@ -557,7 +557,8 @@ int process_event(PRINT_EVENT_INFO *prin
 
     switch (ev_type) {
     case QUERY_EVENT:
-      if (check_database(((Query_log_event*)ev)->db))
+      if (check_database(((Query_log_event*)ev)->db) &&
+          strncmp(((Query_log_event*)ev)->query, "BEGIN", 5)) 
         goto end;
       ev->print(result_file, print_event_info);
       break;

=== added file 'mysql-test/r/binlog_transaction_complete.result'
--- a/mysql-test/r/binlog_transaction_complete.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/binlog_transaction_complete.result	2009-09-18 04:40:13 +0000
@@ -0,0 +1,55 @@
+use test;
+create table if not exists t1(a int) engine=innodb;
+use mysql;
+create table if not exists t2(a int) engine=innodb;
+SET TIMESTAMP=100000;
+# Transaction begin
+begin;
+use test;
+insert into t1 (a) values (1);
+use mysql;
+insert into t2 (a) values (1);
+commit;
+# Transaction commit
+FLUSH LOGS;
+# Test if the "BEGIN" is output for the 'test' database included in above transaction
+/*!40019 SET @@session.max_insert_delayed_threads=0*/;
+/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
+DELIMITER /*!*/;
+SET TIMESTAMP=100000/*!*/;
+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
+/*!*/;
+use test/*!*/;
+SET TIMESTAMP=100000/*!*/;
+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" is 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=100000/*!*/;
+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*/;
+use test;
+drop table t1;
+use mysql;
+drop table t2;

=== added file 'mysql-test/t/binlog_transaction_complete.test'
--- a/mysql-test/t/binlog_transaction_complete.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/binlog_transaction_complete.test	2009-09-18 04:40:13 +0000
@@ -0,0 +1,33 @@
+#
+# This test verifies if the "BEGIN" is output for the database included in transaction.
+#
+-- source include/have_log_bin.inc
+-- source include/have_innodb.inc
+
+use test;
+create table if not exists t1(a int) engine=innodb;
+use mysql;
+create table if not exists t2(a int) engine=innodb;
+let $pos0_master= query_get_value(SHOW MASTER STATUS, Position, 1);
+SET TIMESTAMP=100000;
+--echo # Transaction begin
+begin;
+use test;
+insert into t1 (a) values (1);
+use mysql;
+insert into t2 (a) values (1);
+commit;
+--echo # Transaction commit
+FLUSH LOGS;
+--echo # Test if the "BEGIN" is output for the 'test' database included in above transaction
+--exec $MYSQL_BINLOG --database=test --start-position=$pos0_master --short-form $MYSQLTEST_VARDIR/log/master-bin.000001
+--echo # 
+--echo # Test if the "BEGIN" is output if the database specified is not exist
+--exec $MYSQL_BINLOG --database=not_exist --start-position=$pos0_master --short-form $MYSQLTEST_VARDIR/log/master-bin.000001
+
+use test;
+drop table t1;
+use mysql;
+drop table t2;
+
+


Attachment: [text/bzr-bundle] bzr/dao-gang.qu@sun.com-20090918044013-8yi3pxdhh2mkn6wa.bundle
Thread
bzr commit into mysql-5.0-bugteam branch (Dao-Gang.Qu:2812) Bug#46998Dao-Gang.Qu18 Sep
  • Re: bzr commit into mysql-5.0-bugteam branch (Dao-Gang.Qu:2812)Bug#46998He Zhenxing19 Sep
    • Re: bzr commit into mysql-5.0-bugteam branch (Dao-Gang.Qu:2812)Bug#46998Daogang Qu21 Sep
      • Re: bzr commit into mysql-5.0-bugteam branch (Dao-Gang.Qu:2812)Bug#46998He Zhenxing21 Sep
        • Re: bzr commit into mysql-5.0-bugteam branch (Dao-Gang.Qu:2812)Bug#46998Daogang Qu21 Sep
          • Re: bzr commit into mysql-5.0-bugteam branch (Dao-Gang.Qu:2812)Bug#46998He Zhenxing21 Sep