[Commits] Rev 2912: MBug#702303: Spurious `use` statements in output from mysqlbinlog --rewrite-db="a->b" in http://bazaar.launchpad.net/~maria-captains/maria/5.2

knielsen at knielsen-hq.org knielsen at knielsen-hq.org
Thu Jan 13 13:46:58 EET 2011


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

------------------------------------------------------------
revno: 2912
revision-id: knielsen at knielsen-hq.org-20110113114309-e9rp2whci1rgcstk
parent: monty at askmonty.org-20110112155813-n602fefffgp2widb
fixes bug(s): https://launchpad.net/bugs/702303
committer: knielsen at knielsen-hq.org
branch nick: work-5.2-bug702303
timestamp: Thu 2011-01-13 12:43:09 +0100
message:
  MBug#702303: Spurious `use` statements in output from mysqlbinlog --rewrite-db="a->b"
=== modified file 'client/mysqlbinlog.cc'
--- a/client/mysqlbinlog.cc	2010-09-11 18:43:48 +0000
+++ b/client/mysqlbinlog.cc	2011-01-13 11:43:09 +0000
@@ -636,11 +636,16 @@ static bool shall_skip_database(const ch
   producing USE statements by corresponding log event print-functions.
 */
 
-void print_use_stmt(PRINT_EVENT_INFO* pinfo, const char* db, size_t db_len)
+static void
+print_use_stmt(PRINT_EVENT_INFO* pinfo, const Query_log_event *ev)
 {
+  const char* db= ev->db;
+  const size_t db_len= ev->db_len;
+
   // pinfo->db is the current db.
   // If current db is the same as required db, do nothing.
-  if (!db || !memcmp(pinfo->db, db, db_len + 1))
+  if ((ev->flags & LOG_EVENT_SUPPRESS_USE_F) || !db ||
+      !memcmp(pinfo->db, db, db_len + 1))
     return;
 
   // Current db and required db are different.
@@ -779,7 +784,7 @@ Exit_status process_event(PRINT_EVENT_IN
       Query_log_event *qe= (Query_log_event*)ev;
       if (!qe->is_trans_keyword() && shall_skip_database(qe->db))
         goto end;
-      print_use_stmt(print_event_info, qe->db, qe->db_len);
+      print_use_stmt(print_event_info, qe);
       if (opt_base64_output_mode == BASE64_OUTPUT_ALWAYS)
       {
         if ((retval= write_event_header_and_base64(ev, result_file,
@@ -912,7 +917,7 @@ Exit_status process_event(PRINT_EVENT_IN
 
       if (!shall_skip_database(exlq->db))
       {
-        print_use_stmt(print_event_info, exlq->db, exlq->db_len);
+        print_use_stmt(print_event_info, exlq);
         if (fname)
         {
           convert_path_to_forward_slashes(fname);
@@ -1491,7 +1496,7 @@ static int parse_args(int *argc, char***
 */
 static Exit_status safe_connect()
 {
-  /* Close and old connections to MySQL */
+  /* Close any old connections to MySQL */
   if (mysql)
     mysql_close(mysql);
 



More information about the commits mailing list