Commit 8d3c7e3b authored by mikael@zim.(none)'s avatar mikael@zim.(none)

BUG#16370: Default subpartitioning not properly handled in conjunction

with ALTER TABLE ADD/REORGANIZE PARTITION
Ensure that default subpartitioning is removed when subpartitions
are defined in ADD/REORGANIZE PARTITION
parent 93da852c
...@@ -428,4 +428,40 @@ partition by list (a) ...@@ -428,4 +428,40 @@ partition by list (a)
alter table t1 rebuild partition; alter table t1 rebuild partition;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
drop table t1; drop table t1;
create table t1 (a int)
partition by list (a)
(partition p0 values in (5));
insert into t1 values (0);
ERROR HY000: Table has no partition for value 0
drop table t1;
create table t1 (a int)
partition by range (a) subpartition by hash (a)
(partition p0 values less than (100));
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) SUBPARTITION BY HASH (a) (PARTITION p0 VALUES LESS THAN (100) )
alter table t1 add partition (partition p1 values less than (200)
(subpartition subpart21));
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) SUBPARTITION BY HASH (a) (PARTITION p0 VALUES LESS THAN (100) (SUBPARTITION p0sp0 ENGINE = MyISAM), PARTITION p1 VALUES LESS THAN (200) (SUBPARTITION subpart21 ENGINE = MyISAM))
drop table t1;
create table t1 (a int)
partition by key (a);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY KEY (a)
alter table t1 add partition (partition p1);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY KEY (a) (PARTITION p0 ENGINE = MyISAM, PARTITION p1 ENGINE = MyISAM)
drop table t1;
End of 5.1 tests End of 5.1 tests
...@@ -552,4 +552,40 @@ alter table t1 rebuild partition; ...@@ -552,4 +552,40 @@ alter table t1 rebuild partition;
drop table t1; drop table t1;
#
# BUG 15253 Insert that should fail doesn't
#
create table t1 (a int)
partition by list (a)
(partition p0 values in (5));
--error ER_NO_PARTITION_FOR_GIVEN_VALUE
insert into t1 values (0);
drop table t1;
#
# BUG #16370 Subpartitions names not shown in SHOW CREATE TABLE output
#
create table t1 (a int)
partition by range (a) subpartition by hash (a)
(partition p0 values less than (100));
show create table t1;
alter table t1 add partition (partition p1 values less than (200)
(subpartition subpart21));
show create table t1;
drop table t1;
create table t1 (a int)
partition by key (a);
show create table t1;
alter table t1 add partition (partition p1);
show create table t1;
drop table t1;
--echo End of 5.1 tests --echo End of 5.1 tests
...@@ -4069,6 +4069,7 @@ uint prep_alter_part_table(THD *thd, TABLE *table, ALTER_INFO *alter_info, ...@@ -4069,6 +4069,7 @@ uint prep_alter_part_table(THD *thd, TABLE *table, ALTER_INFO *alter_info,
ALTER_REPAIR_PARTITION | ALTER_REBUILD_PARTITION)) ALTER_REPAIR_PARTITION | ALTER_REBUILD_PARTITION))
{ {
partition_info *tab_part_info= table->part_info; partition_info *tab_part_info= table->part_info;
partition_info *alt_part_info= thd->lex->part_info;
if (!tab_part_info) if (!tab_part_info)
{ {
my_error(ER_PARTITION_MGMT_ON_NONPARTITIONED, MYF(0)); my_error(ER_PARTITION_MGMT_ON_NONPARTITIONED, MYF(0));
...@@ -4141,7 +4142,6 @@ uint prep_alter_part_table(THD *thd, TABLE *table, ALTER_INFO *alter_info, ...@@ -4141,7 +4142,6 @@ uint prep_alter_part_table(THD *thd, TABLE *table, ALTER_INFO *alter_info,
partitioning scheme as currently set-up. partitioning scheme as currently set-up.
Partitions are always added at the end in ADD PARTITION. Partitions are always added at the end in ADD PARTITION.
*/ */
partition_info *alt_part_info= thd->lex->part_info;
uint no_new_partitions= alt_part_info->no_parts; uint no_new_partitions= alt_part_info->no_parts;
uint no_orig_partitions= tab_part_info->no_parts; uint no_orig_partitions= tab_part_info->no_parts;
uint check_total_partitions= no_new_partitions + no_orig_partitions; uint check_total_partitions= no_new_partitions + no_orig_partitions;
...@@ -4736,6 +4736,13 @@ the generated partition syntax in a correct manner. ...@@ -4736,6 +4736,13 @@ the generated partition syntax in a correct manner.
if (alter_info->flags == ALTER_ADD_PARTITION || if (alter_info->flags == ALTER_ADD_PARTITION ||
alter_info->flags == ALTER_REORGANIZE_PARTITION) alter_info->flags == ALTER_REORGANIZE_PARTITION)
{ {
if (tab_part_info->is_sub_partitioned() &&
tab_part_info->use_default_subpartitions &&
!alt_part_info->use_default_subpartitions)
{
tab_part_info->use_default_subpartitions= FALSE;
tab_part_info->use_default_no_subpartitions= FALSE;
}
if (check_partition_info(tab_part_info, (handlerton**)NULL, if (check_partition_info(tab_part_info, (handlerton**)NULL,
table->file, ULL(0))) table->file, ULL(0)))
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment