Skip to content

Commit 60d2664

Browse files
author
Jimmy Yang
committed
Fix Bug 16869435 - IN-PLACE ALTER TABLE FOR TABLE WITH BROKEN FK CAUSES
ASSERT rb://5653 approaved by Marko
1 parent b87b9c8 commit 60d2664

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

storage/innobase/handler/handler0alter.cc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5273,6 +5273,26 @@ innobase_update_foreign_cache(
52735273
DICT_ERR_IGNORE_NONE,
52745274
fk_tables);
52755275

5276+
if (err == DB_CANNOT_ADD_CONSTRAINT) {
5277+
/* It is possible there are existing foreign key are
5278+
loaded with "foreign_key checks" off,
5279+
so let's retry the loading with charset_check is off */
5280+
err = dict_load_foreigns(user_table->name,
5281+
ctx->col_names, false, false,
5282+
DICT_ERR_IGNORE_NONE,
5283+
fk_tables);
5284+
5285+
/* The load with "charset_check" off is successful, warn
5286+
the user that the foreign key has loaded with mis-matched
5287+
charset */
5288+
if (err == DB_SUCCESS) {
5289+
ib_logf(IB_LOG_LEVEL_WARN,
5290+
"Foreign key constraints for table '%s'"
5291+
" are loaded with charset check off",
5292+
user_table->name);
5293+
}
5294+
}
5295+
52765296
ut_ad(fk_tables.empty());
52775297

52785298
DBUG_RETURN(err);

0 commit comments

Comments
 (0)