List:Commits« Previous MessageNext Message »
From:holyfoot Date:December 12 2005 6:29pm
Subject:bk commit into 5.1 tree (holyfoot:1.1973) BUG#15521
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of hf. When hf 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.1973 05/12/12 22:29:25 holyfoot@deer.(none) +7 -0
  Fix for bug #15521 (Cannot reorganise with the same name)

  sql/sql_table.cc
    1.284 05/12/12 22:29:19 holyfoot@stripped +3 -1
    check_reorganise_list call added
    tab_part_info->no_parts should be changed here

  sql/sql_partition.cc
    1.16 05/12/12 22:29:19 holyfoot@stripped +53 -0
    check_reorganise_list implementation added

  sql/handler.h
    1.170 05/12/12 22:29:19 holyfoot@stripped +3 -0
    check_reorganise_list interface added

  mysql-test/t/partition_mgm_err.test
    1.2 05/12/12 22:29:19 holyfoot@stripped +1 -1
    test case modified to produce proper error

  mysql-test/t/partition.test
    1.8 05/12/12 22:29:19 holyfoot@stripped +31 -0
    test case added

  mysql-test/r/partition_mgm_err.result
    1.2 05/12/12 22:29:19 holyfoot@stripped +1 -1
    result fixed

  mysql-test/r/partition.result
    1.8 05/12/12 22:29:18 holyfoot@stripped +34 -0
    result fixed

# 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:	holyfoot
# Host:	deer.(none)
# Root:	/home/hf/work/mysql-5.1.clean

--- 1.169/sql/handler.h	Mon Nov 28 23:07:10 2005
+++ 1.170/sql/handler.h	Mon Dec 12 22:29:19 2005
@@ -717,6 +717,9 @@
 bool is_partition_in_list(char *part_name, List<char> list_part_names);
 bool is_partitions_in_table(partition_info *new_part_info,
                             partition_info *old_part_info);
+bool check_reorganise_list(partition_info *new_part_info,
+                           partition_info *old_part_info,
+                           List<char> list_part_names);
 bool set_up_defaults_for_partitioning(partition_info *part_info,
                                       handler *file,
                                       ulonglong max_rows,

--- 1.283/sql/sql_table.cc	Wed Dec  7 18:17:10 2005
+++ 1.284/sql/sql_table.cc	Mon Dec 12 22:29:19 2005
@@ -3832,7 +3832,8 @@
         my_error(ER_ONLY_ON_RANGE_LIST_PARTITION, MYF(0), "REORGANISE");
         DBUG_RETURN(TRUE);
       }
-      if (is_partitions_in_table(alt_part_info, tab_part_info))
+      if (check_reorganise_list(alt_part_info, tab_part_info,
+                                alter_info->partition_names))
       {
         my_error(ER_SAME_NAME_PARTITION, MYF(0));
         DBUG_RETURN(TRUE);
@@ -3901,6 +3902,7 @@
       }
     }
     partition_changed= TRUE;
+    tab_part_info->no_parts= tab_part_info->partitions.elements;
     create_info->db_type= DB_TYPE_PARTITION_DB;
     thd->lex->part_info= tab_part_info;
     if (alter_info->flags == ALTER_ADD_PARTITION ||

--- 1.7/mysql-test/r/partition.result	Tue Nov 22 03:20:54 2005
+++ 1.8/mysql-test/r/partition.result	Mon Dec 12 22:29:18 2005
@@ -114,3 +114,37 @@
 SELECT * FROM t1;
 id
 drop table t1;
+create table t1
+(a int)
+partition by range (a)
+( partition p0 values less than(10),
+partition p1 values less than (20),
+partition p2 values less than maxvalue);
+alter table t1 reorganise partition p2 into (partition p2 values less than (30));
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY RANGE (a) (PARTITION p0 VALUES LESS THAN (10) ENGINE = MyISAM, PARTITION p1 VALUES LESS THAN (20) ENGINE = MyISAM, PARTITION p2 VALUES LESS THAN (30) ENGINE = MyISAM)
+drop table t1;
+CREATE TABLE t1 (a int, b int)
+PARTITION BY RANGE (a)
+(PARTITION x0 VALUES LESS THAN (2),
+PARTITION x1 VALUES LESS THAN (4),
+PARTITION x2 VALUES LESS THAN (6),
+PARTITION x3 VALUES LESS THAN (8),
+PARTITION x4 VALUES LESS THAN (10),
+PARTITION x5 VALUES LESS THAN (12),
+PARTITION x6 VALUES LESS THAN (14),
+PARTITION x7 VALUES LESS THAN (16),
+PARTITION x8 VALUES LESS THAN (18),
+PARTITION x9 VALUES LESS THAN (20));
+ALTER TABLE t1 REORGANISE PARTITION x0,x1,x2 INTO
+(PARTITION x1 VALUES LESS THAN (6));
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) default NULL,
+  `b` int(11) default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY RANGE (a) (PARTITION x1 VALUES LESS THAN (6) ENGINE = MyISAM, PARTITION x3 VALUES LESS THAN (8) ENGINE = MyISAM, PARTITION x4 VALUES LESS THAN (10) ENGINE = MyISAM, PARTITION x5 VALUES LESS THAN (12) ENGINE = MyISAM, PARTITION x6 VALUES LESS THAN (14) ENGINE = MyISAM, PARTITION x7 VALUES LESS THAN (16) ENGINE = MyISAM, PARTITION x8 VALUES LESS THAN (18) ENGINE = MyISAM, PARTITION x9 VALUES LESS THAN (20) ENGINE = MyISAM)
+drop table t1;

