List:Commits« Previous MessageNext Message »
From:tomas Date:January 11 2006 7:39am
Subject:bk commit into 5.1 tree (tomas:1.2030)
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.2030 06/01/11 08:39:37 tomas@stripped +4 -0
  adopted handlertons

  sql/sql_db.cc
    1.125 06/01/11 08:39:29 tomas@stripped +6 -2
    adopted handlertons

  sql/handler.h
    1.179 06/01/11 08:39:29 tomas@stripped +22 -10
    adopted handlertons

  sql/handler.cc
    1.208 06/01/11 08:39:29 tomas@stripped +98 -85
    adopted handlertons

  sql/ha_ndbcluster_binlog.cc
    1.7 06/01/11 08:39:29 tomas@stripped +9 -23
    adopted handlertons

# 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/mysql-5.1-wl2325-v6

--- 1.207/sql/handler.cc	2006-01-10 23:49:48 +01:00
+++ 1.208/sql/handler.cc	2006-01-11 08:39:29 +01:00
@@ -2412,113 +2412,125 @@
 }
 
 #ifdef HAVE_NDB_BINLOG
+static my_bool reset_logs_handlerton(THD *thd,
+                                     st_plugin_int *plugin,
+                                     void *unused)
+{
+  handlerton *hton= (handlerton *) plugin->plugin->info;
+  if (hton->state == SHOW_OPTION_YES && hton->reset_logs)
+    hton->reset_logs(thd);
+  return FALSE;
+}
+
 int ha_reset_logs(THD *thd)
 {
-  bool result= 0;
-  handlerton **types;
-  for (types= sys_table_types; *types; types++)
-  {
-    if ((*types)->state == SHOW_OPTION_YES && 
-        (*types)->reset_logs)
-    {
-      if ((*types)->reset_logs(thd))
-        result= 1;
-    }
-  }
-  return result;
+  plugin_foreach(thd, reset_logs_handlerton,
+                 MYSQL_STORAGE_ENGINE_PLUGIN, 0);
+  return 0;
+}
+
+static
+my_bool binlog_index_purge_file_handlerton(THD *thd,
+                                           st_plugin_int *plugin,
+                                           void *file)
+{
+  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;
 }
 
 int ha_binlog_index_purge_file(THD *thd, const char *file)
 {
-  bool result= 0;
-  handlerton **types;
-  for (types= sys_table_types; *types; types++)
-  {
-    if ((*types)->state == SHOW_OPTION_YES && 
-        (*types)->binlog_index_purge_file)
-    {
-      if ((*types)->binlog_index_purge_file(thd, file))
-        result= 1;
-    }
-  }
-  return result;
+  plugin_foreach(thd, binlog_index_purge_file_handlerton,
+                 MYSQL_STORAGE_ENGINE_PLUGIN, (void *)file);
+}
+
+static my_bool reset_slave_handlerton(THD *thd, st_plugin_int *plugin,
+                                      void *unused)
+{
+  handlerton *hton= (handlerton *) plugin->plugin->info;
+  if (hton->state == SHOW_OPTION_YES && hton->reset_slave)
+    hton->reset_slave(thd);
+  return FALSE;
 }
 
 void ha_reset_slave(THD* thd)
 {
-  handlerton **types;
-  for (types= sys_table_types; *types; types++)
-  {
-    if ((*types)->state == SHOW_OPTION_YES && 
-        (*types)->reset_slave)
-    {
-      (*types)->reset_slave(thd);
-    }
-  }
+  plugin_foreach(thd, reset_slave_handlerton,
+                 MYSQL_STORAGE_ENGINE_PLUGIN, 0);
 }
 
