Commit 5917c58a authored by Marko Mäkelä's avatar Marko Mäkelä

Bug#14025221 FOREIGN KEY REFERENCES FREED MEMORY AFTER DROP INDEX

dict_table_replace_index_in_foreign_list(): Replace the dropped index
also in the foreign key constraints of child tables that are
referencing this table.

row_ins_check_foreign_constraint(): If the underlying index is
missing, refuse the operation.

rb:1051 approved by Jimmy Yang
parent fcb03305
......@@ -4872,6 +4872,28 @@ dict_table_replace_index_in_foreign_list(
foreign->foreign_index = new_index;
}
}
for (foreign = UT_LIST_GET_FIRST(table->referenced_list);
foreign;
foreign = UT_LIST_GET_NEXT(referenced_list, foreign)) {
dict_index_t* new_index;
if (foreign->referenced_index == index) {
ut_ad(foreign->referenced_table == index->table);
new_index = dict_foreign_find_index(
foreign->referenced_table,
foreign->referenced_col_names,
foreign->n_fields, index,
/*check_charsets=*/TRUE, /*check_null=*/FALSE);
ut_ad(new_index || !trx->check_foreigns);
ut_ad(!new_index || new_index->table == index->table);
foreign->referenced_index = new_index;
}
}
}
/**********************************************************************//**
......
......@@ -1296,7 +1296,8 @@ run_again:
check_index = foreign->foreign_index;
}
if (check_table == NULL || check_table->ibd_file_missing) {
if (check_table == NULL || check_table->ibd_file_missing
|| check_index == NULL) {
if (check_ref) {
FILE* ef = dict_foreign_err_file;
......@@ -1331,9 +1332,6 @@ run_again:
goto exit_func;
}
ut_a(check_table);
ut_a(check_index);
if (check_table != table) {
/* We already have a LOCK_IX on table, but not necessarily
on check_table */
......
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