Commit d9992409 authored by unknown's avatar unknown

Merge zim.(none):/home/mikael/bug17127

into  zim.(none):/home/mikael/bug16370


sql/sql_partition.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
mysql-test/r/partition.result:
  manual merge
mysql-test/t/partition.test:
  manual merge
parents b08527fb 9d651ab1
...@@ -89,3 +89,16 @@ ALTER TABLE t1 ...@@ -89,3 +89,16 @@ ALTER TABLE t1
PARTITION BY KEY(a) PARTITION BY KEY(a)
(PARTITION p0 ENGINE = NDB, PARTITION p1 ENGINE = NDB); (PARTITION p0 ENGINE = NDB, PARTITION p1 ENGINE = NDB);
drop table t1; 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;
...@@ -423,6 +423,64 @@ x123 11,12 1 ...@@ -423,6 +423,64 @@ x123 11,12 1
x234 NULL,1 1 x234 NULL,1 1
drop table t1; drop table t1;
create table t1 (a int) create table t1 (a int)
partition by list (a)
(partition p0 values in (1));
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;
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
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)
partition by range (a)
(partition p0 values less than (1)); (partition p0 values less than (1));
alter table t1 add partition (partition p1 values in (2)); alter table t1 add partition (partition p1 values in (2));
ERROR HY000: Only LIST PARTITIONING can use VALUES IN in partition definition ERROR HY000: Only LIST PARTITIONING can use VALUES IN in partition definition
...@@ -450,10 +508,6 @@ partition by list (a) ...@@ -450,10 +508,6 @@ partition by list (a)
(partition p0 values in (1)); (partition p0 values in (1));
alter table t1 rebuild partition; 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 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
partition by list (a)
(partition p0 values in (1));
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; drop table t1;
create table t1 (a int) engine=innodb partition by hash(a) ; create table t1 (a int) engine=innodb partition by hash(a) ;
show table status like 't1'; show table status like 't1';
......
...@@ -141,7 +141,9 @@ DROP TABLE t1; ...@@ -141,7 +141,9 @@ DROP TABLE t1;
CREATE TABLE t1 (a INT) PARTITION BY HASH(a); CREATE TABLE t1 (a INT) PARTITION BY HASH(a);
ALTER TABLE t1 ADD PARTITION PARTITIONS 4; ALTER TABLE t1 ADD PARTITION PARTITIONS 4;
DROP TABLE t1; 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 p1 VALUES IN (0) (SUBPARTITION p1b),
PARTITION p2 VALUES IN (2) (SUBPARTITION p1b) PARTITION p2 VALUES IN (2) (SUBPARTITION p1b)
); );
......
...@@ -79,3 +79,32 @@ PARTITION BY KEY(a) ...@@ -79,3 +79,32 @@ PARTITION BY KEY(a)
(PARTITION p0 ENGINE = NDB, PARTITION p1 ENGINE = NDB); (PARTITION p0 ENGINE = NDB, PARTITION p1 ENGINE = NDB);
drop table t1; 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;
...@@ -540,6 +540,79 @@ select partition_name, partition_description, table_rows ...@@ -540,6 +540,79 @@ select partition_name, partition_description, table_rows
from information_schema.partitions where table_schema ='test'; from information_schema.partitions where table_schema ='test';
drop table t1; drop table t1;
#
# BUG 17947 Crash with REBUILD PARTITION
#
create table t1 (a int)
partition by list (a)
(partition p0 values in (1));
--error 1064
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;
#
# 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));
#
# 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 17127 # Bug 17127
# #
......
...@@ -205,7 +205,9 @@ DROP TABLE t1; ...@@ -205,7 +205,9 @@ DROP TABLE t1;
#BUG 15408: Partitions: subpartition names are not unique #BUG 15408: Partitions: subpartition names are not unique
# #
--error ER_SAME_NAME_PARTITION --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 p1 VALUES IN (0) (SUBPARTITION p1b),
PARTITION p2 VALUES IN (2) (SUBPARTITION p1b) PARTITION p2 VALUES IN (2) (SUBPARTITION p1b)
); );
...@@ -5614,6 +5614,10 @@ ER_PARTITION_MAXVALUE_ERROR ...@@ -5614,6 +5614,10 @@ ER_PARTITION_MAXVALUE_ERROR
ER_PARTITION_SUBPARTITION_ERROR ER_PARTITION_SUBPARTITION_ERROR
eng "Subpartitions can only be hash partitions and by key" eng "Subpartitions can only be hash partitions and by key"
swe "Subpartitioner kan bara vara hash och key partitioner" 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 ER_PARTITION_WRONG_NO_PART_ERROR
eng "Wrong number of partitions defined, mismatch with previous setting" eng "Wrong number of partitions defined, mismatch with previous setting"
swe "Antal partitioner definierade och antal partitioner r inte lika" swe "Antal partitioner definierade och antal partitioner r inte lika"
......
...@@ -692,12 +692,19 @@ bool check_partition_info(partition_info *part_info,handlerton **eng_type, ...@@ -692,12 +692,19 @@ bool check_partition_info(partition_info *part_info,handlerton **eng_type,
char *same_name; char *same_name;
DBUG_ENTER("check_partition_info"); 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() && if (unlikely(part_info->is_sub_partitioned() &&
(!(part_info->part_type == RANGE_PARTITION || (!(part_info->part_type == RANGE_PARTITION ||
part_info->part_type == LIST_PARTITION)))) part_info->part_type == LIST_PARTITION))))
{ {
/* Only RANGE and LIST partitioning can be subpartitioned */ /* 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; goto end;
} }
if (unlikely(part_info->set_up_defaults_for_partitioning(file, if (unlikely(part_info->set_up_defaults_for_partitioning(file,
...@@ -4078,6 +4085,7 @@ uint prep_alter_part_table(THD *thd, TABLE *table, ALTER_INFO *alter_info, ...@@ -4078,6 +4085,7 @@ uint prep_alter_part_table(THD *thd, TABLE *table, ALTER_INFO *alter_info,
ALTER_REPAIR_PARTITION | ALTER_REBUILD_PARTITION)) ALTER_REPAIR_PARTITION | ALTER_REBUILD_PARTITION))
{ {
partition_info *tab_part_info= table->part_info; partition_info *tab_part_info= table->part_info;
partition_info *alt_part_info= thd->lex->part_info;
uint flags= 0; uint flags= 0;
if (!tab_part_info) if (!tab_part_info)
{ {
...@@ -4172,7 +4180,6 @@ uint prep_alter_part_table(THD *thd, TABLE *table, ALTER_INFO *alter_info, ...@@ -4172,7 +4180,6 @@ uint prep_alter_part_table(THD *thd, TABLE *table, ALTER_INFO *alter_info,
partitioning scheme as currently set-up. partitioning scheme as currently set-up.
Partitions are always added at the end in ADD PARTITION. 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_new_partitions= alt_part_info->no_parts;
uint no_orig_partitions= tab_part_info->no_parts; uint no_orig_partitions= tab_part_info->no_parts;
uint check_total_partitions= no_new_partitions + no_orig_partitions; uint check_total_partitions= no_new_partitions + no_orig_partitions;
...@@ -4767,6 +4774,12 @@ the generated partition syntax in a correct manner. ...@@ -4767,6 +4774,12 @@ the generated partition syntax in a correct manner.
if (alter_info->flags == ALTER_ADD_PARTITION || if (alter_info->flags == ALTER_ADD_PARTITION ||
alter_info->flags == ALTER_REORGANIZE_PARTITION) alter_info->flags == ALTER_REORGANIZE_PARTITION)
{ {
if (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, if (check_partition_info(tab_part_info, (handlerton**)NULL,
table->file, ULL(0))) table->file, ULL(0)))
{ {
......
...@@ -3799,7 +3799,15 @@ part_bit_expr: ...@@ -3799,7 +3799,15 @@ part_bit_expr:
; ;
opt_sub_partition: 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 ')' | '(' sub_part_list ')'
{ {
LEX *lex= Lex; LEX *lex= Lex;
...@@ -3815,6 +3823,11 @@ opt_sub_partition: ...@@ -3815,6 +3823,11 @@ opt_sub_partition:
} }
else if (part_info->count_curr_subparts > 0) 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->no_subparts= part_info->count_curr_subparts;
} }
part_info->count_curr_subparts= 0; part_info->count_curr_subparts= 0;
......
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