Commit c0890b5d authored by Mikael Ronstrom's avatar Mikael Ronstrom

Bug#46354, when defining partitions without subpartition definition after...

Bug#46354, when defining partitions without subpartition definition after defining it with the first partition and using list partition caused crash, fixed by more error checks in parser
parent b1073fb7
...@@ -1068,7 +1068,13 @@ partition by range (a) ...@@ -1068,7 +1068,13 @@ partition by range (a)
subpartition by hash(a) subpartition by hash(a)
(partition p0 values less than (0), (partition p0 values less than (0),
partition p1 values less than (1) (subpartition sp0)); partition p1 values less than (1) (subpartition sp0));
ERROR 42000: Wrong number of subpartitions defined, mismatch with previous setting near '))' at line 5 ERROR 42000: Wrong number of subpartitions defined, mismatch with previous setting near 'subpartition sp0))' at line 5
create table t1 (a int, b int)
partition by list (a)
subpartition by hash(a)
(partition p0 values in (0),
partition p1 values in (1) (subpartition sp0));
ERROR 42000: Wrong number of subpartitions defined, mismatch with previous setting near 'subpartition sp0))' at line 5
create table t1 (a int) create table t1 (a int)
partition by hash (a) partition by hash (a)
(partition p0 (subpartition sp0)); (partition p0 (subpartition sp0));
......
...@@ -1019,6 +1019,17 @@ subpartition by hash(a) ...@@ -1019,6 +1019,17 @@ subpartition by hash(a)
(partition p0 values less than (0), (partition p0 values less than (0),
partition p1 values less than (1) (subpartition sp0)); partition p1 values less than (1) (subpartition sp0));
#
# Bug 46354 Crash with subpartition
#
--error ER_PARSE_ERROR
create table t1 (a int, b int)
partition by list (a)
subpartition by hash(a)
(partition p0 values in (0),
partition p1 values in (1) (subpartition sp0));
# #
# BUG 15961 No error when subpartition defined without subpartition by clause # BUG 15961 No error when subpartition defined without subpartition by clause
# #
......
...@@ -4206,6 +4206,10 @@ opt_sub_partition: ...@@ -4206,6 +4206,10 @@ opt_sub_partition:
if (Lex->part_info->no_subparts != 0 && if (Lex->part_info->no_subparts != 0 &&
!Lex->part_info->use_default_subpartitions) !Lex->part_info->use_default_subpartitions)
{ {
/*
We come here when we have defined subpartitions on the first
partition but not on all the subsequent partitions.
*/
my_parse_error(ER(ER_PARTITION_WRONG_NO_SUBPART_ERROR)); my_parse_error(ER(ER_PARTITION_WRONG_NO_SUBPART_ERROR));
MYSQL_YYABORT; MYSQL_YYABORT;
} }
...@@ -4248,6 +4252,23 @@ sub_part_definition: ...@@ -4248,6 +4252,23 @@ sub_part_definition:
partition_info *part_info= lex->part_info; partition_info *part_info= lex->part_info;
partition_element *curr_part= part_info->current_partition; partition_element *curr_part= part_info->current_partition;
partition_element *sub_p_elem= new partition_element(curr_part); partition_element *sub_p_elem= new partition_element(curr_part);
if (part_info->use_default_subpartitions &&
part_info->partitions.elements >= 2)
{
/*
create table t1 (a int)
partition by list (a) subpartition by hash (a)
(partition p0 values in (1),
partition p1 values in (2) subpartition sp11);
causes use to arrive since we are on the second
partition, but still use_default_subpartitions
is set. When we come here we're processing at least
the second partition (the current partition processed
have already been put into the partitions list.
*/
my_parse_error(ER(ER_PARTITION_WRONG_NO_SUBPART_ERROR));
MYSQL_YYABORT;
}
if (!sub_p_elem || if (!sub_p_elem ||
curr_part->subpartitions.push_back(sub_p_elem)) curr_part->subpartitions.push_back(sub_p_elem))
{ {
......
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