Skip to content

Commit f9bad33

Browse files
author
Marko Mäkelä
committed
Bug#24444831 MY_ERROR(ER_INNODB_ONLINE_LOG_TOO_BIG)
CALLED WITH INVALID INDEX NAME This bug was introduced in MySQL 5.6.8 with WL#6255. When an error occurs while rebuilding a table that only has a hidden GEN_CLUST_INDEX inside InnoDB, ha_alter_info->key_info_buffer would be invalid and should not be dereferenced. get_error_key_name(): Get the name of an erroneous key. Avoid dereferencing ha_alter_info->key_info_buffer when no keys exist in the SQL layer. ha_innobase::inplace_alter_table(), ha_innobase::commit_try_rebuild(): Invoke get_error_key_name() for reporting ER_INNODB_ONLINE_LOG_TOO_BIG or ER_INDEX_CORRUPT. RB: 13834 Reviewed-by: Jimmy Yang <[email protected]>
1 parent f2208d8 commit f9bad33

File tree

1 file changed

+29
-14
lines changed

1 file changed

+29
-14
lines changed

storage/innobase/handler/handler0alter.cc

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3886,6 +3886,27 @@ ha_innobase::prepare_inplace_alter_table(
38863886
add_fts_doc_id_idx));
38873887
}
38883888

3889+
/** Get the name of an erroneous key.
3890+
@param[in] error_key_num InnoDB number of the erroneus key
3891+
@param[in] ha_alter_info changes that were being performed
3892+
@param[in] table InnoDB table
3893+
@return the name of the erroneous key */
3894+
static
3895+
const char*
3896+
get_error_key_name(
3897+
ulint error_key_num,
3898+
const Alter_inplace_info* ha_alter_info,
3899+
const dict_table_t* table)
3900+
{
3901+
if (error_key_num == ULINT_UNDEFINED) {
3902+
return(FTS_DOC_ID_INDEX_NAME);
3903+
} else if (ha_alter_info->key_count == 0) {
3904+
return(dict_table_get_first_index(table)->name);
3905+
} else {
3906+
return(ha_alter_info->key_info_buffer[error_key_num].name);
3907+
}
3908+
}
3909+
38893910
/** Alter the table structure in-place with operations
38903911
specified using Alter_inplace_info.
38913912
The level of concurrency allowed during this operation depends
@@ -4003,17 +4024,13 @@ ha_innobase::inplace_alter_table(
40034024
case DB_ONLINE_LOG_TOO_BIG:
40044025
DBUG_ASSERT(ctx->online);
40054026
my_error(ER_INNODB_ONLINE_LOG_TOO_BIG, MYF(0),
4006-
(prebuilt->trx->error_key_num == ULINT_UNDEFINED)
4007-
? FTS_DOC_ID_INDEX_NAME
4008-
: ha_alter_info->key_info_buffer[
4009-
prebuilt->trx->error_key_num].name);
4027+
get_error_key_name(prebuilt->trx->error_key_num,
4028+
ha_alter_info, prebuilt->table));
40104029
break;
40114030
case DB_INDEX_CORRUPT:
40124031
my_error(ER_INDEX_CORRUPT, MYF(0),
4013-
(prebuilt->trx->error_key_num == ULINT_UNDEFINED)
4014-
? FTS_DOC_ID_INDEX_NAME
4015-
: ha_alter_info->key_info_buffer[
4016-
prebuilt->trx->error_key_num].name);
4032+
get_error_key_name(prebuilt->trx->error_key_num,
4033+
ha_alter_info, prebuilt->table));
40174034
break;
40184035
default:
40194036
my_error_innodb(error,
@@ -4823,7 +4840,6 @@ innobase_update_foreign_cache(
48234840
"Foreign key constraints for table '%s'"
48244841
" are loaded with charset check off",
48254842
user_table->name);
4826-
48274843
}
48284844
}
48294845

@@ -4923,14 +4939,13 @@ commit_try_rebuild(
49234939
DBUG_RETURN(true);
49244940
case DB_ONLINE_LOG_TOO_BIG:
49254941
my_error(ER_INNODB_ONLINE_LOG_TOO_BIG, MYF(0),
4926-
ha_alter_info->key_info_buffer[0].name);
4942+
get_error_key_name(err_key, ha_alter_info,
4943+
rebuilt_table));
49274944
DBUG_RETURN(true);
49284945
case DB_INDEX_CORRUPT:
49294946
my_error(ER_INDEX_CORRUPT, MYF(0),
4930-
(err_key == ULINT_UNDEFINED)
4931-
? FTS_DOC_ID_INDEX_NAME
4932-
: ha_alter_info->key_info_buffer[err_key]
4933-
.name);
4947+
get_error_key_name(err_key, ha_alter_info,
4948+
rebuilt_table));
49344949
DBUG_RETURN(true);
49354950
default:
49364951
my_error_innodb(error, table_name, user_table->flags);

0 commit comments

Comments
 (0)