#At file:///home/mikael/mysql_clones/mysql-5.1-pg3/
3023 Mikael Ronstrom 2009-07-23
Bug#46354 Crash when using list partitioning and subpartitioning and wrong subpartition definition
modified:
mysql-test/r/partition.result
mysql-test/t/partition.test
sql/sql_yacc.yy
=== modified file 'mysql-test/r/partition.result'
--- a/mysql-test/r/partition.result 2009-07-02 14:42:00 +0000
+++ b/mysql-test/r/partition.result 2009-07-23 13:43:36 +0000
@@ -1,5 +1,12 @@
SET @old_general_log= @@global.general_log;
drop table if exists t1, t2;
+create table t1 (a int, b int)
+partition by list (a)
+subpartition by hash (b)
+subpartitions 1
+(partition p1 values in (1),
+partition p2 values in (2) (subpartition p3));
+ERROR 42000: Wrong number of subpartitions defined, mismatch with previous setting near 'subpartition p3))' at line 6
CREATE TABLE t1 (a INT, FOREIGN KEY (a) REFERENCES t0 (a))
ENGINE=MyISAM
PARTITION BY HASH (a);
@@ -1068,7 +1075,7 @@ 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)
partition by hash (a)
(partition p0 (subpartition sp0));
=== modified file 'mysql-test/t/partition.test'
--- a/mysql-test/t/partition.test 2009-07-02 14:42:00 +0000
+++ b/mysql-test/t/partition.test 2009-07-23 13:43:36 +0000
@@ -17,6 +17,20 @@ drop table if exists t1, t2;
--enable_warnings
#
+# Bug#46354: Crash when using subpartitions and only specifying the
+# last one, leads to NULL pointer on subpartition list
+# for that partition. Fixed by ensuring that if one
+# partition defines subpartitions all need to do it.
+#
+--error ER_PARSE_ERROR
+create table t1 (a int, b int)
+partition by list (a)
+subpartition by hash (b)
+subpartitions 1
+(partition p1 values in (1),
+ partition p2 values in (2) (subpartition p3));
+
+#
# Bug#36001: Partitions: spelling and using some error messages
#
--error ER_FOREIGN_KEY_ON_PARTITIONED
=== modified file 'sql/sql_yacc.yy'
--- a/sql/sql_yacc.yy 2009-07-13 17:41:43 +0000
+++ b/sql/sql_yacc.yy 2009-07-23 13:43:36 +0000
@@ -4242,6 +4242,12 @@ sub_part_definition:
{
LEX *lex= Lex;
partition_info *part_info= lex->part_info;
+ if (part_info->use_default_subpartitions &&
+ part_info->partitions.elements >= 2)
+ {
+ my_parse_error(ER(ER_PARTITION_WRONG_NO_SUBPART_ERROR));
+ MYSQL_YYABORT;
+ }
partition_element *curr_part= part_info->current_partition;
partition_element *sub_p_elem= new partition_element(curr_part);
if (!sub_p_elem ||