mirror of
https://github.com/MariaDB/server.git
synced 2025-12-24 11:21:21 +03:00
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: Fix for bug #28125: ERROR 2013 when adding index. - test result. mysql-test/t/innodb_mysql.test: Fix for bug #28125: ERROR 2013 when adding index. - test case. sql/sql_table.cc: 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.
This commit is contained in:
@@ -1357,6 +1357,8 @@ static int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
|
||||
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, HA_CREATE_INFO *create_info,
|
||||
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, HA_CREATE_INFO *create_info,
|
||||
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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user