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

This commit is contained in:
bar@bar.intranet.mysql.r18.ru 2004-02-13 17:58:02 +04:00
parent a052909753
commit 3bdb96d33e
3 changed files with 15 additions and 1 deletions

View File

@ -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

View File

@ -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));

View File

@ -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 &&