From 1727aec6304caec3326298f3026384436de48818 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 20 Apr 2006 14:11:54 -0400 Subject: [PATCH] BUG#19067: Alter table add partition for subpartitioned table crashes Changed variable name for improved clarity and debugging possibilities Fixed bug in not assigning subpart_type mysql-test/t/partition.test: Added new test case sql/partition_info.cc: Changed variable name for improved clarity and debugging possibilities Fixed bug in not assigning subpart_type sql/sql_partition.cc: Changed variable name for improved clarity and debugging possibilities Fixed bug in not assigning subpart_type --- mysql-test/t/partition.test | 11 +++++++++++ sql/partition_info.cc | 14 +++++++------- sql/sql_partition.cc | 3 ++- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test index 272cdc27af6..16edabd7912 100644 --- a/mysql-test/t/partition.test +++ b/mysql-test/t/partition.test @@ -1009,4 +1009,15 @@ select auto_increment from information_schema.tables where table_name='t1'; select * from t1; drop table t1; +# +# BUG 19067 ALTER TABLE .. ADD PARTITION for subpartitioned table crashes +# +create table t1 (a int) +partition by range (a) +subpartition by key (a) +(partition p0 values less than (1)); +alter table t1 add partition (partition p1 values less than (2)); +alter table t1 reorganize partition p1 into (partition p1 values less than (3)); +drop table t1; + --echo End of 5.1 tests diff --git a/sql/partition_info.cc b/sql/partition_info.cc index e2bf37d6ef3..1464e5839b3 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -714,18 +714,18 @@ bool partition_info::check_partition_info(handlerton **eng_type, List_iterator sub_it(part_elem->subpartitions); do { - part_elem= sub_it++; - if (check_table_name(part_elem->partition_name, - strlen(part_elem->partition_name))) + partition_element *sub_elem= sub_it++; + if (check_table_name(sub_elem->partition_name, + strlen(sub_elem->partition_name))) { my_error(ER_WRONG_PARTITION_NAME, MYF(0)); goto end; } - if (part_elem->engine_type == NULL) - part_elem->engine_type= default_engine_type; + if (sub_elem->engine_type == NULL) + sub_elem->engine_type= default_engine_type; DBUG_PRINT("info", ("engine = %u", - ha_legacy_type(part_elem->engine_type))); - engine_array[part_count++]= part_elem->engine_type; + ha_legacy_type(sub_elem->engine_type))); + engine_array[part_count++]= sub_elem->engine_type; } while (++j < no_subparts); } } while (++i < no_parts); diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index aae80f07b71..be85aad608f 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -3949,6 +3949,7 @@ uint prep_alter_part_table(THD *thd, TABLE *table, ALTER_INFO *alter_info, DBUG_RETURN(TRUE); } alt_part_info->part_type= tab_part_info->part_type; + alt_part_info->subpart_type= tab_part_info->subpart_type; if (alt_part_info->set_up_defaults_for_partitioning(table->file, ULL(0), tab_part_info->no_parts)) @@ -4513,7 +4514,7 @@ the generated partition syntax in a correct manner. tab_part_info->use_default_no_subpartitions= FALSE; } if (tab_part_info->check_partition_info((handlerton**)NULL, - table->file, ULL(0))) + table->file, ULL(0))) { DBUG_RETURN(TRUE); }