diff --git a/mysql-test/r/partition_charset.result b/mysql-test/r/partition_charset.result index 665e5d55f8f..bb6cb5e3bef 100644 --- a/mysql-test/r/partition_charset.result +++ b/mysql-test/r/partition_charset.result @@ -16,3 +16,9 @@ s1 1 3 drop table t1; +create table t1 (a varchar(1), primary key (a)) +partition by list (ascii(a)) +(partition p1 values in (65)); +insert into t1 values ('A'); +replace into t1 values ('A'); +drop table t1; diff --git a/mysql-test/r/partition_list.result b/mysql-test/r/partition_list.result index e64a7a8d154..a68a67c6386 100644 --- a/mysql-test/r/partition_list.result +++ b/mysql-test/r/partition_list.result @@ -295,3 +295,7 @@ select * from t1; a 100 drop table t1; +create table t1 (a char(1)) +partition by list (ascii(ucase(a))) +(partition p1 values in (2)); +ERROR HY000: This partition function is not allowed diff --git a/mysql-test/t/partition_list.test b/mysql-test/t/partition_list.test index 7d71d66f2d9..1c76de9d55a 100644 --- a/mysql-test/t/partition_list.test +++ b/mysql-test/t/partition_list.test @@ -179,7 +179,7 @@ insert into t1 values (null); select * from t1; drop table t1; --- error ER_PARTITION_FUNC_NOT_ALLOWED +--error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED create table t1 (a char(1)) partition by list (ascii(ucase(a))) (partition p1 values in (2)); diff --git a/sql/partition_info.cc b/sql/partition_info.cc index 3af79f453ad..6dfedde7116 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -951,6 +951,7 @@ bool partition_info::set_up_charset_field_preps() if (!(char_ptrs= (char**)sql_alloc(size))) goto error; subpart_charset_field_array= (Field**)char_ptrs; + ptr= subpart_field_array; i= 0; while ((field= *(ptr++))) { diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 86068cc5c0d..c02beee350c 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -3315,13 +3315,16 @@ static uint32 get_sub_part_id_from_key(const TABLE *table,byte *buf, uint32 part_id; DBUG_ENTER("get_sub_part_id_from_key"); - key_restore(buf, (byte*)key_spec->key, key_info, key_spec->length); if (likely(rec0 == buf)) + { + key_restore(buf, (byte*)key_spec->key, key_info, key_spec->length); part_id= part_info->get_subpartition_id(part_info); + } else { Field **part_field_array= part_info->subpart_field_array; set_field_ptr(part_field_array, buf, rec0); + key_restore(buf, (byte*)key_spec->key, key_info, key_spec->length); part_id= part_info->get_subpartition_id(part_info); set_field_ptr(part_field_array, rec0, buf); } @@ -3358,14 +3361,17 @@ bool get_part_id_from_key(const TABLE *table, byte *buf, KEY *key_info, longlong func_value; DBUG_ENTER("get_part_id_from_key"); - key_restore(buf, (byte*)key_spec->key, key_info, key_spec->length); if (likely(rec0 == buf)) + { + key_restore(buf, (byte*)key_spec->key, key_info, key_spec->length); result= part_info->get_part_partition_id(part_info, part_id, &func_value); + } else { Field **part_field_array= part_info->part_field_array; set_field_ptr(part_field_array, buf, rec0); + key_restore(buf, (byte*)key_spec->key, key_info, key_spec->length); result= part_info->get_part_partition_id(part_info, part_id, &func_value); set_field_ptr(part_field_array, rec0, buf); @@ -3405,14 +3411,17 @@ void get_full_part_id_from_key(const TABLE *table, byte *buf, longlong func_value; DBUG_ENTER("get_full_part_id_from_key"); - key_restore(buf, (byte*)key_spec->key, key_info, key_spec->length); if (likely(rec0 == buf)) + { + key_restore(buf, (byte*)key_spec->key, key_info, key_spec->length); result= part_info->get_partition_id(part_info, &part_spec->start_part, &func_value); + } else { Field **part_field_array= part_info->full_part_field_array; set_field_ptr(part_field_array, buf, rec0); + key_restore(buf, (byte*)key_spec->key, key_info, key_spec->length); result= part_info->get_partition_id(part_info, &part_spec->start_part, &func_value); set_field_ptr(part_field_array, rec0, buf);