MDEV-35962 CREATE INDEX fails to heal a FOREIGN KEY constraint

commit_cache_norebuild(): Replace any newly added indexes in
the attached foreign key constraints.
This commit is contained in:
Marko Mäkelä 2025-01-29 09:04:50 +02:00
commit 3cfffb4de6
3 changed files with 85 additions and 6 deletions

View file

@ -11036,6 +11036,37 @@ commit_cache_norebuild(
dict_index_remove_from_cache(index->table, index);
}
if (ctx->num_to_add_index) {
for (dict_foreign_t* foreign: ctx->new_table->foreign_set) {
if (foreign->foreign_table == ctx->new_table
&& !foreign->foreign_index) {
foreign->foreign_index =
dict_foreign_find_index(
foreign->foreign_table,
nullptr,
foreign->foreign_col_names,
foreign->n_fields, nullptr,
/*check_charsets=*/TRUE,
/*check_null=*/FALSE,
nullptr, nullptr, nullptr);
}
}
for (dict_foreign_t* foreign: ctx->new_table->referenced_set) {
if (foreign->referenced_table == ctx->new_table
&& !foreign->referenced_index) {
foreign->referenced_index =
dict_foreign_find_index(
foreign->referenced_table,
nullptr,
foreign->referenced_col_names,
foreign->n_fields, nullptr,
/*check_charsets=*/TRUE,
/*check_null=*/FALSE,
nullptr, nullptr, nullptr);
}
}
}
fts_clear_all(ctx->old_table);
if (!ctx->is_instant()) {