-void ha_binlog_wait(THD* thd)
+struct binlog_log_query_st
 {
-  handlerton **types;
-  for (types= sys_table_types; *types; types++)
-  {
-    if ((*types)->state == SHOW_OPTION_YES && 
-        (*types)->binlog_wait)
-    {
-      (*types)->binlog_wait(thd);
-    }
-  }
+  enum_binlog_command binlog_command;
+  const char *query;
+  uint query_length;
+  const char *db;
+  const char *table_name;
+};
+
+static my_bool binlog_log_query_handlerton(THD *thd,
+                                           st_plugin_int *plugin,
+                                           void *args)
+{
+  struct binlog_log_query_st *b= (struct binlog_log_query_st*)args;
+  handlerton *hton= (handlerton *) plugin->plugin->info;
+  if (hton->state == SHOW_OPTION_YES && hton->binlog_log_query)
+    hton->binlog_log_query(thd,
+                           b->binlog_command,
+                           b->query,
+                           b->query_length,
+                           b->db,
+                           b->table_name);
+  return FALSE;
+}
+
+void ha_binlog_log_query(THD *thd, enum_binlog_command binlog_command,
+                         const char *query, uint query_length,
+                         const char *db, const char *table_name)
+{
+  struct binlog_log_query_st b;
+  b.binlog_command= binlog_command;
+  b.query= query;
+  b.query_length= query_length;
+  b.db= db;
+  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;
 }
 
-int ha_binlog_end(THD* thd)
+void ha_binlog_wait(THD* thd)
 {
-  bool result= 0;
-  handlerton **types;
-  for (types= sys_table_types; *types; types++)
-  {
-    if ((*types)->state == SHOW_OPTION_YES && 
-        (*types)->binlog_end)
-    {
-      if ((*types)->binlog_end(thd))
-        result= 1;
-    }
-  }
-  return result;
+  plugin_foreach(thd, binlog_wait_handlerton,
+                 MYSQL_STORAGE_ENGINE_PLUGIN, 0);
 }
 
-int ha_create_database(THD *thd, const char *db, const char *query,
-                       int query_length)
+static my_bool binlog_end_handlerton(THD *thd,
+                                     st_plugin_int *plugin,
+                                     void *unused)
 {
-  bool result= 0;
-  handlerton **types;
-  for (types= sys_table_types; *types; types++)
-  {
-    if ((*types)->state == SHOW_OPTION_YES && 
-        (*types)->create_database)
-    {
-      fprintf(stderr, "%s\n", (*types)->name);
-      if ((*types)->create_database(thd, db, query, query_length))
-        result= 1;
-    }
-  }
-  return result;
+  handlerton *hton= (handlerton *) plugin->plugin->info;
+  if (hton->state == SHOW_OPTION_YES && hton->binlog_end)
+    hton->binlog_end(thd);
+  return FALSE;
 }
 
-int ha_alter_database(THD *thd, const char *db, const char *query,
-                      int query_length)
+int ha_binlog_end(THD* thd)
 {
-  bool result= 0;
-  handlerton **types;
-  for (types= sys_table_types; *types; types++)
-  {
-    if ((*types)->state == SHOW_OPTION_YES && 
-        (*types)->alter_database)
-    {
-      if ((*types)->alter_database(thd, db, query, query_length))
-        result = 1;
-    }
-  }
-  return result;
+  plugin_foreach(thd, binlog_end_handlerton,
+                 MYSQL_STORAGE_ENGINE_PLUGIN, 0);
+  return 0;
 }
 #endif
 
