List:Commits« Previous MessageNext Message »
From:tomas Date:January 26 2006 8:26am
Subject:bk commit into 5.1 tree (tomas:1.2075)
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.2075 06/01/26 09:26:24 tomas@stripped +7 -0
  wl2325, distribution of schema operations between mysql servers

  sql/ha_ndbcluster_binlog.h
    1.3 06/01/26 09:26:19 tomas@stripped +6 -4
    wl2325, distribution of schema operations between mysql servers

  sql/ha_ndbcluster_binlog.cc
    1.4 06/01/26 09:26:19 tomas@stripped +86 -17
    wl2325, distribution of schema operations between mysql servers

  sql/ha_ndbcluster.cc
    1.244 06/01/26 09:26:18 tomas@stripped +42 -23
    wl2325, distribution of schema operations between mysql servers

  mysql-test/t/ndb_multi_row.test
    1.2 06/01/26 09:26:18 tomas@stripped +0 -2
    wl2325, distribution of schema operations between mysql servers

  mysql-test/t/ndb_database.test
    1.3 06/01/26 09:26:18 tomas@stripped +0 -28
    wl2325, distribution of schema operations between mysql servers

  mysql-test/r/ndb_multi_row.result
    1.2 06/01/26 09:26:18 tomas@stripped +0 -6
    wl2325, distribution of schema operations between mysql servers

  mysql-test/r/ndb_database.result
    1.2 06/01/26 09:26:18 tomas@stripped +0 -14
    wl2325, distribution of schema operations between mysql servers

# 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

--- 1.243/sql/ha_ndbcluster.cc	2006-01-18 12:43:23 +01:00
+++ 1.244/sql/ha_ndbcluster.cc	2006-01-26 09:26:18 +01:00
@@ -4136,7 +4136,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);
@@ -4313,7 +4313,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),
@@ -4326,7 +4326,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."
@@ -4600,7 +4600,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);
@@ -5334,6 +5334,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");
@@ -5417,14 +5429,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;
@@ -5562,7 +5574,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=
@@ -5645,7 +5657,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)); 
   }
 
@@ -5769,18 +5781,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);
@@ -7343,9 +7345,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);
@@ -9222,6 +9223,7 @@
 {
   DBUG_ENTER("ha_ndbcluster::alter_tablespace");
 
+  int is_tablespace= 0;
   Ndb *ndb= check_ndb_in_thd(thd);
   if (ndb == NULL)
   {
@@ -9260,6 +9262,7 @@
       DBUG_PRINT("error", ("createDatafile returned %d", error));
       goto ndberror;
     }
+    is_tablespace= 1;
     break;
   }
   case (ALTER_TABLESPACE):
@@ -9303,6 +9306,7 @@
 			   info->ts_alter_tablespace_type));
       DBUG_RETURN(HA_ADMIN_NOT_IMPLEMENTED);
     }
+    is_tablespace= 1;
     break;
   }
   case (CREATE_LOGFILE_GROUP):
@@ -9368,6 +9372,7 @@
     {
       goto ndberror;
     }
+    is_tablespace= 1;
     break;
   }
   case (DROP_LOGFILE_GROUP):
@@ -9393,6 +9398,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.1/mysql-test/r/ndb_database.result	2005-04-22 15:27:54 +02:00
+++ 1.2/mysql-test/r/ndb_database.result	2006-01-26 09:26:18 +01:00
@@ -1,8 +1,4 @@
-drop table if exists t1;
 drop database if exists mysqltest;
-drop table if exists t1;
-drop database if exists mysqltest;
-create database mysqltest;
 create database mysqltest;
 create table mysqltest.t1 (a int primary key, b int) engine=ndb;
 use mysqltest;
@@ -10,18 +6,8 @@
 Tables_in_mysqltest
 t1
 drop database mysqltest;
-use mysqltest;
-show tables;
-Tables_in_mysqltest
 create database mysqltest;
-create table mysqltest.t1 (c int, d int primary key) engine=ndb;
 use mysqltest;
 show tables;
 Tables_in_mysqltest
-t1
 drop database mysqltest;
-use mysqltest;
-show tables;
-Tables_in_mysqltest
-drop table if exists t1;
-drop database if exists mysqltest;

--- 1.2/mysql-test/t/ndb_database.test	2005-07-28 02:21:45 +02:00
+++ 1.3/mysql-test/t/ndb_database.test	2006-01-26 09:26:18 +01:00
@@ -1,13 +1,7 @@
 -- source include/have_ndb.inc
--- source include/have_multi_ndb.inc
 -- source include/not_embedded.inc
 
 --disable_warnings
-connection server1;
-drop table if exists t1;
-drop database if exists mysqltest;
-connection server2;
-drop table if exists t1;
 drop database if exists mysqltest;
 --enable_warnings
 
@@ -15,38 +9,16 @@
 # Check that all tables in a database are dropped when database is dropped
 #
 
