diff options
author | Mikael Ronstrom <mikael@mysql.com> | 2009-10-21 20:53:44 +0200 |
---|---|---|
committer | Mikael Ronstrom <mikael@mysql.com> | 2009-10-21 20:53:44 +0200 |
commit | 57d455460d52da8b124d839fb6462d55b0ca2ee7 (patch) | |
tree | 68dfb95850fcf981ed46f9e26172009717ca5472 | |
parent | cb4bf11965aa5088047ec563cf0247e54b976950 (diff) | |
download | mariadb-git-57d455460d52da8b124d839fb6462d55b0ca2ee7.tar.gz |
Added checks for no NULL values in VALUES LESS THAN, added tests for no MAXVALUE in VALUES IN
-rw-r--r-- | mysql-test/r/partition_column.result | 28 | ||||
-rw-r--r-- | mysql-test/t/partition_column.test | 20 | ||||
-rw-r--r-- | sql/partition_info.cc | 11 | ||||
-rw-r--r-- | sql/share/errmsg.txt | 4 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 2 |
5 files changed, 46 insertions, 19 deletions
diff --git a/mysql-test/r/partition_column.result b/mysql-test/r/partition_column.result index 8bc48553d95..f1bb0a3488a 100644 --- a/mysql-test/r/partition_column.result +++ b/mysql-test/r/partition_column.result @@ -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; diff --git a/mysql-test/t/partition_column.test b/mysql-test/t/partition_column.test index 980aca5a8c5..baeed6bb0a8 100644 --- a/mysql-test/t/partition_column.test +++ b/mysql-test/t/partition_column.test @@ -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; diff --git a/sql/partition_info.cc b/sql/partition_info.cc index 52535041776..3bce7dac1fa 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -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 { diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt index 69f18088807..0bbdacee0bc 100644 --- a/sql/share/errmsg.txt +++ b/sql/share/errmsg.txt @@ -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 diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index c2873bffe9e..43753b7fab2 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -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()) |