[Commits] Rev 2908: Make mysqlbinlog omit redundant `use` around BEGIN/SAVEPOINT/COMMIT/ROLLBACK in 5.0 binlogs in http://bazaar.launchpad.net/~maria-captains/maria/5.2

knielsen at knielsen-hq.org knielsen at knielsen-hq.org
Thu Jan 13 15:15:07 EET 2011


At http://bazaar.launchpad.net/~maria-captains/maria/5.2

------------------------------------------------------------
revno: 2908
revision-id: knielsen at knielsen-hq.org-20110113131507-j9snfp7gwqqp3rre
parent: knielsen at knielsen-hq.org-20110111080654-9yevqumhx6dvmefa
committer: knielsen at knielsen-hq.org
branch nick: work-5.2-percona-mwl47
timestamp: Thu 2011-01-13 14:15:07 +0100
message:
  Make mysqlbinlog omit redundant `use` around BEGIN/SAVEPOINT/COMMIT/ROLLBACK in 5.0 binlogs
  
  This is a merge of percona patch mysqlbinlog_fix.patch.
  
  Apparently, MySQL 5.0 does not flag BEGIN/SAVEPOINT/COMMIT/ROLLBACK statements
  in its binlogs with LOG_EVENT_SUPPRESS_USE_F like 5.1+ does. This causes
  unnecessary `use` statements around such statements when the binlog is dumped
  by mysqlbinlog.
  
  Fix by always suppressing the output of `use` for these statements.
=== modified file 'client/mysqlbinlog.cc'
--- a/client/mysqlbinlog.cc	2011-01-10 13:53:09 +0000
+++ b/client/mysqlbinlog.cc	2011-01-13 13:15:07 +0000
@@ -842,8 +842,19 @@ Exit_status process_event(PRINT_EVENT_IN
     case QUERY_EVENT:
     {
       Query_log_event *qe= (Query_log_event*)ev;
-      if (!qe->is_trans_keyword() && shall_skip_database(qe->db))
-        goto end;
+      if (!qe->is_trans_keyword())
+      {
+        if (shall_skip_database(qe->db))
+          goto end;
+      }
+      else
+      {
+        /*
+          In case the event for one of these statements is obtained
+          from binary log 5.0, make it compatible with 5.1
+        */
+        qe->flags|= LOG_EVENT_SUPPRESS_USE_F;
+      }
       print_use_stmt(print_event_info, qe->db, qe->db_len);
       if (opt_base64_output_mode == BASE64_OUTPUT_ALWAYS)
       {

=== modified file 'mysql-test/r/mysqlbinlog.result'
--- a/mysql-test/r/mysqlbinlog.result	2011-01-10 13:53:09 +0000
+++ b/mysql-test/r/mysqlbinlog.result	2011-01-13 13:15:07 +0000
@@ -222,7 +222,6 @@ ROLLBACK /* added by mysqlbinlog */;
 /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
 DELIMITER /*!*/;
 ROLLBACK/*!*/;
-use test/*!*/;
 SET TIMESTAMP=1108844556/*!*/;
 SET @@session.pseudo_thread_id=999999999/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
@@ -230,6 +229,7 @@ SET @@session.lc_time_names=0/*!*/;
 SET @@session.collation_database=DEFAULT/*!*/;
 BEGIN
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=1108844555/*!*/;
 insert t1 values (1)
 /*!*/;
@@ -241,7 +241,6 @@ Warning: The option '--position' is depr
 /*!40019 SET @@session.max_insert_delayed_threads=0*/;
 /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
 DELIMITER /*!*/;
-use test/*!*/;
 SET TIMESTAMP=1108844556/*!*/;
 SET @@session.pseudo_thread_id=999999999/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
@@ -249,6 +248,7 @@ SET @@session.lc_time_names=0/*!*/;
 SET @@session.collation_database=DEFAULT/*!*/;
 BEGIN
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=1108844555/*!*/;
 insert t1 values (1)
 /*!*/;
@@ -584,7 +584,6 @@ SET @@session.lc_time_names=0/*!*/;
 SET @@session.collation_database=DEFAULT/*!*/;
 BEGIN
 /*!*/;
-use test/*!*/;
 SET TIMESTAMP=1266652094/*!*/;
 SavePoint mixed_cases
 /*!*/;
@@ -595,11 +594,9 @@ INSERT INTO db1.t2 VALUES("in savepoint 
 SET TIMESTAMP=1266652094/*!*/;
 INSERT INTO db1.t1 VALUES(40)
 /*!*/;
-use test/*!*/;
 SET TIMESTAMP=1266652094/*!*/;
 ROLLBACK TO mixed_cases
 /*!*/;
-use db1/*!*/;
 SET TIMESTAMP=1266652094/*!*/;
 INSERT INTO db1.t2 VALUES("after rollback to")
 /*!*/;
@@ -627,7 +624,6 @@ SET @@session.lc_time_names=0/*!*/;
 SET @@session.collation_database=DEFAULT/*!*/;
 BEGIN
 /*!*/;
-use test/*!*/;
 SET TIMESTAMP=1266652094/*!*/;
 SavePoint mixed_cases
 /*!*/;



More information about the commits mailing list