Commit 01072e22 authored by Mikael Ronstrom's avatar Mikael Ronstrom

BUG#47776, Fixed character set handling, used wrong length, eventually also...

BUG#47776, Fixed character set handling, used wrong length, eventually also found that didn't need to convert to my_strnxfrm-format for column list partitioned tables, also column list partitioned tables can use multi-byte character sets in partition fields as well as where strxfrm multiplies the number of bytes in the string
parent f1437d6a
drop table if exists t1; drop table if exists t1;
create table t1 (a varchar(5))
engine=memory
partition by range column_list(a)
( partition p0 values less than (column_list('m')),
partition p1 values less than (column_list('za')));
insert into t1 values ('j');
update t1 set a = 'z' where (a >= 'j');
drop table t1;
create table t1 (a varchar(5))
engine=myisam
partition by range column_list(a)
( partition p0 values less than (column_list('m')),
partition p1 values less than (column_list('za')));
insert into t1 values ('j');
update t1 set a = 'z' where (a >= 'j');
drop table t1;
create table t1 (a varchar(5))
engine=innodb
partition by range column_list(a)
( partition p0 values less than (column_list('m')),
partition p1 values less than (column_list('za')));
insert into t1 values ('j');
update t1 set a = 'z' where (a >= 'j');
drop table t1;
CREATE TABLE t1 (id INT PRIMARY KEY, data INT) ENGINE = InnoDB CREATE TABLE t1 (id INT PRIMARY KEY, data INT) ENGINE = InnoDB
PARTITION BY RANGE(id) ( PARTITION BY RANGE(id) (
PARTITION p0 VALUES LESS THAN (5), PARTITION p0 VALUES LESS THAN (5),
......
...@@ -5,6 +5,36 @@ ...@@ -5,6 +5,36 @@
drop table if exists t1; drop table if exists t1;
--enable_warnings --enable_warnings
#
# BUG#47776, Failed to update for MEMORY engine, crash for InnoDB and success for MyISAM
#
create table t1 (a varchar(5))
engine=memory
partition by range column_list(a)
( partition p0 values less than (column_list('m')),
partition p1 values less than (column_list('za')));
insert into t1 values ('j');
update t1 set a = 'z' where (a >= 'j');
drop table t1;
create table t1 (a varchar(5))
engine=myisam
partition by range column_list(a)
( partition p0 values less than (column_list('m')),
partition p1 values less than (column_list('za')));
insert into t1 values ('j');
update t1 set a = 'z' where (a >= 'j');
drop table t1;
create table t1 (a varchar(5))
engine=innodb
partition by range column_list(a)
( partition p0 values less than (column_list('m')),
partition p1 values less than (column_list('za')));
insert into t1 values ('j');
update t1 set a = 'z' where (a >= 'j');
drop table t1;
# #
# Bug#40595: Non-matching rows not released with READ-COMMITTED on tables # Bug#40595: Non-matching rows not released with READ-COMMITTED on tables
# with partitions # with partitions
......
...@@ -1404,15 +1404,21 @@ static void set_up_partition_func_pointers(partition_info *part_info) ...@@ -1404,15 +1404,21 @@ static void set_up_partition_func_pointers(partition_info *part_info)
if (part_info->is_sub_partitioned()) if (part_info->is_sub_partitioned())
{ {
DBUG_ASSERT(part_info->get_part_partition_id); DBUG_ASSERT(part_info->get_part_partition_id);
part_info->get_part_partition_id_charset= if (!part_info->column_list)
part_info->get_part_partition_id; {
part_info->get_part_partition_id=
part_info->get_part_partition_id_charset;
part_info->get_part_partition_id= get_part_id_charset_func_part; part_info->get_part_partition_id= get_part_id_charset_func_part;
} }
}
else else
{ {
DBUG_ASSERT(part_info->get_partition_id); DBUG_ASSERT(part_info->get_partition_id);
if (!part_info->column_list)
{
part_info->get_part_partition_id_charset= part_info->get_partition_id; part_info->get_part_partition_id_charset= part_info->get_partition_id;
part_info->get_partition_id= get_part_id_charset_func_part; part_info->get_part_partition_id= get_part_id_charset_func_part;
}
} }
} }
if (part_info->subpart_charset_field_array) if (part_info->subpart_charset_field_array)
...@@ -1715,7 +1721,8 @@ bool fix_partition_func(THD *thd, TABLE *table, ...@@ -1715,7 +1721,8 @@ bool fix_partition_func(THD *thd, TABLE *table,
} }
if (((part_info->part_type != HASH_PARTITION || if (((part_info->part_type != HASH_PARTITION ||
part_info->list_of_part_fields == FALSE) && part_info->list_of_part_fields == FALSE) &&
check_part_func_fields(part_info->part_field_array, TRUE)) || (!part_info->column_list &&
check_part_func_fields(part_info->part_field_array, TRUE))) ||
(part_info->list_of_part_fields == FALSE && (part_info->list_of_part_fields == FALSE &&
part_info->is_sub_partitioned() && part_info->is_sub_partitioned() &&
check_part_func_fields(part_info->subpart_field_array, TRUE))) check_part_func_fields(part_info->subpart_field_array, TRUE)))
...@@ -2603,7 +2610,8 @@ static void copy_to_part_field_buffers(Field **ptr, ...@@ -2603,7 +2610,8 @@ static void copy_to_part_field_buffers(Field **ptr,
if (!field->maybe_null() || !field->is_null()) if (!field->maybe_null() || !field->is_null())
{ {
CHARSET_INFO *cs= ((Field_str*)field)->charset(); CHARSET_INFO *cs= ((Field_str*)field)->charset();
uint len= field->pack_length(); uint max_len= field->pack_length();
uint data_len= field->data_length();
uchar *field_buf= *field_bufs; uchar *field_buf= *field_bufs;
/* /*
We only use the field buffer for VARCHAR and CHAR strings We only use the field buffer for VARCHAR and CHAR strings
...@@ -2615,17 +2623,17 @@ static void copy_to_part_field_buffers(Field **ptr, ...@@ -2615,17 +2623,17 @@ static void copy_to_part_field_buffers(Field **ptr,
if (field->type() == MYSQL_TYPE_VARCHAR) if (field->type() == MYSQL_TYPE_VARCHAR)
{ {
uint len_bytes= ((Field_varstring*)field)->length_bytes; uint len_bytes= ((Field_varstring*)field)->length_bytes;
my_strnxfrm(cs, field_buf + len_bytes, (len - len_bytes), my_strnxfrm(cs, field_buf + len_bytes, max_len,
field->ptr + len_bytes, field->field_length); field->ptr + len_bytes, data_len);
if (len_bytes == 1) if (len_bytes == 1)
*field_buf= (uchar) field->field_length; *field_buf= (uchar) data_len;
else else
int2store(field_buf, field->field_length); int2store(field_buf, data_len);
} }
else else
{ {
my_strnxfrm(cs, field_buf, len, my_strnxfrm(cs, field_buf, max_len,
field->ptr, field->field_length); field->ptr, max_len);
} }
field->ptr= field_buf; field->ptr= field_buf;
} }
......
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