List:Commits« Previous MessageNext Message »
From:tomas Date:January 12 2006 9:27am
Subject:bk commit into 5.1 tree (tomas:1.2036)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of tomas. When tomas 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.2036 06/01/12 10:27:00 tomas@stripped +5 -0
  changed hton handling for ndb binlog

  sql/handler.h
    1.180 06/01/12 10:26:47 tomas@stripped +11 -6
    changed hton handling for ndb binlog

  sql/handler.cc
    1.210 06/01/12 10:26:47 tomas@stripped +65 -61
    changed hton handling for ndb binlog

  sql/ha_ndbcluster_binlog.cc
    1.11 06/01/12 10:26:47 tomas@stripped +24 -6
    changed hton handling for ndb binlog

  mysql-test/t/rpl_row_basic_11bugs.test
    1.2 06/01/12 10:26:47 tomas@stripped +2 -0
    adjusted test

  mysql-test/r/rpl_row_basic_11bugs.result
    1.2 06/01/12 10:26:47 tomas@stripped +3 -1
    adjusted test

# 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:	tomas
# Host:	poseidon.ndb.mysql.com
# Root:	/home/tomas/v6

--- 1.209/sql/handler.cc	2006-01-11 11:31:01 +01:00
+++ 1.210/sql/handler.cc	2006-01-12 10:26:47 +01:00
@@ -2412,53 +2412,90 @@
 }
 
 #ifdef HAVE_NDB_BINLOG
-static my_bool reset_logs_handlerton(THD *thd,
-                                     st_plugin_int *plugin,
-                                     void *unused)
+/*
+  TODO: change this into a dynamic struct
+  List<handlerton> does not work as
+  1. binlog_end is called when MEM_ROOT is gone
+  2. cannot work with thd MEM_ROOT as memory should be freed
+*/
+#define MAX_HTON_LIST_ST 63
+struct hton_list_st
 {
-  handlerton *hton= (handlerton *) plugin->plugin->info;
-  if (hton->state == SHOW_OPTION_YES && hton->reset_logs)
-    hton->reset_logs(thd);
+  handlerton *hton[MAX_HTON_LIST_ST];
+  uint sz;
+};
+
+struct binlog_func_st
+{
+  enum_binlog_func fn;
+  void *arg;
+};
+
+/*
+  Listing handlertons first to avoid recursive calls and deadlock
+*/
+static my_bool binlog_func_list(THD *thd, st_plugin_int *plugin, void *arg)
+{
+  hton_list_st *hton_list= (hton_list_st *)arg;
+  handlerton *hton= (handlerton *) plugin->plugin->info;
+  if (hton->state == SHOW_OPTION_YES && hton->binlog_func)
+  {
+    uint sz= hton_list->sz;
+    if (sz == MAX_HTON_LIST_ST-1)
+    {
+      /* list full */
+      return FALSE;
+    }
+    hton_list->hton[sz]= hton;
+    hton_list->sz= sz+1;
+  }
+  return FALSE;
+}
+
+static my_bool binlog_func_foreach(THD *thd, binlog_func_st *bfn)
+{
+  handlerton *hton;
+  hton_list_st hton_list;
+  hton_list.sz= 0;
+  plugin_foreach(thd, binlog_func_list,
+                 MYSQL_STORAGE_ENGINE_PLUGIN, &hton_list);
+
+  uint i= 0, sz= hton_list.sz;
+  while(i < sz)
+    hton_list.hton[i++]->binlog_func(thd, bfn->fn, bfn->arg);
   return FALSE;
 }
 
 int ha_reset_logs(THD *thd)
 {
-  plugin_foreach(thd, reset_logs_handlerton,
-                 MYSQL_STORAGE_ENGINE_PLUGIN, 0);
+  binlog_func_st bfn= {BFN_RESET_LOGS, 0};
+  binlog_func_foreach(thd, &bfn);
   return 0;
 }
 
-static
-my_bool binlog_index_purge_file_handlerton(THD *thd,
-                                           st_plugin_int *plugin,
-                                           void *file)
+void ha_reset_slave(THD* thd)
 {
-  handlerton *hton= (handlerton *) plugin->plugin->info;
-  if (hton->state == SHOW_OPTION_YES && hton->binlog_index_purge_file)
-    hton->binlog_index_purge_file(thd, (const char *)file);
-  return FALSE;
+  binlog_func_st bfn= {BFN_RESET_SLAVE, 0};
+  binlog_func_foreach(thd, &bfn);
 }
 
