diff options
-rw-r--r-- | myisam/mi_key.c | 8 | ||||
-rw-r--r-- | mysql-test/r/ctype_utf8.result | 20 | ||||
-rw-r--r-- | mysql-test/t/ctype_utf8.test | 25 |
3 files changed, 49 insertions, 4 deletions
diff --git a/myisam/mi_key.c b/myisam/mi_key.c index 36fe01a27f2..8f5f0e829ef 100644 --- a/myisam/mi_key.c +++ b/myisam/mi_key.c @@ -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) { diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result index 6c6e5114cf8..6a0bd21c551 100644 --- a/mysql-test/r/ctype_utf8.result +++ b/mysql-test/r/ctype_utf8.result @@ -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; diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test index 21880732e47..17b89ba1050 100644 --- a/mysql-test/t/ctype_utf8.test +++ b/mysql-test/t/ctype_utf8.test @@ -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; |