From 56c24480a98ba8f56fd1fce35fd414741da16015 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 11 Mar 2006 05:56:06 -0800 Subject: [PATCH 1/4] 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 mysql-test/r/partition.result: New test cases mysql-test/t/partition.test: New test cases sql/sql_partition.cc: Ensure that default subpartitioning is removed when subpartitions are defined in ADD/REORGANIZE PARTITION --- mysql-test/r/partition.result | 36 +++++++++++++++++++++++++++++++++++ mysql-test/t/partition.test | 36 +++++++++++++++++++++++++++++++++++ sql/sql_partition.cc | 9 ++++++++- 3 files changed, 80 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result index 80942c861fe..5a956379a47 100644 --- a/mysql-test/r/partition.result +++ b/mysql-test/r/partition.result @@ -428,4 +428,40 @@ 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 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 diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test index 8fc46490856..764ef788991 100644 --- a/mysql-test/t/partition.test +++ b/mysql-test/t/partition.test @@ -552,4 +552,40 @@ alter table t1 rebuild partition; 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 diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 014d3616d3d..3419aee4b26 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -4069,6 +4069,7 @@ uint prep_alter_part_table(THD *thd, TABLE *table, ALTER_INFO *alter_info, ALTER_REPAIR_PARTITION | ALTER_REBUILD_PARTITION)) { partition_info *tab_part_info= table->part_info; + partition_info *alt_part_info= thd->lex->part_info; if (!tab_part_info) { 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, partitioning scheme as currently set-up. 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_orig_partitions= tab_part_info->no_parts; uint check_total_partitions= no_new_partitions + no_orig_partitions; @@ -4736,6 +4736,13 @@ the generated partition syntax in a correct manner. if (alter_info->flags == ALTER_ADD_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, table->file, ULL(0))) { From 402ff5523e9ffcffedbca6f18ffcfb1d8a72c310 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 11 Mar 2006 06:32:24 -0800 Subject: [PATCH 2/4] Ensure we discover also error in using subpartition parts in non-subpartitioned tables in ALTER TABLE ADD/REORGANIZE PARTITION --- sql/sql_partition.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 3419aee4b26..5a6196d94fa 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -4736,8 +4736,7 @@ the generated partition syntax in a correct manner. if (alter_info->flags == ALTER_ADD_PARTITION || alter_info->flags == ALTER_REORGANIZE_PARTITION) { - if (tab_part_info->is_sub_partitioned() && - tab_part_info->use_default_subpartitions && + if (tab_part_info->use_default_subpartitions && !alt_part_info->use_default_subpartitions) { tab_part_info->use_default_subpartitions= FALSE; From aa451a0e07254dfd1f7e1229018d05fc895e312d Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 13 Mar 2006 02:36:02 -0800 Subject: [PATCH 3/4] BUG#15407: Crash if error in subpartition definition mysql-test/r/partition.result: New test cases mysql-test/t/partition.test: New test cases sql/sql_yacc.yy: New error checks --- mysql-test/r/partition.result | 12 ++++++++++++ mysql-test/t/partition.test | 17 +++++++++++++++++ sql/sql_yacc.yy | 15 ++++++++++++++- 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result index 5a956379a47..33f4399d581 100644 --- a/mysql-test/r/partition.result +++ b/mysql-test/r/partition.result @@ -464,4 +464,16 @@ 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; +create table t1 (a int, b int) +partition by range (a) +subpartition by hash(a) +(partition p0 values less than (0) (subpartition sp0), +partition p1 values less than (1)); +ERROR 42000: Wrong number of subpartitions defined, mismatch with previous setting near ')' at line 5 +create table t1 (a int, b int) +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 End of 5.1 tests diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test index 764ef788991..bb551a46ca8 100644 --- a/mysql-test/t/partition.test +++ b/mysql-test/t/partition.test @@ -588,4 +588,21 @@ show create table t1; drop table t1; +# +# BUG 15407 Crash with subpartition +# +--error 1064 +create table t1 (a int, b int) +partition by range (a) +subpartition by hash(a) +(partition p0 values less than (0) (subpartition sp0), + partition p1 values less than (1)); + +--error 1064 +create table t1 (a int, b int) +partition by range (a) +subpartition by hash(a) +(partition p0 values less than (0), + partition p1 values less than (1) (subpartition sp0)); + --echo End of 5.1 tests diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 47852212b84..cae9bb168c4 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -3793,7 +3793,15 @@ part_bit_expr: ; opt_sub_partition: - /* empty */ {} + /* empty */ + { + if (Lex->part_info->no_subparts != 0 && + !Lex->part_info->use_default_subpartitions) + { + yyerror(ER(ER_PARTITION_WRONG_NO_SUBPART_ERROR)); + YYABORT; + } + } | '(' sub_part_list ')' { LEX *lex= Lex; @@ -3809,6 +3817,11 @@ opt_sub_partition: } else if (part_info->count_curr_subparts > 0) { + if (part_info->partitions.elements > 1) + { + yyerror(ER(ER_PARTITION_WRONG_NO_SUBPART_ERROR)); + YYABORT; + } part_info->no_subparts= part_info->count_curr_subparts; } part_info->count_curr_subparts= 0; From c472bdbafa3a2624ea8c92fa97810480a206b8a9 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 13 Mar 2006 09:09:25 -0800 Subject: [PATCH 4/4] BUG #16810: Error on coalesce partition New test case (bug was already fixed) mysql-test/r/ndb_partition_key.result: New test case mysql-test/t/ndb_partition_key.test: New test case --- mysql-test/r/ndb_partition_key.result | 13 ++++++++++++ mysql-test/t/ndb_partition_key.test | 29 +++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/mysql-test/r/ndb_partition_key.result b/mysql-test/r/ndb_partition_key.result index 8842a6e1398..90ecde51e9f 100644 --- a/mysql-test/r/ndb_partition_key.result +++ b/mysql-test/r/ndb_partition_key.result @@ -89,3 +89,16 @@ ALTER TABLE t1 PARTITION BY KEY(a) (PARTITION p0 ENGINE = NDB, PARTITION p1 ENGINE = NDB); drop table t1; +CREATE TABLE t1 ( +c1 MEDIUMINT NOT NULL AUTO_INCREMENT, +c2 TEXT NOT NULL, +c3 INT NOT NULL, +c4 BIT NOT NULL, +c5 FLOAT, +c6 VARCHAR(255), +c7 TIMESTAMP, +PRIMARY KEY(c1,c3)) +ENGINE=NDB +PARTITION BY KEY(c3) PARTITIONS 5; +ALTER TABLE t1 COALESCE PARTITION 4; +DROP TABLE t1; diff --git a/mysql-test/t/ndb_partition_key.test b/mysql-test/t/ndb_partition_key.test index 7f6120fe094..22c84bf132e 100644 --- a/mysql-test/t/ndb_partition_key.test +++ b/mysql-test/t/ndb_partition_key.test @@ -79,3 +79,32 @@ PARTITION BY KEY(a) (PARTITION p0 ENGINE = NDB, PARTITION p1 ENGINE = NDB); drop table t1; + +# +# BUG 16810 Out of memory when coalesce partition +# +CREATE TABLE t1 ( + c1 MEDIUMINT NOT NULL AUTO_INCREMENT, + c2 TEXT NOT NULL, + c3 INT NOT NULL, + c4 BIT NOT NULL, + c5 FLOAT, + c6 VARCHAR(255), + c7 TIMESTAMP, + PRIMARY KEY(c1,c3)) + ENGINE=NDB + PARTITION BY KEY(c3) PARTITIONS 5; + +let $j= 11; +--disable_query_log +while ($j) +{ + eval INSERT INTO t1 VALUES (NULL, "Tested Remotely from Texas, USA", $j, +b'0', + $j.00,"By JBM $j","2006-01-26"); + dec $j; +} +--enable_query_log +ALTER TABLE t1 COALESCE PARTITION 4; + +DROP TABLE t1;