diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result index 2b5b47aeedd..5605b4b6c2a 100644 --- a/mysql-test/r/partition.result +++ b/mysql-test/r/partition.result @@ -750,11 +750,6 @@ t2 CREATE TABLE `t2` ( PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='no comment' /*!50100 PARTITION BY KEY (a) */ drop table t2; -create table t1 (s1 char(2) character set utf8) -partition by list (cast(s1 as signed)) -(partition p1 values in (1), -partition p2 values in (2)); -drop table t1; create table t1 (f1 int) partition by hash (f1) as select 1; drop table t1; prepare stmt1 from 'create table t1 (s1 int) partition by hash (s1)'; diff --git a/mysql-test/r/partition_error.result b/mysql-test/r/partition_error.result index 6ded066c3ec..87ae1d62a04 100644 --- a/mysql-test/r/partition_error.result +++ b/mysql-test/r/partition_error.result @@ -641,7 +641,7 @@ ERROR HY000: Partition constant is out of partition function domain create table t1 (v varchar(12)) partition by range (ascii(v)) (partition p0 values less than (10)); -drop table t1; +ERROR HY000: This partition function is not allowed create table t1 (a int) partition by hash (rand(a)); ERROR 42000: Constant/Random expression in (sub)partitioning function is not allowed near ')' at line 2 diff --git a/mysql-test/r/partition_pruning.result b/mysql-test/r/partition_pruning.result index bf7888bfd99..8125ae91959 100644 --- a/mysql-test/r/partition_pruning.result +++ b/mysql-test/r/partition_pruning.result @@ -284,13 +284,6 @@ explain partitions select * from t9 where a <= '2004-12-19'; id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t9 p0,p1 ALL NULL NULL NULL NULL 2 Using where drop table t5,t6,t7,t8,t9; -create table t1 (a enum('a','b','c','d') default 'a') -partition by hash (ascii(a)) partitions 2; -insert into t1 values ('a'),('b'),('c'); -explain partitions select * from t1 where a='b'; -id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0,p1 ALL NULL NULL NULL NULL 3 Using where -drop table t1; create table t1 ( a1 int not null ) @@ -643,8 +636,9 @@ f_int1 f_int2 8 8 9 9 drop table t1; -create table t1 (a char(10)) partition by list(length(a)) ( -partition p1 values in (1), +create table t1 (a char(10) binary) +partition by list(length(a)) +(partition p1 values in (1), partition p2 values in (2), partition p3 values in (3), partition p4 values in (4), diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test index 4583c06e74f..6fe06dfc8af 100644 --- a/mysql-test/t/partition.test +++ b/mysql-test/t/partition.test @@ -883,11 +883,13 @@ drop table t2; # # Bug#14367: Partitions: crash if utf8 column # -create table t1 (s1 char(2) character set utf8) -partition by list (cast(s1 as signed)) -(partition p1 values in (1), - partition p2 values in (2)); -drop table t1; +# utf columns not supported after Bug #18198 is fixed +# +#create table t1 (s1 char(2) character set utf8) +#partition by list (cast(s1 as signed)) +#(partition p1 values in (1), +# partition p2 values in (2)); +#drop table t1; # # Bug#15336 Partitions: crash if create table as select diff --git a/mysql-test/t/partition_error.test b/mysql-test/t/partition_error.test index a9efbc587be..2c0706cb2cb 100644 --- a/mysql-test/t/partition_error.test +++ b/mysql-test/t/partition_error.test @@ -809,10 +809,10 @@ partition by range (a) # # Bug 18198 Partitions: Verify that erroneus partition functions doesn't work # +-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED create table t1 (v varchar(12)) partition by range (ascii(v)) (partition p0 values less than (10)); -drop table t1; -- error 1064 create table t1 (a int) diff --git a/mysql-test/t/partition_pruning.test b/mysql-test/t/partition_pruning.test index dd79e8d3acb..e0ed5c1c844 100644 --- a/mysql-test/t/partition_pruning.test +++ b/mysql-test/t/partition_pruning.test @@ -238,11 +238,14 @@ explain partitions select * from t9 where a <= '2004-12-19'; drop table t5,t6,t7,t8,t9; # Test the case where we can't create partitioning 'index' -create table t1 (a enum('a','b','c','d') default 'a') - partition by hash (ascii(a)) partitions 2; -insert into t1 values ('a'),('b'),('c'); -explain partitions select * from t1 where a='b'; -drop table t1; +# +# Not supported after bug#18198 is fixed +# +#create table t1 (a enum('a','b','c','d') default 'a') +# partition by hash (ascii(a)) partitions 2; +#insert into t1 values ('a'),('b'),('c'); +#explain partitions select * from t1 where a='b'; +#drop table t1; # # Test cases for bugs found in code review: @@ -519,8 +522,9 @@ select * from t1 where f_int1 between 5 and 15 order by f_int1; drop table t1; # part2: bug in pruning code -create table t1 (a char(10)) partition by list(length(a)) ( - partition p1 values in (1), +create table t1 (a char(10) binary) +partition by list(length(a)) + (partition p1 values in (1), partition p2 values in (2), partition p3 values in (3), partition p4 values in (4), diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 55eab215746..54610328694 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -1553,8 +1553,11 @@ bool fix_partition_func(THD *thd, TABLE *table, goto end; } } - if ((check_part_func_fields(part_info->part_field_array)) || - (part_info->is_sub_partitioned() && + if (((part_info->part_type != HASH_PARTITION || + part_info->list_of_part_fields == FALSE) && + check_part_func_fields(part_info->part_field_array)) || + (part_info->list_of_part_fields == FALSE && + part_info->is_sub_partitioned() && check_part_func_fields(part_info->subpart_field_array))) { my_error(ER_PARTITION_FUNCTION_IS_NOT_ALLOWED, MYF(0));