1
0
mirror of https://github.com/MariaDB/server.git synced 2025-05-29 21:42:28 +03:00

Bug#10253: compound index length and utf8 char set

produces invalid query results

mi_key.c:
  well_formed_length should be executed before space trimming, not after.
ctype_utf8.test:
ctype_utf8.result:
  adding test.
This commit is contained in:
bar@mysql.com 2005-06-07 13:56:42 +05:00
parent 09212cc790
commit 093573b6b7
3 changed files with 28 additions and 3 deletions

View File

@ -84,7 +84,8 @@ uint _mi_make_key(register MI_INFO *info, uint keynr, uchar *key,
pos= (byte*) record+keyseg->start;
if (keyseg->flag & HA_SPACE_PACK)
{
end=pos+length;
FIX_LENGTH(cs, pos, length, char_length);
end= pos + char_length;
if (type != HA_KEYTYPE_NUM)
{
while (end > pos && end[-1] == ' ')
@ -95,8 +96,7 @@ uint _mi_make_key(register MI_INFO *info, uint keynr, uchar *key,
while (pos < end && pos[0] == ' ')
pos++;
}
length=(uint) (end-pos);
FIX_LENGTH(cs, pos, length, char_length);
char_length= (uint) (end - pos);
store_key_length_inc(key,char_length);
memcpy((byte*) key,(byte*) pos,(size_t) char_length);
key+=char_length;

View File

@ -891,3 +891,14 @@ string
create table t1 (a varchar(255)) default character set utf8;
insert into t1 values (1.0);
drop table t1;
create table t1 (
id int not null,
city varchar(20) not null,
key (city(7),id)
) character set=utf8;
insert into t1 values (1,'Durban North');
insert into t1 values (2,'Durban');
select * from t1 where city = 'Durban';
id city
2 Durban
drop table t1;

View File

@ -731,3 +731,17 @@ select ifnull(NULL, _utf8'string');
create table t1 (a varchar(255)) default character set utf8;
insert into t1 values (1.0);
drop table t1;
#
# Bug#10253 compound index length and utf8 char set
# produces invalid query results
#
create table t1 (
id int not null,
city varchar(20) not null,
key (city(7),id)
) character set=utf8;
insert into t1 values (1,'Durban North');
insert into t1 values (2,'Durban');
select * from t1 where city = 'Durban';
drop table t1;