-connection server1;
-create database mysqltest;
-
-connection server2;
 create database mysqltest;
 create table mysqltest.t1 (a int primary key, b int) engine=ndb;
 use mysqltest;
 show tables;
 
-connection server1;
 drop database mysqltest;
-
-connection server2;
-use mysqltest;
-show tables;
-
-connection server1;
 create database mysqltest;
-create table mysqltest.t1 (c int, d int primary key) engine=ndb;
 use mysqltest;
 show tables;
 
-connection server2;
 drop database mysqltest;
-
-connection server1;
-use mysqltest;
-show tables;
-
---disable_warnings
-drop table if exists t1;
-drop database if exists mysqltest;
---enable_warnings
 
 # End of 4.1 tests

--- 1.1/mysql-test/r/ndb_multi_row.result	2006-01-12 19:50:38 +01:00
+++ 1.2/mysql-test/r/ndb_multi_row.result	2006-01-26 09:26:18 +01:00
@@ -50,15 +50,9 @@
 select * from t3;
 a	b	c	last_col
 1	Hi!	89	Longtext column
-show status like 'handler_discover%';
-Variable_name	Value
-Handler_discover	1
 show tables like 't4';
 Tables_in_test (t4)
 t4
-show status like 'handler_discover%';
-Variable_name	Value
-Handler_discover	2
 show tables;
 Tables_in_test
 t1

--- 1.1/mysql-test/t/ndb_multi_row.test	2006-01-12 19:50:44 +01:00
+++ 1.2/mysql-test/t/ndb_multi_row.test	2006-01-26 09:26:18 +01:00
@@ -66,9 +66,7 @@
 connection server1;
 select * from t1;
 select * from t3;
-show status like 'handler_discover%';
 show tables like 't4';
-show status like 'handler_discover%';
 show tables;
 
 drop table t1, t2, t3, t4;

--- 1.3/sql/ha_ndbcluster_binlog.cc	2006-01-17 15:36:50 +01:00
+++ 1.4/sql/ha_ndbcluster_binlog.cc	2006-01-26 09:26:19 +01:00
@@ -36,6 +36,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
@@ -232,7 +237,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)
@@ -334,7 +339,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;
@@ -343,7 +348,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--;
@@ -360,7 +365,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");
@@ -387,7 +392,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");
@@ -412,6 +417,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;
 }
 
@@ -484,7 +520,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");
@@ -820,7 +856,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)
   {
@@ -864,6 +900,10 @@
     break;
   case SOT_ALTER_DB:
     break;
+  case SOT_TABLESPACE:
+    break;
+  case SOT_LOGFILE_GROUP:
+    break;
   default:
     abort(); /* should not happen, programming error */
   }
@@ -1299,13 +1339,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",
@@ -1358,6 +1405,10 @@
           }
           DBUG_RETURN(0);
         }
+        case SOT_TABLESPACE:
+        case SOT_LOGFILE_GROUP:
+          log_query= 1;
+          break;
         }
         if (log_query)
         {
@@ -1365,7 +1416,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;
         }
       }
@@ -2414,7 +2465,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.
@@ -2455,7 +2516,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");
@@ -2483,16 +2545,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)
@@ -2699,6 +2767,7 @@
   delete thd;
 
   ndb_binlog_thread_running= -1;
+  ndb_binlog_running= 0;
   (void) pthread_cond_signal(&injector_cond);
 
   DBUG_PRINT("exit", ("ndb_binlog_thread"));

--- 1.2/sql/ha_ndbcluster_binlog.h	2006-01-20 12:54:56 +01:00
+++ 1.3/sql/ha_ndbcluster_binlog.h	2006-01-26 09:26:19 +01:00
@@ -38,7 +38,9 @@
   SOT_DROP_DB,
   SOT_CREATE_DB,
   SOT_ALTER_DB,
-  SOT_CLEAR_SLOCK
+  SOT_CLEAR_SLOCK,
+  SOT_TABLESPACE,
+  SOT_LOGFILE_GROUP
 };
 
 const uint max_ndb_nodes= 64; /* multiple of 32 */
@@ -90,7 +92,8 @@
                                  NDB_SHARE *share);
 void ndb_rep_event_name(String *event_name,
                         const char *db, const char *tbl);
-
+int ndb_create_table_from_engine(THD *thd, const char *db,
+                                 const char *table_name);
 int ndbcluster_binlog_start();
 pthread_handler_t ndb_binlog_thread_func(void *arg);
 
@@ -101,8 +104,7 @@
 extern NDB_SHARE *apply_status_share;
 extern NDB_SHARE *schema_share;
 
-extern THD *injector_thd;
-extern int ndb_binlog_thread_running;
+extern int ndb_binlog_running;
 
 bool
 ndbcluster_show_status_binlog(THD* thd, stat_print_fn *stat_print,
Thread
bk commit into 5.1 tree (tomas:1.2075)tomas26 Jan