-int ha_binlog_index_purge_file(THD *thd, const char *file)
+void ha_binlog_wait(THD* thd)
 {
-  plugin_foreach(thd, binlog_index_purge_file_handlerton,
-                 MYSQL_STORAGE_ENGINE_PLUGIN, (void *)file);
+  binlog_func_st bfn= {BFN_BINLOG_WAIT, 0};
+  binlog_func_foreach(thd, &bfn);
 }
 
-static my_bool reset_slave_handlerton(THD *thd, st_plugin_int *plugin,
-                                      void *unused)
+int ha_binlog_end(THD* thd)
 {
-  handlerton *hton= (handlerton *) plugin->plugin->info;
-  if (hton->state == SHOW_OPTION_YES && hton->reset_slave)
-    hton->reset_slave(thd);
-  return FALSE;
+  binlog_func_st bfn= {BFN_BINLOG_END, 0};
+  binlog_func_foreach(thd, &bfn);
+  return 0;
 }
 
-void ha_reset_slave(THD* thd)
+int ha_binlog_index_purge_file(THD *thd, const char *file)
 {
-  plugin_foreach(thd, reset_slave_handlerton,
-                 MYSQL_STORAGE_ENGINE_PLUGIN, 0);
+  binlog_func_st bfn= {BFN_BINLOG_PURGE_FILE, (void *)file};
+  binlog_func_foreach(thd, &bfn);
 }
 
 struct binlog_log_query_st
@@ -2498,39 +2535,6 @@
   b.table_name= table_name;
   plugin_foreach(thd, binlog_log_query_handlerton,
                  MYSQL_STORAGE_ENGINE_PLUGIN, &b);
-}
-
-static my_bool binlog_wait_handlerton(THD *thd,
-                                      st_plugin_int *plugin,
-                                      void *unused)
-{
-  handlerton *hton= (handlerton *) plugin->plugin->info;
-  if (hton->state == SHOW_OPTION_YES && hton->binlog_wait)
-    hton->binlog_wait(thd);
-  return FALSE;
-}
-
-void ha_binlog_wait(THD* thd)
-{
-  plugin_foreach(thd, binlog_wait_handlerton,
-                 MYSQL_STORAGE_ENGINE_PLUGIN, 0);
-}
-
-static my_bool binlog_end_handlerton(THD *thd,
-                                     st_plugin_int *plugin,
-                                     void *unused)
-{
-  handlerton *hton= (handlerton *) plugin->plugin->info;
-  if (hton->state == SHOW_OPTION_YES && hton->binlog_end)
-    hton->binlog_end(thd);
-  return FALSE;
-}
-
-int ha_binlog_end(THD* thd)
-{
-  plugin_foreach(thd, binlog_end_handlerton,
-                 MYSQL_STORAGE_ENGINE_PLUGIN, 0);
-  return 0;
 }
 #endif
 

--- 1.179/sql/handler.h	2006-01-11 08:39:29 +01:00
+++ 1.180/sql/handler.h	2006-01-12 10:26:47 +01:00
@@ -205,6 +205,14 @@
 		ROW_TYPE_DYNAMIC, ROW_TYPE_COMPRESSED,
 		ROW_TYPE_REDUNDANT, ROW_TYPE_COMPACT };
 
+enum enum_binlog_func {
+  BFN_RESET_LOGS=        1,
+  BFN_RESET_SLAVE=       2,
+  BFN_BINLOG_WAIT=       3,
+  BFN_BINLOG_END=        4,
+  BFN_BINLOG_PURGE_FILE= 5
+};
+
 enum enum_binlog_command {
   LOGCOM_CREATE_TABLE,
   LOGCOM_ALTER_TABLE,
@@ -354,7 +362,8 @@
     handlerton structure version
    */
   const int interface_version;
-#define MYSQL_HANDLERTON_INTERFACE_VERSION 0x0000
+/* last version change: 0x0001 in 5.1.6 */
+#define MYSQL_HANDLERTON_INTERFACE_VERSION 0x0001
 
 
   /*
@@ -450,14 +459,10 @@
       engines static initialization.  They are initialized at handler init.
       Thus, leave them last in the struct.
    */
-   int (*reset_logs)(THD *thd);
-   int (*binlog_index_purge_file)(THD *thd, const char *file);
-   void (*reset_slave)(THD *thd);
+   int (*binlog_func)(THD *thd, enum_binlog_func fn, void *arg);
    void (*binlog_log_query)(THD *thd, enum_binlog_command binlog_command,
                             const char *query, uint query_length,
                             const char *db, const char *table_name);
-   void (*binlog_wait)(THD *thd);
-   int (*binlog_end)(THD *thd);
 } handlerton;
 
 extern const handlerton default_hton;

