From: Date: February 21 2006 4:09pm Subject: bk commit into 5.0 tree (evgen:1.2066) BUG#17530 List-Archive: http://lists.mysql.com/commits/2979 X-Bug: 17530 Message-Id: <20060221150937.4FD4D22E9BB@moonbone.moonbone.local> Below is the list of changes that have just been committed into a local 5.0 repository of evgen. When evgen does a push these changes will be propagated to the main repository and, within 24 hours after the push, to the public repository. For information on how to access the public repository see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html ChangeSet 1.2066 06/02/21 18:09:32 evgen@stripped +3 -0 Fixed bug#17530: Incorrect key truncation on table creation caused server crash. When a too long field is used for a key, only a prefix part of the field is used. Length is reduced to the max key length allowed for storage. But if the field have a multibyte charset it is possible to break multibyte char sequence. This leads to the failed assertion in the innodb code and server crash when a record is inserted. The make_prepare_table() now aligns truncated key length to the boundary of multibyte char. sql/sql_table.cc 1.297 06/02/21 18:05:16 evgen@stripped +3 -1 Fixed bug#17530: Incorrect key truncation on table creation caused server crash. The make_prepare_table() now aligns truncated key length to the boundary of multibyte char. mysql-test/r/create.result 1.113 06/02/21 18:05:03 evgen@stripped +6 -0 Added test case for bug#17530: Incorrect key truncation on table creation caused server crash. mysql-test/t/create.test 1.75 06/02/21 18:04:40 evgen@stripped +8 -0 Added test case for bug#17530: Incorrect key truncation on table creation caused server crash. # This is a BitKeeper patch. What follows are the unified diffs for the # set of deltas contained in the patch. The rest of the patch, the part # that BitKeeper cares about, is below these diffs. # User: evgen # Host: moonbone.local # Root: /work/17530-bug-5.0-mysql --- 1.296/sql/sql_table.cc 2006-02-17 09:56:47 +03:00 +++ 1.297/sql/sql_table.cc 2006-02-21 18:05:16 +03:00 @@ -1299,7 +1299,9 @@ } 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 */ --- 1.112/mysql-test/r/create.result 2006-01-17 11:44:13 +03:00 +++ 1.113/mysql-test/r/create.result 2006-02-21 18:05:03 +03:00 @@ -765,3 +765,9 @@ `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; --- 1.74/mysql-test/t/create.test 2006-01-17 11:44:13 +03:00 +++ 1.75/mysql-test/t/create.test 2006-02-21 18:04:40 +03:00 @@ -660,4 +660,12 @@ 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