List:Internals« Previous MessageNext Message »
From:Mats Kindahl Date:April 15 2005 10:43am
Subject:bk commit into 5.1 tree (mats:1.1800)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of mats. When mats does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.1800 05/04/15 12:43:17 mats@stripped +6 -0
  Merge with 5.1 clone for WL#2325.

  sql/slave.cc
    1.245 05/04/15 12:43:13 mats@stripped +0 -4
    Merge with 5.1 clone for WL#2325.

  sql/log.cc
    1.162 05/04/15 12:43:13 mats@stripped +0 -3
    Merge with 5.1 clone for WL#2325.

  sql/sql_class.cc
    1.178 05/04/15 12:34:09 mats@stripped +0 -0
    Auto merged

  sql/mysqld.cc
    1.449 05/04/15 12:34:08 mats@stripped +0 -0
    Auto merged

  sql/log_event.h
    1.113 05/04/15 12:34:08 mats@stripped +0 -0
    Auto merged

  sql/log_event.cc
    1.175 05/04/15 12:34:08 mats@stripped +0 -0
    Auto merged

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	mats
# Host:	romeo.kindahl.net
# Root:	/home/bk/w2325-mysql-5.1/RESYNC

--- 1.161/sql/log.cc	2005-04-14 14:42:59 +02:00
+++ 1.162/sql/log.cc	2005-04-15 12:43:13 +02:00
@@ -1558,11 +1558,15 @@
   bool error= 1;
   DBUG_ENTER("MYSQL_LOG::write(Log_event*)");
   
+#ifdef HAVE_REPLICATION
   /*
     Let the event decide if it want to go to the binlog.
   */
-  if (!event_info->write_to_binlog())
+  if (!event_info->write_to_binlog()) {
+    DBUG_PRINT("info",("!write_to_binlog()"));
     DBUG_RETURN(0);		// Silently succeed
+  }
+#endif
 
   pthread_mutex_lock(&LOCK_log);
 
@@ -1581,12 +1585,10 @@
        "do the involved tables match (to be implemented)
         binlog_[wild_]{do|ignore}_table?" (WL#1049)"
     */
-    if ((thd && !(thd->options & OPTION_BIN_LOG)) ||
-	(!binlog_filter->db_ok(local_db)))
+    if (thd && !(thd->options & OPTION_BIN_LOG))
     {
       VOID(pthread_mutex_unlock(&LOCK_log));
-      DBUG_PRINT("info",("db_ok('%s')==%d", local_db, 
-			 binlog_filter->db_ok(local_db)));
+      DBUG_PRINT("info",("!OPTION_BIN_LOG"));
       DBUG_RETURN(0);
     }
 #endif /* HAVE_REPLICATION */

--- 1.174/sql/log_event.cc	2005-04-14 08:48:39 +02:00
+++ 1.175/sql/log_event.cc	2005-04-15 12:34:08 +02:00
@@ -457,6 +457,13 @@
   DBUG_RETURN(0);
 }
 
+bool Log_event::
+do_write_to_binlog() const
+{
+  extern bool check_binlog_db(const char*);
+  const char* the_db = const_cast<Log_event*>(this)->get_db();
+  return check_binlog_db(the_db);
+}
 
 /*
   Log_event::pack_info()
@@ -4911,6 +4918,13 @@
 {
   my_free(m_rows_buf, MYF(MY_WME));
   m_rows_buf = m_rows_cur = m_rows_end = NULL;
+  m_dbnam = m_tblnam = NULL; 
+}
+
+const char* Rows_log_event::
+get_db()
+{ 
+  return m_dbnam; 
 }
 
 void Rows_log_event::
@@ -5249,15 +5263,17 @@
 write_data_body(IO_CACHE* file)
 {
   DBUG_ENTER("Table_map_log_event::write_data_body(IO_CACHE*)");
-  // To ensure that we can use VLE in the future.
-  DBUG_ASSERT(m_dblen < 128);
-  DBUG_ASSERT(m_tbllen < 128);
-  DBUG_ASSERT(m_colcnt < 128);
-  
   DBUG_PRINT("info", ("m_dblen = %d; m_dbnam = %s", 
 		      m_dblen, m_dbnam));
   DBUG_PRINT("info", ("m_tbllen = %d; m_tblnam = %s", 
 		      m_tbllen, m_tblnam));
+
+  // To ensure that we can use VLE in the future.
+  DBUG_ASSERT(m_dblen < 128);
+  DBUG_ASSERT(m_tbllen < 128);
+  DBUG_ASSERT(m_colcnt < 128);
+  DBUG_ASSERT(m_dbnam != NULL);
+  DBUG_ASSERT(m_tblnam != NULL);
 
   byte const dbuf[] = { m_dblen };
   byte const tbuf[] = { m_tbllen };

--- 1.112/sql/log_event.h	2005-04-14 08:48:39 +02:00
+++ 1.113/sql/log_event.h	2005-04-15 12:34:08 +02:00
@@ -661,6 +661,7 @@
   const char* get_type_str();
 
 #ifndef MYSQL_CLIENT
+#ifdef HAVE_REPLICATION
   /*
     Predicate to check if this event should be written to the binary
     log.  This function is called by MYSQL_LOG to decide if this event
@@ -688,21 +689,24 @@
   bool can_be_cached() const {
       return do_can_be_cached();
   }
-#endif
 
-private:
-#ifndef MYSQL_CLIENT
+protected:
   /*
     Primitive for testing if the event should be written to the binary log.
     The subclasses should override this if they do not want to be written to
-    the binary log.  By default, everything goes to the binary log.
+    the binary log.  
+
+    By default, the event goes to the binary log if the database is OK given
+    the binlog-do-db and binlog-ignore-db options.
+
+    This member function is protected so that subclasses can use it in
+    implementing the checks, for example: some subclass might decide that this
+    test should not be made.
 
     Return 'true' if the event should be written to the binary log, 'false'
     otherwise.
    */
