Commit 8f68a9eb authored by unknown's avatar unknown

Bug#4594 "column index make = failed for gbk, but like works"

Fix for MyISAM. Tests for MyISAM and HASH+BTREE.

parent a6352443
......@@ -42,7 +42,7 @@ uint _mi_make_key(register MI_INFO *info, uint keynr, uchar *key,
byte *pos,*end;
uchar *start;
reg1 HA_KEYSEG *keyseg;
my_bool is_unique=info->s->keyinfo[keynr].flag & HA_NOSAME;
my_bool is_ft= info->s->keyinfo[keynr].flag & HA_FULLTEXT;
DBUG_ENTER("_mi_make_key");
if(info->s->keyinfo[keynr].flag & HA_SPATIAL)
......@@ -75,7 +75,7 @@ uint _mi_make_key(register MI_INFO *info, uint keynr, uchar *key,
*key++=1; /* Not NULL */
}
char_length= (is_unique && cs && cs->mbmaxlen > 1) ? length/cs->mbmaxlen : length;
char_length= (!is_ft && cs && cs->mbmaxlen > 1) ? length/cs->mbmaxlen : length;
pos= (byte*) record+keyseg->start;
if (keyseg->flag & HA_SPACE_PACK)
......@@ -193,7 +193,7 @@ uint _mi_pack_key(register MI_INFO *info, uint keynr, uchar *key, uchar *old,
{
uchar *start_key=key;
HA_KEYSEG *keyseg;
my_bool is_unique=info->s->keyinfo[keynr].flag & HA_NOSAME;
my_bool is_ft= info->s->keyinfo[keynr].flag & HA_FULLTEXT;
DBUG_ENTER("_mi_pack_key");
for (keyseg=info->s->keyinfo[keynr].seg ;
......@@ -217,7 +217,7 @@ uint _mi_pack_key(register MI_INFO *info, uint keynr, uchar *key, uchar *old,
continue; /* Found NULL */
}
}
char_length= (is_unique && cs && cs->mbmaxlen > 1) ? length/cs->mbmaxlen : length;
char_length= (!is_ft && cs && cs->mbmaxlen > 1) ? length/cs->mbmaxlen : length;
pos=old;
if (keyseg->flag & HA_SPACE_PACK)
{
......
......@@ -540,3 +540,23 @@ select c as c_a from t1 where c='б';
c_a
б
drop table t1;
create table t1 (
str varchar(255) character set utf8 not null,
key str (str(2))
) engine=myisam;
INSERT INTO t1 VALUES ('str');
INSERT INTO t1 VALUES ('str2');
select * from t1 where str='str';
str
str
drop table t1;
create table t1 (
str varchar(255) character set utf8 not null,
key str using btree (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;
......@@ -392,3 +392,28 @@ select c as c_all from t1 order by c;
select c as c_a from t1 where c='a';
select c as c_a from t1 where c='б';
drop table t1;
# Bug#4594: column index make = failed for gbk, but like works
# Check MYISAM
#
create table t1 (
str varchar(255) character set utf8 not null,
key str (str(2))
) engine=myisam;
INSERT INTO t1 VALUES ('str');
INSERT INTO t1 VALUES ('str2');
select * from t1 where str='str';
drop table t1;
# the same for HEAP+BTREE
#
create table t1 (
str varchar(255) character set utf8 not null,
key str using btree (str(2))
) engine=heap;
INSERT INTO t1 VALUES ('str');
INSERT INTO t1 VALUES ('str2');
select * from t1 where str='str';
drop table t1;
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