diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result index d84d8e25ef1..27ae4119de2 100644 --- a/mysql-test/r/partition.result +++ b/mysql-test/r/partition.result @@ -428,6 +428,10 @@ partition by list (a) 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 drop table t1; +create table t1 (a int) +partition by hash (a) +(partition p0 (subpartition sp0)); +ERROR HY000: It is only possible to mix RANGE/LIST partitioning with HASH/KEY partitioning for subpartitioning create table t1 (a int) engine=innodb partition by hash(a) ; show table status like 't1'; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment diff --git a/mysql-test/r/partition_mgm_err.result b/mysql-test/r/partition_mgm_err.result index c7003c6e14c..f899801e7cd 100644 --- a/mysql-test/r/partition_mgm_err.result +++ b/mysql-test/r/partition_mgm_err.result @@ -141,7 +141,9 @@ DROP TABLE t1; CREATE TABLE t1 (a INT) PARTITION BY HASH(a); ALTER TABLE t1 ADD PARTITION PARTITIONS 4; DROP TABLE t1; -CREATE TABLE t1 (s1 int, s2 int) PARTITION BY LIST (s1) ( +CREATE TABLE t1 (s1 int, s2 int) +PARTITION BY LIST (s1) +SUBPARTITION BY KEY (s2) ( PARTITION p1 VALUES IN (0) (SUBPARTITION p1b), PARTITION p2 VALUES IN (2) (SUBPARTITION p1b) ); diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test index 9ee2bbd36b3..6760f928d50 100644 --- a/mysql-test/t/partition.test +++ b/mysql-test/t/partition.test @@ -552,6 +552,14 @@ alter table t1 rebuild partition; drop table t1; +# +# BUG 15961 No error when subpartition defined without subpartition by clause +# +--error ER_SUBPARTITION_ERROR +create table t1 (a int) +partition by hash (a) +(partition p0 (subpartition sp0)); + # # Bug #14673: Wrong InnoDB default row format # diff --git a/mysql-test/t/partition_mgm_err.test b/mysql-test/t/partition_mgm_err.test index f72222feadd..8573fd59f2f 100644 --- a/mysql-test/t/partition_mgm_err.test +++ b/mysql-test/t/partition_mgm_err.test @@ -205,7 +205,9 @@ DROP TABLE t1; #BUG 15408: Partitions: subpartition names are not unique # --error ER_SAME_NAME_PARTITION -CREATE TABLE t1 (s1 int, s2 int) PARTITION BY LIST (s1) ( +CREATE TABLE t1 (s1 int, s2 int) +PARTITION BY LIST (s1) +SUBPARTITION BY KEY (s2) ( PARTITION p1 VALUES IN (0) (SUBPARTITION p1b), PARTITION p2 VALUES IN (2) (SUBPARTITION p1b) ); diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt index 4255504e98f..e8766b3d882 100644 --- a/sql/share/errmsg.txt +++ b/sql/share/errmsg.txt @@ -5614,6 +5614,10 @@ ER_PARTITION_MAXVALUE_ERROR ER_PARTITION_SUBPARTITION_ERROR eng "Subpartitions can only be hash partitions and by key" swe "Subpartitioner kan bara vara hash och key partitioner" +ER_PARTITION_SUBPART_MIX_ERROR + eng "Must define subpartitions on all partitions if on one partition" + swe "Subpartitioner mÃ¥ste definieras pÃ¥ alla partitioner om pÃ¥ en" + ER_PARTITION_WRONG_NO_PART_ERROR eng "Wrong number of partitions defined, mismatch with previous setting" swe "Antal partitioner definierade och antal partitioner är inte lika" diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index a27e5b1979f..7f81cf7eadc 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -692,12 +692,19 @@ bool check_partition_info(partition_info *part_info,handlerton **eng_type, char *same_name; DBUG_ENTER("check_partition_info"); + if (unlikely(!part_info->is_sub_partitioned() && + !(part_info->use_default_subpartitions && + part_info->use_default_no_subpartitions))) + { + my_error(ER_SUBPARTITION_ERROR, MYF(0)); + goto end; + } if (unlikely(part_info->is_sub_partitioned() && (!(part_info->part_type == RANGE_PARTITION || part_info->part_type == LIST_PARTITION)))) { /* Only RANGE and LIST partitioning can be subpartitioned */ - my_error(ER_SUBPARTITION_ERROR, MYF(0)); + my_error(ER_PARTITION_SUBPART_MIX_ERROR, MYF(0)); goto end; } if (unlikely(part_info->set_up_defaults_for_partitioning(file,