Bug #2699 UTF8 breaks primary keys for cols > 85 characters

parent a0529097
...@@ -167,3 +167,5 @@ select hex(s1) from t1; ...@@ -167,3 +167,5 @@ select hex(s1) from t1;
hex(s1) hex(s1)
41 41
drop table t1; drop table t1;
create table t1 (a char(160) character set utf8, primary key(a));
ERROR HY000: Incorrect sub part key. The used key part isn't a string, the used length is longer than the key part or the storage engine doesn't support unique sub keys
...@@ -98,3 +98,10 @@ create table t1 (s1 text character set utf8); ...@@ -98,3 +98,10 @@ create table t1 (s1 text character set utf8);
insert into t1 values (0x41FF); insert into t1 values (0x41FF);
select hex(s1) from t1; select hex(s1) from t1;
drop table t1; drop table t1;
#
# Bug 2699
# UTF8 breaks primary keys for cols > 85 characters
#
--error 1089
create table t1 (a char(160) character set utf8, primary key(a));
...@@ -877,7 +877,12 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, ...@@ -877,7 +877,12 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
column->field_name); column->field_name);
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
key_part_info->length=(uint8) length; if (length > file->max_key_part_length())
{
my_error(ER_WRONG_SUB_KEY,MYF(0));
DBUG_RETURN(-1);
}
key_part_info->length=(uint16) length;
/* Use packed keys for long strings on the first column */ /* Use packed keys for long strings on the first column */
if (!(db_options & HA_OPTION_NO_PACK_KEYS) && if (!(db_options & HA_OPTION_NO_PACK_KEYS) &&
(length >= KEY_DEFAULT_PACK_LENGTH && (length >= KEY_DEFAULT_PACK_LENGTH &&
......
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