summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikael Ronstrom <mikael@mysql.com>2009-07-29 17:56:32 +0200
committerMikael Ronstrom <mikael@mysql.com>2009-07-29 17:56:32 +0200
commita8e7535e335000908d4fe682dadfe23254c2e035 (patch)
treea14963565dedc00931b5b193647fcd943ad41374
parenta58b887c17c696c6e67adf0714254c57371d9cc2 (diff)
downloadmariadb-git-a8e7535e335000908d4fe682dadfe23254c2e035.tar.gz
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
-rw-r--r--mysql-test/r/partition.result8
-rw-r--r--mysql-test/t/partition.test11
-rw-r--r--sql/sql_yacc.yy21
3 files changed, 39 insertions, 1 deletions
diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result
index 8e3fbde1ea8..9643478b96b 100644
--- a/mysql-test/r/partition.result
+++ b/mysql-test/r/partition.result
@@ -1068,7 +1068,13 @@ partition by range (a)
subpartition by hash(a)
(partition p0 values less than (0),
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)
partition by hash (a)
(partition p0 (subpartition sp0));
diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test
index 8b4af201af2..18bcf84407b 100644
--- a/mysql-test/t/partition.test
+++ b/mysql-test/t/partition.test
@@ -1020,6 +1020,17 @@ subpartition by hash(a)
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
#
--error ER_SUBPARTITION_ERROR
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 91eb0d15dee..096e7941d00 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -4206,6 +4206,10 @@ opt_sub_partition:
if (Lex->part_info->no_subparts != 0 &&
!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));
MYSQL_YYABORT;
}
@@ -4248,6 +4252,23 @@ sub_part_definition:
partition_info *part_info= lex->part_info;
partition_element *curr_part= part_info->current_partition;
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 ||
curr_part->subpartitions.push_back(sub_p_elem))
{