List:Commits« Previous MessageNext Message »
From:Jonas Oreland Date:October 29 2008 2:11pm
Subject:bzr commit into mysql-5.1 branch (jonas:3026)
View as plain text  
#At file:///home/jonas/src/telco-6.4/

 3026 Jonas Oreland	2008-10-29
      ndb - 
        fix "alter online table T reorganize partition"
        fix so that environment variables are not needed for ndbmtd on mysqld-side
modified:
  mysql-test/suite/ndb/r/ndb_add_partition.result
  mysql-test/suite/ndb/r/ndb_basic.result
  mysql-test/suite/ndb/t/ndb_add_partition.test
  sql/ha_ndbcluster.cc
  sql/handler.h
  sql/sql_partition.cc
  sql/sql_table.cc

=== modified file 'mysql-test/suite/ndb/r/ndb_add_partition.result'
--- a/mysql-test/suite/ndb/r/ndb_add_partition.result	2008-06-07 19:47:48 +0000
+++ b/mysql-test/suite/ndb/r/ndb_add_partition.result	2008-10-29 14:11:08 +0000
@@ -141,8 +141,12 @@ a	b	c
 select * from t2 where b = 50;
 a	b	c
 50	50	50
+alter online table t1 reorganize partition;
+alter online table t2 reorganize partition;
 alter online table t1 add partition partitions 1;
 alter online table t2 add partition partitions 4;
+alter online table t1 reorganize partition;
+ERROR HY000: REORGANISE PARTITION without parameters can only be used on auto-partitioned tables using HASH PARTITIONs
 select count(*) from t1;
 count(*)
 100

=== modified file 'mysql-test/suite/ndb/r/ndb_basic.result'
--- a/mysql-test/suite/ndb/r/ndb_basic.result	2008-10-06 11:03:32 +0000
+++ b/mysql-test/suite/ndb/r/ndb_basic.result	2008-10-29 14:11:08 +0000
@@ -619,8 +619,6 @@ create table t1
 primary key (a,b,c,d)) 
 engine=ndb
 max_rows=800000000;
-Warnings:
-Warning	1105	Ndb might have problems storing the max amount of rows specified
 insert into t1 values
 (1,2,3,4),(2,3,4,5),(3,4,5,6),
 (3,2,3,4),(1,3,4,5),(2,4,5,6),

=== modified file 'mysql-test/suite/ndb/t/ndb_add_partition.test'
--- a/mysql-test/suite/ndb/t/ndb_add_partition.test	2008-06-07 19:47:48 +0000
+++ b/mysql-test/suite/ndb/t/ndb_add_partition.test	2008-10-29 14:11:08 +0000
@@ -87,9 +87,17 @@ select * from t2 where b = 30;
 select * from t2 where b = 40;
 select * from t2 where b = 50;
 
+alter online table t1 reorganize partition;
+alter online table t2 reorganize partition;
+
 alter online table t1 add partition partitions 1;
 alter online table t2 add partition partitions 4;
 
+# reorganize partition not support if not default partitioning
+# and after a add partition it's no longer default
+--error ER_REORG_NO_PARAM_ERROR
+alter online table t1 reorganize partition;
+
 select count(*) from t1;
 select count(*) from t2;
 --sorted_result

