From b54aae41d5483072f3f6d38d5313c4e6c9b58112 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=A8=E8=B6=85?= Date: Tue, 8 Oct 2024 17:18:10 +0800 Subject: [PATCH] bug#114904 Rename table with COPY does not change the constraint name, the bug reason is alter rename table by ALGORITHM COPY not update child table reference tablename in dict_foreign_t cache, The solution is reset chiild table reference table if refresh_fk is true in dd_table_check_for_child --- storage/innobase/dict/dict0dd.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/storage/innobase/dict/dict0dd.cc b/storage/innobase/dict/dict0dd.cc index 13fada010a32..ae98c17d06f4 100644 --- a/storage/innobase/dict/dict0dd.cc +++ b/storage/innobase/dict/dict0dd.cc @@ -4567,7 +4567,12 @@ dberr_t dd_table_check_for_child(dd::cache::Dictionary_client *client, if (foreign_table) { for (auto &fk : foreign_table->foreign_set) { if (strcmp(fk->referenced_table_name, tbl_name) != 0) { - continue; + if (m_table->refresh_fk) {//after alter rename copy, child fk reference table not update,bug-114904 + fk->referenced_table_name = mem_heap_strdup(fk->heap, tbl_name); + dict_mem_referenced_table_name_lookup_set(fk, true); + } else { + continue; + } } if (fk->referenced_table) {