--- 1.1/mysql-test/r/rpl_row_basic_11bugs.result	2005-12-27 12:04:14 +01:00
+++ 1.2/mysql-test/r/rpl_row_basic_11bugs.result	2006-01-12 10:26:47 +01:00
@@ -9,6 +9,7 @@
 SHOW DATABASES;
 Database
 information_schema
+cluster_replication
 mysql
 test
 test_ignore
@@ -26,7 +27,7 @@
 INSERT INTO t2 VALUES (3,3), (4,4);
 SHOW BINLOG EVENTS;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-master-bin.000001	4	Format_desc	1	102	Server ver: 5.1.5-alpha-debug-log, Binlog ver: 4
+master-bin.000001	4	Format_desc	1	102	Server ver: VERSION, Binlog ver: 4
 master-bin.000001	102	Query	1	195	use `test`; CREATE TABLE t1 (a INT, b INT)
 master-bin.000001	195	Table_map	1	235	test.t1
 master-bin.000001	235	Write_rows	1	282	
@@ -34,6 +35,7 @@
 SHOW DATABASES;
 Database
 information_schema
+cluster_replication
 mysql
 test
 USE test;

--- 1.1/mysql-test/t/rpl_row_basic_11bugs.test	2005-12-27 12:03:58 +01:00
+++ 1.2/mysql-test/t/rpl_row_basic_11bugs.test	2006-01-12 10:26:47 +01:00
@@ -17,6 +17,8 @@
 CREATE TABLE t2 (a INT, b INT);
 SHOW TABLES;
 INSERT INTO t2 VALUES (3,3), (4,4);
+let $VERSION=`select version()`;
+--replace_result $VERSION VERSION
 SHOW BINLOG EVENTS;
 sync_slave_with_master;
 --echo **** On Slave ****

--- 1.10/sql/ha_ndbcluster_binlog.cc	2006-01-11 17:28:45 +01:00
+++ 1.11/sql/ha_ndbcluster_binlog.cc	2006-01-12 10:26:47 +01:00
@@ -497,16 +497,34 @@
 /*
   Initialize the binlog part of the ndb handlerton
 */
+static int ndbcluster_binlog_func(THD *thd, enum_binlog_func fn, void *arg)
+{
+  switch(fn)
+  {
+  case BFN_RESET_LOGS:
+    ndbcluster_reset_logs(thd);
+    break;
+  case BFN_RESET_SLAVE:
+    ndbcluster_reset_slave(thd);
+    break;
+  case BFN_BINLOG_WAIT:
+    ndbcluster_binlog_wait(thd);
+    break;
+  case BFN_BINLOG_END:
+    ndbcluster_binlog_end(thd);
+    break;
+  case BFN_BINLOG_PURGE_FILE:
+    ndbcluster_binlog_index_purge_file(thd, (const char *)arg);
+    break;
+  }
+  return 0;
+}
+
 void ndbcluster_binlog_init_handlerton()
 {
   handlerton &h= ndbcluster_hton;
-  h.reset_logs=       ndbcluster_reset_logs;
-  h.binlog_index_purge_file=
-    ndbcluster_binlog_index_purge_file;
-  h.reset_slave=      ndbcluster_reset_slave;
+  h.binlog_func=      ndbcluster_binlog_func;
   h.binlog_log_query= ndbcluster_binlog_log_query;
-  h.binlog_wait=      ndbcluster_binlog_wait;
-  h.binlog_end=       ndbcluster_binlog_end;
 }
 
 
Thread
bk commit into 5.1 tree (tomas:1.2036)tomas12 Jan