Added checks for no NULL values in VALUES LESS THAN, added tests for no MAXVALUE in VALUES IN

This commit is contained in:
Mikael Ronstrom 2009-10-21 20:53:44 +02:00
parent cb4bf11965
commit 57d455460d
5 changed files with 46 additions and 19 deletions

View File

@ -1,5 +1,13 @@
drop table if exists t1;
create table t1 (a int, b int)
partition by range column_list (a,b)
(partition p0 values less than (NULL, maxvalue));
ERROR HY000: Not allowed to use NULL value in VALUES LESS THAN
create table t1 (a int, b int)
partition by list column_list(a,b)
( partition p0 values in ((maxvalue, 0)));
Got one of the listed errors
create table t1 (a int, b int)
partition by key (a,a);
ERROR HY000: Duplicate partition field name a
create table t1 (a int, b int)
@ -144,17 +152,17 @@ create table t1 (a int, b char(10), c varchar(25), d datetime)
partition by range column_list(a,b,c,d)
subpartition by hash (to_seconds(d))
subpartitions 4
( partition p0 values less than (1, NULL, MAXVALUE, NULL),
( partition p0 values less than (1, 0, MAXVALUE, 0),
partition p1 values less than (1, 'a', MAXVALUE, TO_DAYS('1999-01-01')),
partition p2 values less than (1, 'a', MAXVALUE, MAXVALUE),
partition p3 values less than (1, MAXVALUE, MAXVALUE, MAXVALUE));
select partition_method, partition_expression, partition_description
from information_schema.partitions where table_name = "t1";
partition_method partition_expression partition_description
RANGE COLUMN_LIST a,b,c,d 1,NULL,MAXVALUE,NULL
RANGE COLUMN_LIST a,b,c,d 1,NULL,MAXVALUE,NULL
RANGE COLUMN_LIST a,b,c,d 1,NULL,MAXVALUE,NULL
RANGE COLUMN_LIST a,b,c,d 1,NULL,MAXVALUE,NULL
RANGE COLUMN_LIST a,b,c,d 1,0,MAXVALUE,0
RANGE COLUMN_LIST a,b,c,d 1,0,MAXVALUE,0
RANGE COLUMN_LIST a,b,c,d 1,0,MAXVALUE,0
RANGE COLUMN_LIST a,b,c,d 1,0,MAXVALUE,0
RANGE COLUMN_LIST a,b,c,d 1,'a',MAXVALUE,730120
RANGE COLUMN_LIST a,b,c,d 1,'a',MAXVALUE,730120
RANGE COLUMN_LIST a,b,c,d 1,'a',MAXVALUE,730120
@ -233,7 +241,7 @@ partition p1 values less than ('2040-01-01'));
ERROR HY000: Partition column values of incorrect type
create table t1 (a int, b int)
partition by range column_list(a,b)
(partition p0 values less than (null, 10));
(partition p0 values less than (maxvalue, 10));
drop table t1;
create table t1 (d date)
partition by range column_list(d)
@ -268,7 +276,7 @@ drop table t1;
create table t1 (a int, b int)
partition by list column_list(a,b)
(partition p0 values in ((maxvalue,maxvalue)));
ERROR 42000: Cannot use MAXVALUE as value in List partitioning near 'maxvalue,maxvalue)))' at line 3
ERROR 42000: Cannot use MAXVALUE as value in VALUES IN near 'maxvalue,maxvalue)))' at line 3
create table t1 (a int, b int)
partition by range column_list(a,b)
(partition p0 values less than (maxvalue,maxvalue));
@ -309,11 +317,11 @@ partition by range column_list(a,b)
ERROR HY000: Inconsistency in usage of column lists for partitioning
create table t1 (a int, b int)
partition by range column_list(a,b)
(partition p0 values less than (1, NULL),
(partition p0 values less than (1, 0),
partition p1 values less than (2, maxvalue),
partition p2 values less than (3, 3),
partition p3 values less than (10, NULL));
insert into t1 values (10,0);
partition p3 values less than (10, maxvalue));
insert into t1 values (11,0);
ERROR HY000: Table has no partition for value from column_list
insert into t1 values (0,1),(1,1),(2,1),(3,1),(3,4),(4,9),(9,1);
select * from t1;

