Commit d30f17af authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-13818 CREATE INDEX leaks memory if running out of undo log space

if create_index_dict() fails, we need to free ctx->add_index[a] too

This fixes innodb.alter_crash and innodb.instant_alter_debug
failures in ASAN_OPTIONS="abort_on_error=1" runs
parent 2bd204b9
...@@ -5634,18 +5634,19 @@ prepare_inplace_alter_table_dict( ...@@ -5634,18 +5634,19 @@ prepare_inplace_alter_table_dict(
ctx->trx->table_id = user_table->id; ctx->trx->table_id = user_table->id;
for (ulint a = 0; a < ctx->num_to_add_index; a++) { for (ulint a = 0; a < ctx->num_to_add_index; a++) {
dict_index_t*& index = ctx->add_index[a]; dict_index_t* index = ctx->add_index[a];
const bool has_new_v_col = index->has_new_v_col; const bool has_new_v_col = index->has_new_v_col;
index = create_index_dict(ctx->trx, index, add_v); index = create_index_dict(ctx->trx, index, add_v);
if (!index) { if (!index) {
error = ctx->trx->error_state; error = ctx->trx->error_state;
ut_ad(error != DB_SUCCESS); ut_ad(error != DB_SUCCESS);
error_handling_drop_uncached: error_handling_drop_uncached:
while (++a < ctx->num_to_add_index) { do {
dict_mem_index_free(ctx->add_index[a]); dict_mem_index_free(ctx->add_index[a]);
} } while (++a < ctx->num_to_add_index);
goto error_handling; goto error_handling;
} }
ctx->add_index[a]= index;
index->parser = index_defs[a].parser; index->parser = index_defs[a].parser;
index->has_new_v_col = has_new_v_col; index->has_new_v_col = has_new_v_col;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment