diff --git a/mysql-test/include/drop-on-restart.inc b/mysql-test/include/drop-on-restart.inc index 841b636483a..ecdd24ebef1 100644 --- a/mysql-test/include/drop-on-restart.inc +++ b/mysql-test/include/drop-on-restart.inc @@ -23,6 +23,7 @@ drop database if exists db1_secret; drop database if exists db2; drop database if exists federated; drop database if exists mysqldump_test_db; +drop database if exists mysqlslap; drop database if exists mysqltest1; drop database if exists mysqltest2; drop database if exists mysqltest3; @@ -34,6 +35,7 @@ drop database if exists mysqltest_bob; drop database if exists mysqltest_db1; drop database if exists mysqltest_prometheus; drop database if exists mysqltest_sisyfos; +drop database if exists ndbsynctest; drop database if exists ndbtest1; drop database if exists rewrite; drop database if exists test2; diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result index 25ceafd2c69..8228a7d904c 100644 --- a/mysql-test/r/create.result +++ b/mysql-test/r/create.result @@ -770,3 +770,9 @@ t1 CREATE TABLE `t1` ( `i` int(11) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 MAX_ROWS=4294967295 drop table t1; +create table t1(f1 varchar(800) binary not null, key(f1)) engine = innodb +character set utf8 collate utf8_general_ci; +Warnings: +Warning 1071 Specified key was too long; max key length is 765 bytes +insert into t1 values('aaa'); +drop table t1; diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test index d8f23b1e875..c5d1b881896 100644 --- a/mysql-test/t/create.test +++ b/mysql-test/t/create.test @@ -661,4 +661,12 @@ alter table t1 max_rows=100000000000; show create table t1; drop table t1; +# +# Bug#17530: Incorrect key truncation on table creation caused server crash. +# +create table t1(f1 varchar(800) binary not null, key(f1)) engine = innodb + character set utf8 collate utf8_general_ci; +insert into t1 values('aaa'); +drop table t1; + # End of 5.0 tests diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 2737e9448f9..5a4ac7db05e 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1742,7 +1742,9 @@ static int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, } if (length > file->max_key_part_length() && key->type != Key::FULLTEXT) { - length=file->max_key_part_length(); + length= file->max_key_part_length(); + /* Align key length to multibyte char boundary */ + length-= length % sql_field->charset->mbmaxlen; if (key->type == Key::MULTIPLE) { /* not a critical problem */