=== modified file 'sql/ha_ndbcluster.cc'
--- a/sql/ha_ndbcluster.cc	2008-10-21 04:02:59 +0000
+++ b/sql/ha_ndbcluster.cc	2008-10-29 14:11:08 +0000
@@ -6599,7 +6599,13 @@ int ha_ndbcluster::create(const char *na
     goto abort;
 
   // Check for HashMap
-  if (tab.getFragmentType() == NDBTAB::HashMapPartition)
+  if (tab.getFragmentType() == NDBTAB::HashMapPartition && 
+      tab.getDefaultNoPartitionsFlag())
+  {
+    tab.setFragmentCount(0);
+    tab.setFragmentData(0, 0);
+  }
+  else if (tab.getFragmentType() == NDBTAB::HashMapPartition)
   {
     NdbDictionary::HashMap hm;
     int res= dict->getDefaultHashMap(hm, tab.getFragmentCount());
@@ -11339,6 +11345,11 @@ int ha_ndbcluster::get_default_no_partit
   {
     max_rows= create_info->max_rows;
     min_rows= create_info->min_rows;
+    
+    /**
+     * we hate this method...just return 1??
+     */
+    return 1;
   }
   else
   {
@@ -11350,13 +11361,6 @@ int ha_ndbcluster::get_default_no_partit
     get_no_fragments(max_rows >= min_rows ? max_rows : min_rows);
   uint no_nodes= g_ndb_cluster_connection->no_db_nodes();
 
-  if (getenv("NDBMT_LQH_THREADS"))
-  {
-    int mul= atoi(getenv("NDBMT_LQH_THREADS"));
-    if (mul <= 0)
-      mul= 1;
-    no_nodes*= (uint)mul;
-  }
   if (adjusted_frag_count(no_fragments, no_nodes, reported_frags))
   {
     push_warning(current_thd,
@@ -11653,7 +11657,8 @@ HA_ALTER_FLAGS supported_alter_operation
     HA_ADD_COLUMN |
     HA_COLUMN_STORAGE |
     HA_COLUMN_FORMAT |
-    HA_ADD_PARTITION;
+    HA_ADD_PARTITION |
+    HA_ALTER_TABLE_REORG;
 }
 
 int ha_ndbcluster::check_if_supported_alter(TABLE *altered_table,
@@ -11676,6 +11681,8 @@ int ha_ndbcluster::check_if_supported_al
   add_column= add_column | HA_ADD_COLUMN;
   adding= adding | HA_ADD_INDEX | HA_ADD_UNIQUE_INDEX;
   dropping= dropping | HA_DROP_INDEX | HA_DROP_UNIQUE_INDEX;
+  partition_info *part_info= table->part_info;
+  const NDBTAB *old_tab= m_table;
 
   if (thd->variables.ndb_use_copying_alter_table)
   {
@@ -11689,21 +11696,40 @@ int ha_ndbcluster::check_if_supported_al
     DBUG_PRINT("info", ("Not supported %s", dbug_string));
   }
 #endif
+
+  if (alter_flags->is_set(HA_ALTER_TABLE_REORG))
+  {
+    /*
+      sql_partition.cc tries to compute what is going on
+      and sets flags...that we clear
+    */
+    if (part_info->use_default_no_partitions)
+    {
+      alter_flags->clear_bit(HA_COALESCE_PARTITION);
+      alter_flags->clear_bit(HA_ADD_PARTITION);
+    }
+  }
+
   if ((*alter_flags & not_supported).is_set())
   {
-    DBUG_PRINT("info", ("Detected unsupported change"));
+#ifndef DBUG_OFF
+    HA_ALTER_FLAGS tmp = *alter_flags;
+    tmp&= not_supported;
+    char dbug_string[HA_MAX_ALTER_FLAGS+1];
+    tmp.print(dbug_string);
+    DBUG_PRINT("info", ("Detected unsupported change: %s", dbug_string));
+#endif
     DBUG_RETURN(HA_ALTER_NOT_SUPPORTED);
   }
 
   if (alter_flags->is_set(HA_ADD_COLUMN) ||
-      alter_flags->is_set(HA_ADD_PARTITION))
+      alter_flags->is_set(HA_ADD_PARTITION) ||
+      alter_flags->is_set(HA_ALTER_TABLE_REORG))
   {
      Ndb *ndb= get_ndb(thd);
      NDBDICT *dict= ndb->getDictionary();
      ndb->setDatabaseName(m_dbname);
-     const NDBTAB *old_tab= m_table;
      NdbDictionary::Table new_tab= *old_tab;
-     partition_info *part_info= table->part_info;
 
      if (alter_flags->is_set(HA_ADD_COLUMN))
      {
@@ -11745,11 +11771,16 @@ int ha_ndbcluster::check_if_supported_al
        }
      }
 
-     if (alter_flags->is_set(HA_ADD_PARTITION))
+     if (alter_flags->is_set(HA_ALTER_TABLE_REORG))
+     {
+       new_tab.setFragmentCount(0);
+       new_tab.setFragmentData(0, 0);
+     }
+     else if (alter_flags->is_set(HA_ADD_PARTITION))
      {
        new_tab.setFragmentCount(part_info->no_parts);
      }
-
+     
      if (dict->supportedAlterTable(*old_tab, new_tab))
      {
        DBUG_PRINT("info", ("Adding column(s) supported on-line"));
@@ -11987,7 +12018,12 @@ int ha_ndbcluster::alter_table_phase1(TH
      }
   }
 
-  if (alter_flags->is_set(HA_ADD_PARTITION))
+  if (alter_flags->is_set(HA_ALTER_TABLE_REORG))
+  {
+    new_tab->setFragmentCount(0);    
+    new_tab->setFragmentData(0, 0);
+  }
+  else if (alter_flags->is_set(HA_ADD_PARTITION))
   {
     partition_info *part_info= table->part_info;
     new_tab->setFragmentCount(part_info->no_parts);

=== modified file 'sql/handler.h'
--- a/sql/handler.h	2008-10-07 08:52:37 +0000
+++ b/sql/handler.h	2008-10-29 14:11:08 +0000
@@ -50,7 +50,7 @@
 /* Bits to show what an alter table will do */
 #include <sql_bitmap.h>
 
-#define HA_MAX_ALTER_FLAGS 39
+#define HA_MAX_ALTER_FLAGS 40
 typedef Bitmap<HA_MAX_ALTER_FLAGS> HA_ALTER_FLAGS;
 
 #define HA_ADD_INDEX                  (0)
@@ -92,6 +92,7 @@ typedef Bitmap<HA_MAX_ALTER_FLAGS> HA_AL
 #define HA_RENAME_TABLE               (36)
 #define HA_ALTER_STORAGE_ENGINE       (37)
 #define HA_RECREATE                   (38)
+#define HA_ALTER_TABLE_REORG          (39)
 /* Remember to increase HA_MAX_ALTER_FLAGS when adding more flags! */
 
 /* Return values for check_if_supported_alter */

=== modified file 'sql/sql_partition.cc'
--- a/sql/sql_partition.cc	2008-09-02 16:31:03 +0000
+++ b/sql/sql_partition.cc	2008-10-29 14:11:08 +0000
@@ -4172,7 +4172,7 @@ uint prep_alter_part_table(THD *thd, TAB
     {
       uint new_part_no, curr_part_no;
       if (tab_part_info->part_type != HASH_PARTITION ||
-          tab_part_info->use_default_no_partitions)
+          !tab_part_info->use_default_no_partitions)
       {
         my_error(ER_REORG_NO_PARAM_ERROR, MYF(0));
         DBUG_RETURN(TRUE);

=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc	2008-10-07 10:10:09 +0000
+++ b/sql/sql_table.cc	2008-10-29 14:11:08 +0000
@@ -5191,6 +5191,8 @@ void setup_ha_alter_flags(Alter_info *al
     *alter_flags|= HA_ALTER_PARTITION;
   if (ALTER_FOREIGN_KEY & flags)
     *alter_flags|= HA_ALTER_FOREIGN_KEY;
+  if (ALTER_TABLE_REORG & flags)
+    *alter_flags|= HA_ALTER_TABLE_REORG;
 }
 
 

Thread
bzr commit into mysql-5.1 branch (jonas:3026) Jonas Oreland29 Oct