Commit da60f197 authored by unknown's avatar unknown

ctype_utf8.result, ctype_utf8.test, mi_key.c:

  bug 4521: unique key prefix interacts poorly with utf8: fixed length key fix.


myisam/mi_key.c:
  bug 4521: unique key prefix interacts poorly with utf8: fixed length key fix.
mysql-test/t/ctype_utf8.test:
  bug 4521: unique key prefix interacts poorly with utf8: fixed length key fix.
mysql-test/r/ctype_utf8.result:
  bug 4521: unique key prefix interacts poorly with utf8: fixed length key fix.
parent 16987e1c
......@@ -168,13 +168,18 @@ uint _mi_make_key(register MI_INFO *info, uint keynr, uchar *key,
}
continue;
}
#ifdef NOT_YET_FIXED_LENGTH_KEY
if (char_length && length > char_length)
{
char_length= my_charpos(cs, pos, pos+length, char_length);
set_if_smaller(length, char_length);
if (char_length < length)
{
uint diff= length - char_length;
memcpy((byte*) key, pos, char_length);
cs->cset->fill(cs, key + char_length, diff, ' ');
key+= length;
continue;
}
}
#endif
memcpy((byte*) key, pos, length);
key+= length;
}
......
......@@ -276,3 +276,26 @@ select c cb20 from t1 where c=repeat('b',20);
cb20
bbbbbbbbbbbbbbbbbbbb
drop table t1;
create table t1 (c char(3) character set utf8, unique (c(2)));
insert into t1 values ('1'),('2'),('3'),('4'),('x'),('y'),('z');
insert into t1 values ('a');
insert into t1 values ('aa');
insert into t1 values ('aaa');
ERROR 23000: Duplicate entry 'aaa' for key 1
insert into t1 values ('b');
insert into t1 values ('bb');
insert into t1 values ('bbb');
ERROR 23000: Duplicate entry 'bbb' for key 1
insert into t1 values ('а');
insert into t1 values ('аа');
insert into t1 values ('ааа');
ERROR 23000: Duplicate entry 'ааа' for key 1
insert into t1 values ('б');
insert into t1 values ('бб');
insert into t1 values ('ббб');
ERROR 23000: Duplicate entry 'ббб' for key 1
insert into t1 values ('ꪪ');
insert into t1 values ('ꪪꪪ');
insert into t1 values ('ꪪꪪꪪ');
ERROR 23000: Duplicate entry 'ꪪꪪ' for key 1
drop table t1;
......@@ -187,3 +187,30 @@ select c cz from t1 where c='z';
select c ca10 from t1 where c='aaaaaaaaaa';
select c cb20 from t1 where c=repeat('b',20);
drop table t1;
#
# Bug 4521: unique key prefix interacts poorly with utf8
# Check fixed length keys
create table t1 (c char(3) character set utf8, unique (c(2)));
insert into t1 values ('1'),('2'),('3'),('4'),('x'),('y'),('z');
insert into t1 values ('a');
insert into t1 values ('aa');
--error 1062
insert into t1 values ('aaa');
insert into t1 values ('b');
insert into t1 values ('bb');
--error 1062
insert into t1 values ('bbb');
insert into t1 values ('а');
insert into t1 values ('аа');
--error 1062
insert into t1 values ('ааа');
insert into t1 values ('б');
insert into t1 values ('бб');
--error 1062
insert into t1 values ('ббб');
insert into t1 values ('ꪪ');
insert into t1 values ('ꪪꪪ');
--error 1062
insert into t1 values ('ꪪꪪꪪ');
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