MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Dao-Gang.Qu Date:August 18 2009 2:16am
Subject:bzr commit into mysql-5.0-bugteam branch (Dao-Gang.Qu:2789) Bug#23890
View as plain text  
#At file:///home/daogangq/mysql/bzrwork/bug23890/mysql-5.0-bugteam/ based on revid:epotemkin@stripped

 2789 Dao-Gang.Qu@stripped	2009-08-18
      Bug #23890  	mysqlbinlog outputs COMMIT unnecessarily when single database is used
      
      mysqlbinlog --database=bar N-bin.000003 >003bar.txt
      will output all the COMMITs in the binary log even if the database argument 'bar' isn't mentioned 
      in the binary log. The COMMITS isn't associated with database in the binary log, so the COMMITS 
      will be output in any situation.
      
      To fix the problem, we need record and update the using database from context. So that the COMMITs 
      will be output in the following two cases:
      1. The database argument is consistent with the using database.
      2. The database argument is NULL.
     @ client/mysqlbinlog.cc
        Added database_using[] array to record and update the using database from context.

    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-08-18 02:16:42 +0000
@@ -42,9 +42,11 @@
 
 
 #define CLIENT_CAPABILITIES	(CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG | CLIENT_LOCAL_FILES)
+#define DATABASE_NAME_LENGTH    256
 
 char server_version[SERVER_VERSION_LENGTH];
 ulong server_id = 0;
+char database_using[DATABASE_NAME_LENGTH];
 
 // needed by net_serv.c
 ulong bytes_sent = 0L, bytes_received = 0L;
@@ -557,6 +559,8 @@ int process_event(PRINT_EVENT_INFO *prin
 
     switch (ev_type) {
     case QUERY_EVENT:
+      /* Update the using database name */
+      strcpy(database_using, ((Query_log_event*)ev)->db);
       if (check_database(((Query_log_event*)ev)->db))
         goto end;
       ev->print(result_file, print_event_info);
@@ -564,6 +568,8 @@ int process_event(PRINT_EVENT_INFO *prin
     case CREATE_FILE_EVENT:
     {
       Create_file_log_event* ce= (Create_file_log_event*)ev;
+      /* Update the using database name */
+      strcpy(database_using, ce->db);
       /*
         We test if this event has to be ignored. If yes, we don't save
         this event; this will have the good side-effect of ignoring all
@@ -644,6 +650,8 @@ Create_file event for file_id: %u\n",exv
       Execute_load_query_log_event *exlq= (Execute_load_query_log_event*)ev;
       char *fname= load_processor.grab_fname(exlq->file_id);
 
+      /* Update the using database name */
+      strcpy(database_using, exlq->db);
       if (check_database(exlq->db))
       {
         if (fname)
@@ -662,6 +670,16 @@ Create_file event for file_id: %u\n",exv
 Begin_load_query event for file_id: %u\n", exlq->file_id);
       break;
     }
+    case INTVAR_EVENT:
+    case XID_EVENT:
+    {
+      /* If the database argument is not NULL and inconsistent with 
+         the using database, go to end. Else, print the event info */
+      if (check_database(database_using))
+        goto end;
+      ev->print(result_file, print_event_info);
+      break;
+    }
     default:
       ev->print(result_file, print_event_info);
     }


Attachment: [text/bzr-bundle] bzr/dao-gang.qu@sun.com-20090818021642-a5gy7avbs810u2hh.bundle
Thread
bzr commit into mysql-5.0-bugteam branch (Dao-Gang.Qu:2789) Bug#23890Dao-Gang.Qu18 Aug