MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Martin Skold Date:November 15 2006 10:14am
Subject:bk commit into 5.1 tree (mskold:1.2322) BUG#21495
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of marty. When marty 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@stripped, 2006-11-15 11:13:49+01:00, mskold@stripped +6 -0
  bug #21495  Alter table from x engine to ndb and back can cause issue with drop DB:disable distributed drop database if a database contains local tables

  mysql-test/r/ndb_multi.result@stripped, 2006-11-15 11:12:07+01:00, mskold@stripped +24 -0
    bug #21495  Alter table from x engine to ndb and back can cause issue with drop DB:disable distributed drop database if a database contains local tables

  mysql-test/t/ndb_multi.test@stripped, 2006-11-15 11:12:42+01:00, mskold@stripped +37 -0
    bug #21495  Alter table from x engine to ndb and back can cause issue with drop DB:disable distributed drop database if a database contains local tables

  sql/ha_ndbcluster_binlog.cc@stripped, 2006-11-15 11:12:07+01:00, mskold@stripped +46 -8
    bug #21495  Alter table from x engine to ndb and back can cause issue with drop DB:disable distributed drop database if a database contains local tables

  sql/ha_ndbcluster_binlog.h@stripped, 2006-11-15 11:12:07+01:00, mskold@stripped +1 -0
    bug #21495  Alter table from x engine to ndb and back can cause issue with drop DB:disable distributed drop database if a database contains local tables

  sql/sql_show.cc@stripped, 2006-11-15 11:12:07+01:00, mskold@stripped +0 -6
    bug #21495  Alter table from x engine to ndb and back can cause issue with drop DB:disable distributed drop database if a database contains local tables

  sql/sql_show.h@stripped, 2006-11-15 11:12:07+01:00, mskold@stripped +9 -0
    bug #21495  Alter table from x engine to ndb and back can cause issue with drop DB:disable distributed drop database if a database contains local tables

# 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:	mskold
# Host:	linux.site
# Root:	/windows/Linux_space/MySQL/mysql-5.1-new-ndb

--- 1.374/sql/sql_show.cc	2006-11-15 11:14:03 +01:00
+++ 1.375/sql/sql_show.cc	2006-11-15 11:14:03 +01:00
@@ -491,13 +491,7 @@ bool mysqld_show_column_types(THD *thd)
     FIND_FILES_DIR      no such directory, or directory can't be read
 */
 
-enum find_files_result {
-  FIND_FILES_OK,
-  FIND_FILES_OOM,
-  FIND_FILES_DIR
-};
 
-static
 find_files_result
 find_files(THD *thd, List<char> *files, const char *db,
            const char *path, const char *wild, bool dir)

--- 1.2/sql/sql_show.h	2006-11-15 11:14:03 +01:00
+++ 1.3/sql/sql_show.h	2006-11-15 11:14:03 +01:00
@@ -10,6 +10,15 @@ struct st_table_list;
 typedef st_ha_create_information HA_CREATE_INFO;
 typedef st_table_list TABLE_LIST;
 
+enum find_files_result {
+  FIND_FILES_OK,
+  FIND_FILES_OOM,
+  FIND_FILES_DIR
+};
+
+find_files_result find_files(THD *thd, List<char> *files, const char *db,
+                             const char *path, const char *wild, bool dir);
+
 int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet,
                       HA_CREATE_INFO  *create_info_arg);
 int view_store_create_info(THD *thd, TABLE_LIST *table, String *buff);

--- 1.14/mysql-test/r/ndb_multi.result	2006-11-15 11:14:03 +01:00
+++ 1.15/mysql-test/r/ndb_multi.result	2006-11-15 11:14:03 +01:00
@@ -97,3 +97,27 @@ c1
 3
 5
 drop table t1;
+create database db;
+use db;
+create table t1(x int) engine=ndb;
+use db;
+show tables;
+Tables_in_db
+t1
+drop database db;
+show tables;
+ERROR 42000: Unknown database 'db'
+create database db;
+use db;
+create table t1(x int) engine=ndb;
+use db;
+create table t2(x int) engine=myisam;
+show tables;
+Tables_in_db
+t1
+t2
+drop database db;
+show tables;
+Tables_in_db
+t2
+drop database db;

--- 1.16/mysql-test/t/ndb_multi.test	2006-11-15 11:14:03 +01:00
+++ 1.17/mysql-test/t/ndb_multi.test	2006-11-15 11:14:03 +01:00
@@ -87,3 +87,40 @@ connection server1;
 select * from t1 order by c1;
 drop table t1;
 # End of 4.1 tests
