List:Commits« Previous MessageNext Message »
From:ramil Date:July 18 2007 9:13am
Subject:bk commit into 5.0 tree (ramil:1.2533) BUG#28125
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of ram. When ram 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@stripped, 2007-07-18 12:13:45+05:00, ramil@stripped +3 -0
  Fix for bug #28125: ERROR 2013 when adding index.
  
  Problem: we may break a multibyte char sequence using a key 
  reduced to maximum allowed length for a storage engine
  (that leads to failed assertion in the innodb code, 
  see also #17530). 
  
  Fix: align truncated key length to multibyte char boundary.

  mysql-test/r/innodb_mysql.result@stripped, 2007-07-18 12:13:44+05:00, ramil@stripped +13 -1
    Fix for bug #28125: ERROR 2013 when adding index.
      - test result.

  mysql-test/t/innodb_mysql.test@stripped, 2007-07-18 12:13:44+05:00, ramil@stripped +9 -0
    Fix for bug #28125: ERROR 2013 when adding index.
      - test case.

  sql/sql_table.cc@stripped, 2007-07-18 12:13:44+05:00, ramil@stripped +4 -2
    Fix for bug #28125: ERROR 2013 when adding index.
      - align truncated key length to multibyte char boundary.
      - display real key length in bytes raising warnings.

diff -Nrup a/mysql-test/r/innodb_mysql.result b/mysql-test/r/innodb_mysql.result
--- a/mysql-test/r/innodb_mysql.result	2007-07-08 00:17:02 +05:00
+++ b/mysql-test/r/innodb_mysql.result	2007-07-18 12:13:44 +05:00
@@ -418,7 +418,7 @@ DROP TABLE t1,t2;
 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
+Warning	1071	Specified key was too long; max key length is 767 bytes
 insert into t1 values('aaa');
 drop table t1;
 CREATE TABLE t1 (a INT PRIMARY KEY, b INT, c FLOAT, KEY b(b)) ENGINE = INNODB;
@@ -735,4 +735,16 @@ COUNT(*)
 3072
 set @@sort_buffer_size=default;
 DROP TABLE t1,t2;
+create table t1(a text) engine=innodb default charset=utf8;
+insert into t1 values('aaa');
+alter table t1 add index(a(1024));
+Warnings:
+Warning	1071	Specified key was too long; max key length is 767 bytes
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` text,
+  KEY `a` (`a`(255))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8
+drop table t1;
 End of 5.0 tests
diff -Nrup a/mysql-test/t/innodb_mysql.test b/mysql-test/t/innodb_mysql.test
--- a/mysql-test/t/innodb_mysql.test	2007-07-08 00:19:29 +05:00
+++ b/mysql-test/t/innodb_mysql.test	2007-07-18 12:13:44 +05:00
@@ -741,4 +741,13 @@ set @@sort_buffer_size=default;
 
 DROP TABLE t1,t2;
 
+#
+# Bug #28125: ERROR 2013 when adding index.
+#
+create table t1(a text) engine=innodb default charset=utf8; 
+insert into t1 values('aaa');
+alter table t1 add index(a(1024));
+show create table t1;
+drop table t1;
+
 --echo End of 5.0 tests
diff -Nrup a/sql/sql_table.cc b/sql/sql_table.cc
--- a/sql/sql_table.cc	2007-06-15 20:46:58 +05:00
+++ b/sql/sql_table.cc	2007-07-18 12:13:44 +05:00
@@ -1357,6 +1357,8 @@ static int mysql_prepare_table(THD *thd,
 			  length);
 	      push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
 			   ER_TOO_LONG_KEY, warn_buff);
+              /* Align key length to multibyte char boundary */
+              length-= length % sql_field->charset->mbmaxlen;
 	    }
 	    else
 	    {
@@ -1387,8 +1389,6 @@ static int mysql_prepare_table(THD *thd,
       if (length > file->max_key_part_length() && key->type !=
Key::FULLTEXT)
       {
         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 */
@@ -1397,6 +1397,8 @@ static int mysql_prepare_table(THD *thd,
 		      length);
 	  push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
 		       ER_TOO_LONG_KEY, warn_buff);
+          /* Align key length to multibyte char boundary */
+          length-= length % sql_field->charset->mbmaxlen;
 	}
 	else
 	{
Thread
bk commit into 5.0 tree (ramil:1.2533) BUG#28125ramil18 Jul