Commit 65070bef authored by Sergei Golubchik's avatar Sergei Golubchik

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

free already allocated indexes if row_merge_create_index() fails

This fixes innodb.alter_crash failure
in ASAN_OPTIONS="abort_on_error=1" runs
parent 2b4027e6
......@@ -4860,7 +4860,7 @@ prepare_inplace_alter_table_dict(
/* Create the indexes in SYS_INDEXES and load into dictionary. */
for (ulint a = 0; a < ctx->num_to_add_index; a++) {
for (int a = 0; a < ctx->num_to_add_index; a++) {
if (index_defs[a].ind_type & DICT_VIRTUAL
&& ctx->num_to_drop_vcol > 0 && !new_clustered) {
......@@ -4877,6 +4877,9 @@ prepare_inplace_alter_table_dict(
if (!ctx->add_index[a]) {
error = ctx->trx->error_state;
DBUG_ASSERT(error != DB_SUCCESS);
while (--a >= 0) {
dict_mem_index_free(ctx->add_index[a]);
}
goto error_handling;
}
......
......@@ -4418,6 +4418,7 @@ row_merge_create_index(
this index, to ensure read consistency. */
ut_ad(index->trx_id == trx->id);
} else {
dict_mem_index_free(index);
index = NULL;
}
......
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