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
This commit is contained in:
parent
e4e1901569
commit
dde1b32d9e
@ -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 */
|
||||
|
Loading…
x
Reference in New Issue
Block a user