+
+# Check distributed drop of database in 5.1
+create database db;
+use db;
+create table t1(x int) engine=ndb;
+
+connection server2;
+use db;
+show tables;
+
+connection server1;
+drop database db;
+
+connection server2;
+--error 1049
+show tables;
+
+connection server1;
+
+# bug#21495
+create database db;
+use db;
+create table t1(x int) engine=ndb;
+
+connection server2;
+use db;
+create table t2(x int) engine=myisam;
+show tables;
+
+connection server1;
+drop database db;
+
+connection server2;
+show tables;
+drop database db;
+
+connection server1;

--- 1.85/sql/ha_ndbcluster_binlog.cc	2006-11-15 11:14:03 +01:00
+++ 1.86/sql/ha_ndbcluster_binlog.cc	2006-11-15 11:14:03 +01:00
@@ -16,6 +16,7 @@
 */
 
 #include "mysql_priv.h"
+#include "sql_show.h"
 #ifdef WITH_NDBCLUSTER_STORAGE_ENGINE
 #include "ha_ndbcluster.h"
 
@@ -1828,14 +1829,25 @@ ndb_binlog_thread_handle_schema_event(TH
           log_query= 1;
           break;
         case SOT_DROP_DB:
-          run_query(thd, schema->query,
-                    schema->query + schema->query_length,
-                    TRUE,    /* print error */
-                    TRUE);   /* don't binlog the query */
-          /* binlog dropping database after any table operations */
-          post_epoch_log_list->push_back(schema, mem_root);
-          /* acknowledge this query _after_ epoch completion */
-          post_epoch_unlock= 1;
+	  /* Drop the database locally if it only contains ndb tables */
+	  if (! ndbcluster_check_if_local_tables_in_db(thd, schema->db))
+	  {
+	    run_query(thd, schema->query,
+		      schema->query + schema->query_length,
+		      TRUE,    /* print error */
+		      TRUE);   /* don't binlog the query */
+	    /* binlog dropping database after any table operations */
+	    post_epoch_log_list->push_back(schema, mem_root);
+	    /* acknowledge this query _after_ epoch completion */
+	    post_epoch_unlock= 1;
+	  }
+	  else
+	  {
+	    /*
+	      Database contained local tables, leave it
+	     */
+	    log_query= 1;
+	  }
           break;
         case SOT_CREATE_DB:
           /* fall through */
@@ -2331,6 +2343,32 @@ ndbcluster_check_if_local_table(const ch
     DBUG_RETURN(true);
   }
 
+  DBUG_RETURN(false);
+}
+
+bool
+ndbcluster_check_if_local_tables_in_db(THD *thd, const char *dbname)
+{
+  DBUG_ENTER("ndbcluster_check_if_local_tables_in_db");
+  DBUG_PRINT("info", ("Looking for files in directory %s", dbname));
+  char *tabname;
+  List<char> files;
+  char path[FN_REFLEN];
+
+  build_table_filename(path, sizeof(path), dbname, "", "", 0);
+  if (find_files(thd, &files, dbname, path, NullS, 0) != FIND_FILES_OK)
+  {
+    DBUG_PRINT("info", ("Failed to find files"));
+    DBUG_RETURN(true);
+  }
+  DBUG_PRINT("info",("found: %d files", files.elements));
+  while ((tabname= files.pop()))
+  {
+    DBUG_PRINT("info", ("Found table %s", tabname));
+    if (ndbcluster_check_if_local_table(dbname, tabname))
+      DBUG_RETURN(true);
+  }
+  
   DBUG_RETURN(false);
 }
 

--- 1.18/sql/ha_ndbcluster_binlog.h	2006-11-15 11:14:03 +01:00
+++ 1.19/sql/ha_ndbcluster_binlog.h	2006-11-15 11:14:03 +01:00
@@ -124,6 +124,7 @@ void ndbcluster_binlog_init_handlerton()
 void ndbcluster_binlog_init_share(NDB_SHARE *share, TABLE *table);
 
 bool ndbcluster_check_if_local_table(const char *dbname, const char *tabname);
+bool ndbcluster_check_if_local_tables_in_db(THD *thd, const char *dbname);
 
 int ndbcluster_create_binlog_setup(Ndb *ndb, const char *key,
                                    uint key_len,
Thread
bk commit into 5.1 tree (mskold:1.2322) BUG#21495Martin Skold15 Nov