List:Commits« Previous MessageNext Message »
From:tomas Date:January 26 2006 8:28am
Subject:bk commit into 5.1 tree (tomas:1.2082)
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.2082 06/01/26 09:28:16 tomas@stripped +2 -0
  Merge tulin@stripped:/home/bk/mysql-5.1-new
  into  poseidon.ndb.mysql.com:/home/tomas/mysql-5.1-new

  sql/ha_ndbcluster_binlog.cc
    1.5 06/01/26 09:28:04 tomas@stripped +0 -0
    Auto merged

  sql/ha_ndbcluster.cc
    1.245 06/01/26 09:28:04 tomas@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:	tomas
# Host:	poseidon.ndb.mysql.com
# Root:	/home/tomas/mysql-5.1-new/RESYNC

--- 1.244/sql/ha_ndbcluster.cc	2006-01-25 22:00:25 +01:00
+++ 1.245/sql/ha_ndbcluster.cc	2006-01-26 09:28:04 +01:00
@@ -4166,7 +4166,7 @@
     if ((my_errno= write_ndb_file(name)))
       DBUG_RETURN(my_errno);
 #ifdef HAVE_NDB_BINLOG
-    if (ndb_binlog_thread_running > 0)
+    if (ndb_binlog_running > 0)
       ndbcluster_create_binlog_setup(get_ndb(), name2, m_dbname, m_tabname, 0);
 #endif /* HAVE_NDB_BINLOG */
     DBUG_RETURN(my_errno);
