Skip to content

Commit 55bb279

Browse files
committed
Correctly resolve the conflict around commit_cache_norebuild()
1 parent 69e5522 commit 55bb279

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

mysql-test/suite/innodb/r/foreign_key.result

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,6 @@ ALTER TABLE t1 ADD FOREIGN KEY (f) REFERENCES non_existing_table (x);
233233
SET SESSION FOREIGN_KEY_CHECKS = ON;
234234
ALTER TABLE t1 ADD FULLTEXT INDEX ft1 (f);
235235
Warnings:
236-
Warning 124 InnoDB rebuilding table to add column FTS_DOC_ID
237236
Warning 1088 failed to load FOREIGN KEY constraints
238237
ALTER TABLE t1 ADD FULLTEXT INDEX ft2 (f);
239238
Warnings:

storage/innobase/handler/handler0alter.cc

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9084,9 +9084,10 @@ after a successful commit_try_norebuild() call.
90849084
@param ctx In-place ALTER TABLE context for the current partition
90859085
@param table the TABLE before the ALTER
90869086
@param trx Data dictionary transaction
9087-
(will be started and committed, for DROP INDEX) */
9087+
(will be started and committed, for DROP INDEX)
9088+
@return whether all replacements were found for dropped indexes */
90889089
inline MY_ATTRIBUTE((nonnull))
9089-
void
9090+
bool
90909091
commit_cache_norebuild(
90919092
/*===================*/
90929093
Alter_inplace_info* ha_alter_info,
@@ -9099,6 +9100,8 @@ commit_cache_norebuild(
90999100
DBUG_ASSERT(ctx->new_table->space != fil_system.temp_space);
91009101
DBUG_ASSERT(!ctx->new_table->is_temporary());
91019102

9103+
bool found = true;
9104+
91029105
if (ctx->page_compression_level) {
91039106
DBUG_ASSERT(ctx->new_table->space != fil_system.sys_space);
91049107
ctx->new_table->flags &=
@@ -9201,7 +9204,7 @@ commit_cache_norebuild(
92019204

92029205
if (!dict_foreign_replace_index(
92039206
index->table, ctx->col_names, index)) {
9204-
ut_a(!ctx->prebuilt->trx->check_foreigns);
9207+
found = false;
92059208
}
92069209

92079210
/* Mark the index dropped
@@ -9253,7 +9256,7 @@ commit_cache_norebuild(
92539256
: NULL;
92549257
DBUG_ASSERT((ctx->new_table->fts == NULL)
92559258
== (ctx->new_table->fts_doc_id_index == NULL));
9256-
DBUG_VOID_RETURN;
9259+
DBUG_RETURN(found);
92579260
}
92589261

92599262
/** Adjust the persistent statistics after non-rebuilding ALTER TABLE.
@@ -9868,13 +9871,11 @@ ha_innobase::commit_inplace_alter_table(
98689871
bool fk_fail = innobase_update_foreign_cache(
98699872
ctx, m_user_thd) != DB_SUCCESS;
98709873

9871-
commit_cache_norebuild(ha_alter_info, ctx,
9872-
table, trx);
9873-
innobase_rename_or_enlarge_columns_cache(
9874-
ha_alter_info, table, ctx->new_table);
9875-
#ifdef MYSQL_RENAME_INDEX
9876-
rename_indexes_in_cache(ctx, ha_alter_info);
9877-
#endif
9874+
if (!commit_cache_norebuild(ha_alter_info, ctx, table,
9875+
trx)) {
9876+
fk_fail = true;
9877+
}
9878+
98789879
if (fk_fail && m_prebuilt->trx->check_foreigns) {
98799880
goto foreign_fail;
98809881
}

0 commit comments

Comments
 (0)