-  virtual bool do_write_to_binlog() const {
-    return true;
-  }
+  virtual bool do_write_to_binlog() const;
 
   /*
     Primitive for testing if the event can be cached at all.
@@ -711,6 +715,7 @@
     return true;
   }
 #endif
+#endif
 };
 
 /*
@@ -1714,10 +1719,12 @@
 
 private:
 #ifndef MYSQL_CLIENT
+#ifdef HAVE_REPLICATION
   virtual bool do_write_to_binlog() const {
-    return opt_binlog_row_level;
+    return opt_binlog_row_level && Log_event::do_write_to_binlog();
   }
 #endif
+#endif
 };
 
 
@@ -1783,7 +1790,7 @@
 
   virtual bool write_data_header(IO_CACHE* file);
   virtual bool write_data_body(IO_CACHE* file);
-  virtual const char* get_db() { return m_dbnam; }
+  virtual const char* get_db();
 
 protected:
   // The constructors are protected since you're supposed to inherit
@@ -1819,16 +1826,20 @@
   bool   m_is_transactional;	// The table handler is transactional
 
 private:
+
 #ifndef MYSQL_CLIENT
+#ifdef HAVE_REPLICATION
+
   virtual bool do_write_to_binlog() const {
-    return opt_binlog_row_level;
+    // We deliberately do not check the databases here; see
+    // Log_event::do_write_to_binlog(). (Not there yet!!!)
+    return opt_binlog_row_level && Log_event::do_write_to_binlog();
   }
 
   virtual bool do_can_be_cached() const {
     return opt_binlog_row_level && m_is_transactional;
   }
 
-#ifdef HAVE_REPLICATION
   /*
     Primitive to prepare for a sequence of row executions.
 

--- 1.448/sql/mysqld.cc	2005-04-14 14:19:44 +02:00
+++ 1.449/sql/mysqld.cc	2005-04-15 12:34:08 +02:00
@@ -315,7 +315,8 @@
 
 my_bool opt_binlog_row_level = FALSE; // Statement-level is default
 const char *binlog_format_names[]= {"disabled","statement", "row"};
-const char *opt_binlog_format= binlog_format_names[0];
+enum Binlog_format { BF_NONE, BF_STMT, BF_ROW };
+const char *opt_binlog_format= binlog_format_names[BF_NONE];
 
 unsigned long opt_binlog_rows_event_max_size = 1024;
 
@@ -6150,10 +6151,10 @@
     break;
   case (int) OPT_BIN_LOG:
     opt_bin_log=1;
-    if (opt_binlog_format == binlog_format_names[0])
+    if (opt_binlog_format == binlog_format_names[BF_NONE])
     {
       opt_binlog_row_level= FALSE;
-      opt_binlog_format= binlog_format_names[1];
+      opt_binlog_format= binlog_format_names[BF_STMT];
     }
     break;
   case (int) OPT_ERROR_LOG_FILE:
@@ -6221,14 +6222,14 @@
     break;
   }
   case OPT_BINLOG_FORMAT:
-    if (strcmp(argument,binlog_format_names[2]) == 0) 
+    if (strcmp(argument,binlog_format_names[BF_ROW]) == 0) 
     {
-      opt_binlog_format= binlog_format_names[2];
+      opt_binlog_format= binlog_format_names[BF_ROW];
       opt_binlog_row_level = TRUE;
     }
-    else if (strcmp(argument, binlog_format_names[1]) == 0) 
+    else if (strcmp(argument, binlog_format_names[BF_STMT]) == 0) 
     {
-      opt_binlog_format= binlog_format_names[1];
+      opt_binlog_format= binlog_format_names[BF_STMT];
       opt_binlog_row_level = FALSE;
     }
     else 
@@ -6490,7 +6491,7 @@
     if (opt_ndbcluster)
     {
       have_ndbcluster= SHOW_OPTION_YES;
-      opt_binlog_format= binlog_format_names[2];
+      opt_binlog_format= binlog_format_names[BF_ROW];
       opt_binlog_row_level= TRUE;
     }
     else

--- 1.244/sql/slave.cc	2005-04-08 13:30:52 +02:00
+++ 1.245/sql/slave.cc	2005-04-15 12:43:13 +02:00
@@ -919,7 +919,6 @@
   return (db ? db : "");
 }
 
-
 static int init_strvar_from_file(char *var, int max_size, IO_CACHE *f,
 				 const char *default_val)
 {

--- 1.177/sql/sql_class.cc	2005-04-14 14:19:46 +02:00
+++ 1.178/sql/sql_class.cc	2005-04-15 12:34:09 +02:00
@@ -1901,8 +1901,10 @@
     Rows_log_event* const 
 	ev = new RowsEventT(this, table, tid, cols, is_transactional);
     ev->server_id = server_id; // I don't like this, it's too easy to forget. 
-    if (flush_and_set_pending_event(ev))
+    if (!ev->write_to_binlog() || flush_and_set_pending_event(ev)) {
+      delete ev;
       DBUG_RETURN(NULL);
+    }
     DBUG_RETURN(ev);
   }
   DBUG_RETURN(pending);
@@ -2141,7 +2143,7 @@
   Table_map_log_event 
     the_event(this, table, table_id, is_transactional);
 
-  if (mysql_bin_log.write(&the_event))
+  if (the_event.write_to_binlog() && mysql_bin_log.write(&the_event))
     DBUG_RETURN(1);
   DBUG_RETURN(0);
 }
Thread
bk commit into 5.1 tree (mats:1.1800)Mats Kindahl15 Apr