Bug#4594: column index make = failed for gbk, but like works
Fix for HEAP+HASH prefix keys.
This commit is contained in:
parent
8522f83038
commit
c3c483e091
@ -560,3 +560,13 @@ select * from t1 where str='str';
|
|||||||
str
|
str
|
||||||
str
|
str
|
||||||
drop table t1;
|
drop table t1;
|
||||||
|
create table t1 (
|
||||||
|
str varchar(255) character set utf8 not null,
|
||||||
|
key str using hash (str(2))
|
||||||
|
) engine=heap;
|
||||||
|
INSERT INTO t1 VALUES ('str');
|
||||||
|
INSERT INTO t1 VALUES ('str2');
|
||||||
|
select * from t1 where str='str';
|
||||||
|
str
|
||||||
|
str
|
||||||
|
drop table t1;
|
||||||
|
@ -417,3 +417,15 @@ INSERT INTO t1 VALUES ('str');
|
|||||||
INSERT INTO t1 VALUES ('str2');
|
INSERT INTO t1 VALUES ('str2');
|
||||||
select * from t1 where str='str';
|
select * from t1 where str='str';
|
||||||
drop table t1;
|
drop table t1;
|
||||||
|
|
||||||
|
# the same for HEAP+HASH
|
||||||
|
#
|
||||||
|
|
||||||
|
create table t1 (
|
||||||
|
str varchar(255) character set utf8 not null,
|
||||||
|
key str using hash (str(2))
|
||||||
|
) engine=heap;
|
||||||
|
INSERT INTO t1 VALUES ('str');
|
||||||
|
INSERT INTO t1 VALUES ('str2');
|
||||||
|
select * from t1 where str='str';
|
||||||
|
drop table t1;
|
||||||
|
13
sql/key.cc
13
sql/key.cc
@ -211,10 +211,17 @@ bool key_cmp_if_same(TABLE *table,const byte *key,uint idx,uint key_length)
|
|||||||
if (!(key_part->key_type & (FIELDFLAG_NUMBER+FIELDFLAG_BINARY+
|
if (!(key_part->key_type & (FIELDFLAG_NUMBER+FIELDFLAG_BINARY+
|
||||||
FIELDFLAG_PACK)))
|
FIELDFLAG_PACK)))
|
||||||
{
|
{
|
||||||
if (my_strnncoll(key_part->field->charset(),
|
CHARSET_INFO *cs= key_part->field->charset();
|
||||||
|
uint char_length= key_part->length / cs->mbmaxlen;
|
||||||
|
const byte *pos= table->record[0] + key_part->offset;
|
||||||
|
if (length > char_length)
|
||||||
|
{
|
||||||
|
char_length= my_charpos(cs, pos, pos + length, char_length);
|
||||||
|
set_if_smaller(char_length, length);
|
||||||
|
}
|
||||||
|
if (cs->coll->strnncollsp(cs,
|
||||||
(const uchar*) key, length,
|
(const uchar*) key, length,
|
||||||
(const uchar*) table->record[0]+key_part->offset,
|
(const uchar*) pos, char_length))
|
||||||
length))
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else if (memcmp(key,table->record[0]+key_part->offset,length))
|
else if (memcmp(key,table->record[0]+key_part->offset,length))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user