--- 1.7/mysql-test/t/partition.test	Tue Nov 22 03:20:54 2005
+++ 1.8/mysql-test/t/partition.test	Mon Dec 12 22:29:19 2005
@@ -172,3 +172,34 @@
 
 drop table t1;
 
+#
+# BUG 15221 (Cannot reorganize with the same name)
+#
+create table t1
+(a int)
+partition by range (a)
+  ( partition p0 values less than(10),
+    partition p1 values less than (20),
+    partition p2 values less than maxvalue);
+
+alter table t1 reorganise partition p2 into (partition p2 values less than (30));
+show create table t1;
+drop table t1;
+
+CREATE TABLE t1 (a int, b int)
+PARTITION BY RANGE (a)
+(PARTITION x0 VALUES LESS THAN (2),
+ PARTITION x1 VALUES LESS THAN (4),
+ PARTITION x2 VALUES LESS THAN (6),
+ PARTITION x3 VALUES LESS THAN (8),
+ PARTITION x4 VALUES LESS THAN (10),
+ PARTITION x5 VALUES LESS THAN (12),
+ PARTITION x6 VALUES LESS THAN (14),
+ PARTITION x7 VALUES LESS THAN (16),
+ PARTITION x8 VALUES LESS THAN (18),
+ PARTITION x9 VALUES LESS THAN (20));
+
+ALTER TABLE t1 REORGANISE PARTITION x0,x1,x2 INTO
+(PARTITION x1 VALUES LESS THAN (6));
+show create table t1;
+drop table t1;

--- 1.15/sql/sql_partition.cc	Sat Nov 26 08:16:18 2005
+++ 1.16/sql/sql_partition.cc	Mon Dec 12 22:29:19 2005
@@ -190,6 +190,59 @@
 
 
 /*
+  A support function to check partition names for duplication in a
+  partitioned table. Works almost like is_partition_in_table, but
+  also checks additional list and doesn't count tables that are
+  there.
+  SYNOPSIS
+    check_reorganise_list()
+    new_part_info      New partition info
+    old_part_info      Old partition info
+    list_part_names    list of tables 'allowed' to duplicate
+  RETURN VALUES
+    TRUE               Not allowed duplicate names found
+    FALSE              Duplicate names not found
+  DESCRIPTION
+    Can handle that the new and old parts are the same in which case it
+    checks that the list of names in the partitions doesn't contain any
+    duplicated names.
+*/
+
+bool check_reorganise_list(partition_info *new_part_info,
+                           partition_info *old_part_info,
+                           List<char> list_part_names)
+{
+  uint no_new_parts= new_part_info->partitions.elements, new_count;
+  uint no_old_parts= old_part_info->partitions.elements, old_count;
+  List_iterator<partition_element> new_parts_it(new_part_info->partitions);
+  bool same_part_info= (new_part_info == old_part_info);
+  DBUG_ENTER("is_partitions_in_table");
+
+  new_count= 0;
+  do
+  {
+    List_iterator<partition_element> old_parts_it(old_part_info->partitions);
+    char *new_name= (new_parts_it++)->partition_name;
+    new_count++;
+    old_count= 0;
+    do
+    {
+      char *old_name= (old_parts_it++)->partition_name;
+      old_count++;
+      if (same_part_info && old_count == new_count)
+        break;
+      if (!(my_strcasecmp(system_charset_info, old_name, new_name)))
+      {
+        if (!is_partition_in_list(old_name, list_part_names))
+          DBUG_RETURN(TRUE);
+      }
+    } while (old_count < no_old_parts);
+  } while (new_count < no_new_parts);
+  DBUG_RETURN(FALSE);
+}
+
+
+/*
   A useful routine used by update_row for partition handlers to calculate
   the partition ids of the old and the new record.
   SYNOPSIS

--- 1.1/mysql-test/r/partition_mgm_err.result	Fri Aug 19 19:24:19 2005
+++ 1.2/mysql-test/r/partition_mgm_err.result	Mon Dec 12 22:29:19 2005
@@ -26,7 +26,7 @@
 (PARTITION x11 VALUES LESS THAN (22));
 ERROR HY000: More partitions to reorganise than there are partitions
 ALTER TABLE t1 REORGANISE PARTITION x0,x1,x2 INTO
-(PARTITION x1 VALUES LESS THAN (6));
+(PARTITION x3 VALUES LESS THAN (6));
 ERROR HY000: All partitions must have unique names in the table
 ALTER TABLE t1 REORGANISE PARTITION x0, x2 INTO
 (PARTITION x11 VALUES LESS THAN (2));

--- 1.1/mysql-test/t/partition_mgm_err.test	Fri Aug 19 19:24:09 2005
+++ 1.2/mysql-test/t/partition_mgm_err.test	Mon Dec 12 22:29:19 2005
@@ -43,7 +43,7 @@
 
 --error ER_SAME_NAME_PARTITION
 ALTER TABLE t1 REORGANISE PARTITION x0,x1,x2 INTO
-(PARTITION x1 VALUES LESS THAN (6));
+(PARTITION x3 VALUES LESS THAN (6));
 
 --error ER_CONSECUTIVE_REORG_PARTITIONS
 ALTER TABLE t1 REORGANISE PARTITION x0, x2 INTO
Thread
bk commit into 5.1 tree (holyfoot:1.1973) BUG#15521holyfoot12 Dec