View File

@ -8,6 +8,16 @@
drop table if exists t1;
--enable_warnings
--error ER_NULL_IN_VALUES_LESS_THAN
create table t1 (a int, b int)
partition by range column_list (a,b)
(partition p0 values less than (NULL, maxvalue));
--error ER_MAXVALUE_IN_VALUES_IN, ER_PARSE_ERROR
create table t1 (a int, b int)
partition by list column_list(a,b)
( partition p0 values in ((maxvalue, 0)));
#
# BUG#47837, Crash when two same fields in column list processing
#
@ -115,7 +125,7 @@ create table t1 (a int, b char(10), c varchar(25), d datetime)
partition by range column_list(a,b,c,d)
subpartition by hash (to_seconds(d))
subpartitions 4
( partition p0 values less than (1, NULL, MAXVALUE, NULL),
( partition p0 values less than (1, 0, MAXVALUE, 0),
partition p1 values less than (1, 'a', MAXVALUE, TO_DAYS('1999-01-01')),
partition p2 values less than (1, 'a', MAXVALUE, MAXVALUE),
partition p3 values less than (1, MAXVALUE, MAXVALUE, MAXVALUE));
@ -168,7 +178,7 @@ partition by range column_list(d)
create table t1 (a int, b int)
partition by range column_list(a,b)
(partition p0 values less than (null, 10));
(partition p0 values less than (maxvalue, 10));
drop table t1;
create table t1 (d date)
@ -250,13 +260,13 @@ partition by range column_list(a,b)
create table t1 (a int, b int)
partition by range column_list(a,b)
(partition p0 values less than (1, NULL),
(partition p0 values less than (1, 0),
partition p1 values less than (2, maxvalue),
partition p2 values less than (3, 3),
partition p3 values less than (10, NULL));
partition p3 values less than (10, maxvalue));
-- error ER_NO_PARTITION_FOR_GIVEN_VALUE
insert into t1 values (10,0);
insert into t1 values (11,0);
insert into t1 values (0,1),(1,1),(2,1),(3,1),(3,4),(4,9),(9,1);
select * from t1;

View File

@ -1992,7 +1992,7 @@ int partition_info::fix_parser_data(THD *thd)
partition_element *part_elem;
part_elem_value *val;
uint num_elements;
uint i= 0, j;
uint i= 0, j, k;
int result;
DBUG_ENTER("partition_info::fix_parser_data");
@ -2020,6 +2020,15 @@ int partition_info::fix_parser_data(THD *thd)
my_error(ER_PARTITION_COLUMN_LIST_ERROR, MYF(0));
DBUG_RETURN(TRUE);
}
for (k= 0; k < num_columns; k++)
{
part_column_list_val *col_val= &val->col_val_array[k];
if (col_val->null_value && part_type == RANGE_PARTITION)
{
my_error(ER_NULL_IN_VALUES_LESS_THAN, MYF(0));
DBUG_RETURN(TRUE);
}
}
}
else
{

View File

@ -6214,8 +6214,8 @@ ER_WRONG_TYPE_COLUMN_VALUE_ERROR
eng "Partition column values of incorrect type"
ER_TOO_MANY_PARTITION_FUNC_FIELDS_ERROR
eng "Too many fields in '%-.192s'"
ER_MAXVALUE_IN_LIST_PARTITIONING_ERROR
eng "Cannot use MAXVALUE as value in List partitioning"
ER_MAXVALUE_IN_VALUES_IN
eng "Cannot use MAXVALUE as value in VALUES IN"
ER_TOO_MANY_VALUES_ERROR
eng "Cannot have more than one value for this type of %-.64s partitioning"
ER_ROW_SINGLE_PARTITION_FIELD_ERROR

View File

@ -4229,7 +4229,7 @@ part_value_expr_item:
part_column_list_val *col_val;
if (part_info->part_type == LIST_PARTITION)
{
my_parse_error(ER(ER_MAXVALUE_IN_LIST_PARTITIONING_ERROR));
my_parse_error(ER(ER_MAXVALUE_IN_VALUES_IN));
MYSQL_YYABORT;
}
if (part_info->add_max_value())