List:Commits« Previous MessageNext Message »
From:mattiasj Date:November 20 2007 8:21am
Subject:bk commit into 5.1 tree (mattiasj:1.2621) BUG#30822
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of mattiasj. When mattiasj 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, 2007-11-20 09:20:59+01:00, mattiasj@stripped +5 -0
  Bug#30822: ALTER TABLE COALESCE PARTITION causes segmentation fault
  
  Problem was for LINEAR HASH/KEY. Crashes because of wrong partition id
  returned when creating the new altered partitions. (because of wrong
  linear hash mask)
  
  Solution: Update the linear hash mask before using it for the new
  altered table.

  mysql-test/r/partition_hash.result@stripped, 2007-11-20 09:20:54+01:00, mattiasj@stripped +12 -0
    Bug#30822: ALTER TABLE COALESCE PARTITION causes segmentation fault
    
    test result

  mysql-test/t/partition_hash.test@stripped, 2007-11-20 09:20:54+01:00, mattiasj@stripped +16 -0
    Bug#30822: ALTER TABLE COALESCE PARTITION causes segmentatition fault
    
    test case

  sql/ha_partition.cc@stripped, 2007-11-20 09:20:54+01:00, mattiasj@stripped +8 -0
    Bug#30822: ALTER TABLE COALESCE PARTITION causes segmentation fault
    
    Updating the linear hash mask before using it.

  sql/sql_partition.cc@stripped, 2007-11-20 09:20:54+01:00, mattiasj@stripped +1 -1
    Bug#30822: ALTER TABLE COALESCE PARTITION causes segmentation fault
    
    exporting the set_linear_hash_mask function (static -> non static)

  sql/sql_partition.h@stripped, 2007-11-20 09:20:54+01:00, mattiasj@stripped +1 -0
    Bug#30822: ALTER TABLE COALESCE PARTITION causes segmentation fault
    
    exporting the set_linear_hash_mask function (static -> non static)

diff -Nrup a/mysql-test/r/partition_hash.result b/mysql-test/r/partition_hash.result
--- a/mysql-test/r/partition_hash.result	2007-11-11 20:38:26 +01:00
+++ b/mysql-test/r/partition_hash.result	2007-11-20 09:20:54 +01:00
@@ -1,4 +1,16 @@
 drop table if exists t1;
+CREATE TABLE t1 (c1 INT)
+PARTITION BY HASH (c1)
+PARTITIONS 15;
+INSERT INTO t1 VALUES (1), (2), (3), (4), (5);
+ALTER TABLE t1 COALESCE PARTITION 13;
+DROP TABLE t1;
+CREATE TABLE t1 (c1 INT)
+PARTITION BY LINEAR HASH (c1)
+PARTITIONS 5;
+INSERT INTO t1 VALUES (1), (2), (3), (4), (5);
+ALTER TABLE t1 COALESCE PARTITION 3;
+DROP TABLE t1;
 create table t1 (a int unsigned)
 partition by hash(a div 2)
 partitions 4;
diff -Nrup a/mysql-test/t/partition_hash.test b/mysql-test/t/partition_hash.test
--- a/mysql-test/t/partition_hash.test	2007-11-11 20:38:26 +01:00
+++ b/mysql-test/t/partition_hash.test	2007-11-20 09:20:54 +01:00
@@ -10,6 +10,22 @@ drop table if exists t1;
 --enable_warnings
 
 #
+# Bug#30822: crash when COALESCE
+#
+CREATE TABLE t1 (c1 INT)
+  PARTITION BY HASH (c1)
+  PARTITIONS 15;
+INSERT INTO t1 VALUES (1), (2), (3), (4), (5);
+ALTER TABLE t1 COALESCE PARTITION 13;
+DROP TABLE t1;
+CREATE TABLE t1 (c1 INT)
+  PARTITION BY LINEAR HASH (c1)
+  PARTITIONS 5;
+INSERT INTO t1 VALUES (1), (2), (3), (4), (5);
+ALTER TABLE t1 COALESCE PARTITION 3;
+DROP TABLE t1;
+
+#
 # More partition pruning tests, especially on interval walking
 #
 create table t1 (a int unsigned)
diff -Nrup a/sql/ha_partition.cc b/sql/ha_partition.cc
--- a/sql/ha_partition.cc	2007-11-09 23:21:58 +01:00
+++ b/sql/ha_partition.cc	2007-11-20 09:20:54 +01:00
@@ -1531,6 +1531,14 @@ int ha_partition::copy_partitions(ulongl
   longlong func_value;
   DBUG_ENTER("ha_partition::copy_partitions");
 
+  if (m_part_info->linear_hash_ind)
+  {
+    if (m_part_info->part_type == HASH_PARTITION)
+      set_linear_hash_mask(m_part_info, m_part_info->no_parts);
+    else
+      set_linear_hash_mask(m_part_info, m_part_info->no_subparts);
+  }
+
   while (reorg_part < m_reorged_parts)
   {
     handler *file= m_reorged_file[reorg_part];
diff -Nrup a/sql/sql_partition.cc b/sql/sql_partition.cc
--- a/sql/sql_partition.cc	2007-11-15 20:25:41 +01:00
+++ b/sql/sql_partition.cc	2007-11-20 09:20:54 +01:00
@@ -1402,7 +1402,7 @@ static void set_up_partition_func_pointe
     NONE
 */
 
-static void set_linear_hash_mask(partition_info *part_info, uint no_parts)
+void set_linear_hash_mask(partition_info *part_info, uint no_parts)
 {
   uint mask;
 
diff -Nrup a/sql/sql_partition.h b/sql/sql_partition.h
--- a/sql/sql_partition.h	2007-06-25 11:22:22 +02:00
+++ b/sql/sql_partition.h	2007-11-20 09:20:54 +01:00
@@ -65,6 +65,7 @@ int get_part_for_delete(const uchar *buf
 void prune_partition_set(const TABLE *table, part_id_range *part_spec);
 bool check_partition_info(partition_info *part_info,handlerton **eng_type,
                           TABLE *table, handler *file, HA_CREATE_INFO *info);
+void set_linear_hash_mask(partition_info *part_info, uint no_parts);
 bool fix_partition_func(THD *thd, TABLE *table, bool create_table_ind);
 char *generate_partition_syntax(partition_info *part_info,
                                 uint *buf_length, bool use_sql_alloc,
Thread
bk commit into 5.1 tree (mattiasj:1.2621) BUG#30822mattiasj20 Nov