@@ -2805,6 +2817,7 @@
     
     for (ext= file->bas_ext(); *ext; ext++)
     {
+      fprintf(stderr, "%x  %s\n", ext, (char *) *ext);
       while ((old_ext= it++))
       {
         if (!strcmp(old_ext, *ext))

--- 1.178/sql/handler.h	2006-01-10 23:33:07 +01:00
+++ 1.179/sql/handler.h	2006-01-11 08:39:29 +01:00
@@ -205,6 +205,16 @@
 		ROW_TYPE_DYNAMIC, ROW_TYPE_COMPRESSED,
 		ROW_TYPE_REDUNDANT, ROW_TYPE_COMPACT };
 
+enum enum_binlog_command {
+  LOGCOM_CREATE_TABLE,
+  LOGCOM_ALTER_TABLE,
+  LOGCOM_RENAME_TABLE,
+  LOGCOM_DROP_TABLE,
+  LOGCOM_CREATE_DB,
+  LOGCOM_ALTER_DB,
+  LOGCOM_DROP_DB
+};
+
 /* struct to hold information about the table that should be created */
 
 /* Bits in used_fields */
@@ -435,15 +445,19 @@
    bool (*flush_logs)();
    bool (*show_status)(THD *thd, stat_print_fn *print, enum ha_stat_type stat);
    uint32 flags;                                /* global handler flags */
+   /* 
+      Handlerton functions are not set in the different storage
+      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);
+   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);
-   int (*create_database)(THD *thd, const char *db, const char *query,
-                          int query_length);
-   int (*alter_database)(THD *thd, const char *db, const char *query,
-                         int query_length);
 } handlerton;
 
 extern const handlerton default_hton;
@@ -1648,18 +1662,16 @@
 int ha_reset_logs(THD *thd);
 int ha_binlog_index_purge_file(THD *thd, const char *file);
 void ha_reset_slave(THD *thd);
+void ha_binlog_log_query(THD *thd, enum_binlog_command binlog_command,
+                         const char *query, uint query_length,
+                         const char *db, const char *table_name);
 void ha_binlog_wait(THD *thd);
 int ha_binlog_end(THD *thd);
-int ha_create_database(THD *thd, const char *db, const char *query,
-                       int query_length);
-int ha_alter_database(THD *thd, const char *db, const char *query,
-                      int query_length);
 #else
 #define ha_reset_logs(a) 0
 #define ha_binlog_index_purge_file(a,b) 0
 #define ha_reset_slave(a)
+#define ha_binlog_log_query(a,b,c,d,e,f);
 #define ha_binlog_wait(a)
 #define ha_binlog_end(a) 0
-#define ha_create_database(a,b,c,d) 0
-#define ha_alter_database(a,b,c,d) 0
 #endif

--- 1.124/sql/sql_db.cc	2006-01-05 12:55:43 +01:00
+++ 1.125/sql/sql_db.cc	2006-01-11 08:39:29 +01:00
@@ -497,7 +497,9 @@
       query_length= thd->query_length;
     }
 
-    ha_create_database(thd, db, query, query_length);
+    ha_binlog_log_query(thd, LOGCOM_CREATE_DB,
+                        query, query_length,
+                        db, "");
 
     if (mysql_bin_log.is_open())
     {
@@ -573,7 +575,9 @@
     thd->variables.collation_database= thd->db_charset;
   }
 
-  ha_alter_database(thd, db, thd->query, thd->query_length);
+  ha_binlog_log_query(thd, LOGCOM_ALTER_DB,
+                      thd->query, thd->query_length,
+                      db, "");
 
   if (mysql_bin_log.is_open())
   {

--- 1.6/sql/ha_ndbcluster_binlog.cc	2006-01-10 23:30:02 +01:00
+++ 1.7/sql/ha_ndbcluster_binlog.cc	2006-01-11 08:39:29 +01:00
@@ -402,28 +402,15 @@
   DBUG_RETURN(0);
 }
 
-static int
-ndbcluster_create_database(THD *thd, const char *db, const char *query,
-                           int query_length)
+static void
+ndbcluster_binlog_log_query(THD *thd, enum_binlog_command binlog_command,
+                            const char *query, uint query_length,
+                            const char *db, const char *table_name)
 {
-  DBUG_ENTER("ndbcluster_create_database");
-  DBUG_PRINT("enter", ("db: %s  query: %s", db, query));
-  ndbcluster_log_schema_op(thd, 0,
-                           query, query_length,
-                           db, "", 0, 0, SOT_CREATE_DB);
-  DBUG_RETURN(0);
-}
-
-static int
-ndbcluster_alter_database(THD *thd, const char *db, const char *query,
-                          int query_length)
-{
-  DBUG_ENTER("ndbcluster_alter_database");
-  DBUG_PRINT("enter", ("db: %s  query: %s", db, query));
-  ndbcluster_log_schema_op(thd, 0,
-                           query, query_length,
-                           db, "", 0, 0, SOT_ALTER_DB);
-  DBUG_RETURN(0);
+  DBUG_ENTER("ndbcluster_binlog_log_query");
+  DBUG_PRINT("enter", ("db: %s  table_name: %s  query: %s",
+                       db, table_name, query));
+  DBUG_VOID_RETURN;
 }
 
 /*
@@ -515,10 +502,9 @@
   h.binlog_index_purge_file=
     ndbcluster_binlog_index_purge_file;
   h.reset_slave=      ndbcluster_reset_slave;
+  h.binlog_log_query= ndbcluster_binlog_log_query;
   h.binlog_wait=      ndbcluster_binlog_wait;
   h.binlog_end=       ndbcluster_binlog_end;
-  h.create_database=  ndbcluster_create_database;
-  h.alter_database=   ndbcluster_alter_database;
 }
 
 
Thread
bk commit into 5.1 tree (tomas:1.2030)tomas11 Jan