@@ -4343,7 +4343,7 @@
       if (ndbcluster_create_event(ndb, t, event_name.c_ptr(), share) < 0)
       {
         /* this is only a serious error if the binlog is on */
-	if (share && ndb_binlog_thread_running > 0)
+	if (share && ndb_binlog_running > 0)
 	{
           push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
                               ER_GET_ERRMSG, ER(ER_GET_ERRMSG),
@@ -4356,7 +4356,7 @@
         sql_print_information("NDB Binlog: CREATE TABLE Event: %s",
                               event_name.c_ptr());
 
-      if (share && ndb_binlog_thread_running > 0 &&
+      if (share && ndb_binlog_running > 0 &&
           ndbcluster_create_event_ops(share, t, event_name.c_ptr()) < 0)
       {
         sql_print_error("NDB Binlog: FAILED CREATE TABLE event operations."
@@ -4630,7 +4630,7 @@
   }
 #ifdef HAVE_NDB_BINLOG
   NDB_SHARE *share= 0;
-  if (ndb_binlog_thread_running > 0 &&
+  if (ndb_binlog_running > 0 &&
       (share= get_share(from, 0, false)))
   {
     int r= rename_share(share, to);
@@ -5365,6 +5365,18 @@
 /*
   find all tables in ndb and discover those needed
 */
+int ndb_create_table_from_engine(THD *thd, const char *db,
+                                 const char *table_name)
+{
+  LEX *old_lex= thd->lex, newlex;
+  thd->lex= &newlex;
+  newlex.current_select= NULL;
+  lex_start(thd, (const uchar*) "", 0);
+  int res= ha_create_table_from_engine(thd, db, table_name);
+  thd->lex= old_lex;
+  return res;
+}
+
 int ndbcluster_find_all_files(THD *thd)
 {
   DBUG_ENTER("ndbcluster_find_all_files");
@@ -5448,14 +5460,14 @@
       {
         /* ToDo 4.1 database needs to be created if missing */
         pthread_mutex_lock(&LOCK_open);
-        if (ha_create_table_from_engine(thd, elmt.database, elmt.name))
+        if (ndb_create_table_from_engine(thd, elmt.database, elmt.name))
         {
           /* ToDo 4.1 handle error */
         }
         pthread_mutex_unlock(&LOCK_open);
       }
 #ifdef HAVE_NDB_BINLOG
-      else if (ndb_binlog_thread_running > 0)
+      else if (ndb_binlog_running > 0)
       {
         /* set up replication for this table */
         NDB_SHARE *share;
@@ -5593,7 +5605,7 @@
 
 #ifdef HAVE_NDB_BINLOG
   /* setup logging to binlog for all discovered tables */
-  if (ndb_binlog_thread_running > 0)
+  if (ndb_binlog_running > 0)
   {
     char *end;
     char *end1=
@@ -5676,7 +5688,7 @@
   while ((file_name=it2++))
   {  
     DBUG_PRINT("info", ("Table %s need discovery", file_name));
-    if (ha_create_table_from_engine(thd, db, file_name) == 0)
+    if (ndb_create_table_from_engine(thd, db, file_name) == 0)
       files->push_back(thd->strdup(file_name)); 
   }
 
@@ -5800,18 +5812,8 @@
   pthread_mutex_init(&ndbcluster_mutex,MY_MUTEX_INIT_FAST);
 #ifdef HAVE_NDB_BINLOG
   /* start the ndb injector thread */
-  if (opt_bin_log)
-  {
-    if (binlog_row_based)
-    {
-      if (ndbcluster_binlog_start())
-        goto ndbcluster_init_error;
-    }
-    else
-    {
-      sql_print_error("NDB: only row based binary logging is supported");
-    }
-  }
+  if (ndbcluster_binlog_start())
+    goto ndbcluster_init_error;
 #endif /* HAVE_NDB_BINLOG */
   
   pthread_mutex_init(&LOCK_ndb_util_thread, MY_MUTEX_INIT_FAST);
@@ -7374,9 +7376,8 @@
   ndbcluster_util_inited= 1;
 
 #ifdef HAVE_NDB_BINLOG
-  /* If running, signal injector thread that all is setup */
-  if (ndb_binlog_thread_running > 0)
-    pthread_cond_signal(&injector_cond);
+  /* Signal injector thread that all is setup */
+  pthread_cond_signal(&injector_cond);
 #endif
 
   set_timespec(abstime, 0);
@@ -9253,6 +9254,7 @@
 {
   DBUG_ENTER("ha_ndbcluster::alter_tablespace");
 
+  int is_tablespace= 0;
   Ndb *ndb= check_ndb_in_thd(thd);
   if (ndb == NULL)
   {
@@ -9291,6 +9293,7 @@
       DBUG_PRINT("error", ("createDatafile returned %d", error));
       goto ndberror;
     }
+    is_tablespace= 1;
     break;
   }
   case (ALTER_TABLESPACE):
@@ -9334,6 +9337,7 @@
 			   info->ts_alter_tablespace_type));
       DBUG_RETURN(HA_ADMIN_NOT_IMPLEMENTED);
     }
+    is_tablespace= 1;
     break;
   }
   case (CREATE_LOGFILE_GROUP):
@@ -9399,6 +9403,7 @@
     {
       goto ndberror;
     }
+    is_tablespace= 1;
     break;
   }
   case (DROP_LOGFILE_GROUP):
@@ -9424,6 +9429,20 @@
     DBUG_RETURN(HA_ADMIN_NOT_IMPLEMENTED);
   }
   }
+
+  if (is_tablespace)
+    ndbcluster_log_schema_op(thd, 0,
+                             thd->query, thd->query_length,
+                             "", info->tablespace_name,
+                             0, 0,
+                             SOT_TABLESPACE);
+  else
+    ndbcluster_log_schema_op(thd, 0,
+                             thd->query, thd->query_length,
+                             "", info->logfile_group_name,
+                             0, 0,
+                             SOT_LOGFILE_GROUP);
+
   DBUG_RETURN(FALSE);
 
 ndberror:

--- 1.4/sql/ha_ndbcluster_binlog.cc	2006-01-25 22:00:26 +01:00
+++ 1.5/sql/ha_ndbcluster_binlog.cc	2006-01-26 09:28:04 +01:00
@@ -41,6 +41,11 @@
    0 if never started
 */
 int ndb_binlog_thread_running= 0;
+/*
+  Flag showing if the ndb binlog should be created, if so == 1
+  0 if not
+*/
+int ndb_binlog_running= 0;
 
 /*
   Global reference to the ndb injector thread THD oject
@@ -237,7 +242,7 @@
 
   share->op= 0;
   share->table= 0;
-  if (ndb_binlog_thread_running <= 0)
+  if (ndb_binlog_running <= 0)
   {
     DBUG_ASSERT(_table != 0);
     if (_table->s->primary_key == MAX_KEY)
@@ -343,7 +348,7 @@
 */
 static void ndbcluster_binlog_wait(THD *thd)
 {
-  if (ndb_binlog_thread_running > 0)
+  if (ndb_binlog_running > 0)
   {
     DBUG_ENTER("ndbcluster_binlog_wait");
     const char *save_info= thd ? thd->proc_info : 0;
@@ -352,7 +357,7 @@
     if (thd)
       thd->proc_info= "Waiting for ndbcluster binlog update to "
 	"reach current position";
-    while (count && ndb_binlog_thread_running > 0 &&
+    while (count && ndb_binlog_running > 0 &&
            ndb_latest_handled_binlog_epoch < wait_epoch)
     {
       count--;
@@ -369,7 +374,7 @@
 */
 static int ndbcluster_reset_logs(THD *thd)
 {
-  if (ndb_binlog_thread_running <= 0)
+  if (ndb_binlog_running <= 0)
     return 0;
 
   DBUG_ENTER("ndbcluster_reset_logs");
@@ -396,7 +401,7 @@
 static int
 ndbcluster_binlog_index_purge_file(THD *thd, const char *file)
 {
-  if (ndb_binlog_thread_running <= 0)
+  if (ndb_binlog_running <= 0)
     return 0;
 
   DBUG_ENTER("ndbcluster_binlog_index_purge_file");
@@ -421,6 +426,37 @@
   DBUG_ENTER("ndbcluster_binlog_log_query");
   DBUG_PRINT("enter", ("db: %s  table_name: %s  query: %s",
                        db, table_name, query));
+  enum SCHEMA_OP_TYPE type;
+  int log= 0;
+  switch (binlog_command)
+  {
+  case LOGCOM_CREATE_TABLE:
+    type= SOT_CREATE_TABLE;
+    break;
+  case LOGCOM_ALTER_TABLE:
+    type= SOT_ALTER_TABLE;
+    break;
+  case LOGCOM_RENAME_TABLE:
+    type= SOT_RENAME_TABLE;
+    break;
+  case LOGCOM_DROP_TABLE:
+    type= SOT_DROP_TABLE;
+    break;
+  case LOGCOM_CREATE_DB:
+    type= SOT_CREATE_DB;
+    log= 1;
+    break;
+  case LOGCOM_ALTER_DB:
+    type= SOT_ALTER_DB;
+    log= 1;
+    break;
+  case LOGCOM_DROP_DB:
+    type= SOT_DROP_DB;
+    break;
+  }
+  if (log)
+    ndbcluster_log_schema_op(thd, 0, query, query_length,
+                             db, table_name, 0, 0, type);
   DBUG_VOID_RETURN;
 }
 
@@ -493,7 +529,7 @@
 ****************************************************************/
 static void ndbcluster_reset_slave(THD *thd)
 {
-  if (ndb_binlog_thread_running <= 0)
+  if (ndb_binlog_running <= 0)
     return;
 
   DBUG_ENTER("ndbcluster_reset_slave");
@@ -829,7 +865,7 @@
                              enum SCHEMA_OP_TYPE type)
 {
   DBUG_ENTER("ndbcluster_log_schema_op");
-#ifdef NOT_YET
+#if 1 //def NOT_YET
   Thd_ndb *thd_ndb= get_thd_ndb(thd);
   if (!thd_ndb)
   {
@@ -873,6 +909,10 @@
     break;
   case SOT_ALTER_DB:
     break;
+  case SOT_TABLESPACE:
+    break;
+  case SOT_LOGFILE_GROUP:
+    break;
   default:
     abort(); /* should not happen, programming error */
   }
@@ -1308,13 +1348,20 @@
           schema_list->push_back(schema, mem_root);
           log_query= 0;
           break;
-        case SOT_CREATE_TABLE:
-          /* fall through */
         case SOT_RENAME_TABLE:
           /* fall through */
         case SOT_ALTER_TABLE:
+          /* fall through */
+          if (ndb_binlog_running > 0)
+          {
+            log_query= 1;
+            break; /* discovery will be handled by binlog */
+          }
+          /* fall through */
+        case SOT_CREATE_TABLE:
+          /* fall through */
           pthread_mutex_lock(&LOCK_open);
-          if (ha_create_table_from_engine(thd, schema->db, schema->name))
+          if (ndb_create_table_from_engine(thd, schema->db, schema->name))
           {
             sql_print_error("Could not discover table '%s.%s' from "
                             "binlog schema event '%s' from node %d",
@@ -1367,6 +1414,10 @@
           }
           DBUG_RETURN(0);
         }
+        case SOT_TABLESPACE:
+        case SOT_LOGFILE_GROUP:
+          log_query= 1;
+          break;
         }
         if (log_query)
         {
@@ -1374,7 +1425,7 @@
           thd->db= schema->db;
           thd->binlog_query(THD::STMT_QUERY_TYPE, schema->query,
                             schema->query_length, FALSE,
-                            schema->name[0] == 0);
+                            schema->name[0] == 0 || thd->db[0] == 0);
           thd->db= thd_db_save;
         }
       }
@@ -2494,7 +2545,17 @@
   injector_thd= thd;
   injector_ndb= ndb;
   ndb_binlog_thread_running= 1;
-
+  if (opt_bin_log)
+  {
+    if (binlog_row_based)
+    {
+      ndb_binlog_running= 1;
+    }
+    else
+    {
+      sql_print_error("NDB: only row based binary logging is supported");
+    }
+  }
   /*
     We signal the thread that started us that we've finished
     starting up.
@@ -2535,7 +2596,8 @@
   {
     static char db[]= "";
     thd->db= db;
-    open_binlog_index(thd, &binlog_tables, &binlog_index);
+    if (ndb_binlog_running)
+      open_binlog_index(thd, &binlog_tables, &binlog_index);
     if (!apply_status_share)
     {
       sql_print_error("NDB: Could not get apply status share");
@@ -2563,16 +2625,22 @@
     thd->set_time();
     
     /* wait for event or 1000 ms */
-    Uint64 gci, schema_gci;
-    int res= ndb->pollEvents(1000, &gci);
-    int schema_res= schema_ndb->pollEvents(0, &schema_gci);
+    Uint64 gci= 0, schema_gci;
+    int res= 0, tot_poll_wait= 1000;
+    if (ndb_binlog_running)
+    {
+      res= ndb->pollEvents(tot_poll_wait, &gci);
+      tot_poll_wait= 0;
+    }
+    int schema_res= schema_ndb->pollEvents(tot_poll_wait, &schema_gci);
     ndb_latest_received_binlog_epoch= gci;
 
     while (gci > schema_gci && schema_res >= 0)
       schema_res= schema_ndb->pollEvents(10, &schema_gci);
 
     if ((abort_loop || do_ndbcluster_binlog_close_connection) &&
-        ndb_latest_handled_binlog_epoch >= g_latest_trans_gci)
+        (ndb_latest_handled_binlog_epoch >= g_latest_trans_gci ||
+         ndb_binlog_running == 0))
       break; /* Shutting down server */
 
     if (binlog_index && binlog_index->s->version < refresh_version)
@@ -2783,6 +2851,7 @@
   delete thd;
 
   ndb_binlog_thread_running= -1;
+  ndb_binlog_running= 0;
   (void) pthread_cond_signal(&injector_cond);
 
   DBUG_PRINT("exit", ("ndb_binlog_thread"));
Thread
bk commit into 5.1 tree (tomas:1.2082)tomas26 Jan