3411
3411
goto funct_exit;
3414
if (table->space && !table->dir_path_of_temp_table) {
3414
if (table->space && !DICT_TF2_FLAG_IS_SET(table, DICT_TF2_TEMPORARY)) {
3415
3415
/* Discard and create the single-table tablespace. */
3416
3416
ulint space = table->space;
3417
3417
ulint flags = fil_space_get_flags(space);
3419
ut_a(!DICT_TF2_FLAG_IS_SET(table, DICT_TF2_TEMPORARY));
3421
3419
dict_get_and_save_data_dir_path(table, true);
3423
3421
if (flags != ULINT_UNDEFINED
4217
4215
is_temp = DICT_TF2_FLAG_IS_SET(table, DICT_TF2_TEMPORARY);
4219
4217
/* If there is a temp path then the temp flag is set.
4220
However, during recovery, we might have a temp flag but
4221
not know the temp path */
4218
However, during recovery or reloading the table object
4219
after eviction from data dictionary cache, we might
4220
have a temp flag but not know the temp path */
4222
4221
ut_a(table->dir_path_of_temp_table == NULL || is_temp);
4223
4222
if (dict_table_is_discarded(table)
4224
4223
|| table->ibd_file_missing) {
5072
5072
if (dict_table_has_fts_index(table)
5073
5073
&& !dict_tables_have_same_db(old_name, new_name)) {
5074
5074
err = fts_rename_aux_tables(table, new_name, trx);
5076
if (err != DB_SUCCESS && (table->space != 0)) {
5077
char* orig_name = table->name;
5078
trx_t* trx_bg = trx_allocate_for_background();
5080
/* If the first fts_rename fails, the trx would
5081
be rolled back and committed, we can't use it any more,
5082
so we have to start a new background trx here. */
5083
ut_a(trx_state_eq(trx, TRX_STATE_NOT_STARTED));
5084
trx_bg->op_info = "Revert the failing rename "
5085
"for fts aux tables";
5086
trx_bg->dict_operation_lock_mode = RW_X_LATCH;
5087
trx_start_for_ddl(trx_bg, TRX_DICT_OP_TABLE);
5089
/* If rename fails and table has its own tablespace,
5090
we need to call fts_rename_aux_tables again to
5091
revert the ibd file rename, which is not under the
5092
control of trx. Also notice the parent table name
5093
in cache is not changed yet. If the reverting fails,
5094
the ibd data may be left in the new database, which
5095
can be fixed only manually. */
5096
table->name = const_cast<char*>(new_name);
5097
fts_rename_aux_tables(table, old_name, trx_bg);
5098
table->name = orig_name;
5100
trx_bg->dict_operation_lock_mode = 0;
5101
trx_commit_for_mysql(trx_bg);
5102
trx_free_for_background(trx_bg);
5075
if (err != DB_TABLE_NOT_FOUND) {
5076
aux_fts_rename = true;
5177
if (aux_fts_rename && err != DB_SUCCESS
5178
&& table != NULL && (table->space != 0)) {
5180
char* orig_name = table->name;
5181
trx_t* trx_bg = trx_allocate_for_background();
5183
/* If the first fts_rename fails, the trx would
5184
be rolled back and committed, we can't use it any more,
5185
so we have to start a new background trx here. */
5186
ut_a(trx_state_eq(trx_bg, TRX_STATE_NOT_STARTED));
5187
trx_bg->op_info = "Revert the failing rename "
5188
"for fts aux tables";
5189
trx_bg->dict_operation_lock_mode = RW_X_LATCH;
5190
trx_start_for_ddl(trx_bg, TRX_DICT_OP_TABLE);
5192
/* If rename fails and table has its own tablespace,
5193
we need to call fts_rename_aux_tables again to
5194
revert the ibd file rename, which is not under the
5195
control of trx. Also notice the parent table name
5196
in cache is not changed yet. If the reverting fails,
5197
the ibd data may be left in the new database, which
5198
can be fixed only manually. */
5199
table->name = const_cast<char*>(new_name);
5200
fts_rename_aux_tables(table, old_name, trx_bg);
5201
table->name = orig_name;
5203
trx_bg->dict_operation_lock_mode = 0;
5204
trx_commit_for_mysql(trx_bg);
5205
trx_free_for_background(trx_bg);
5203
5208
if (table != NULL) {
5204
5209
dict_table_close(table, dict_locked, FALSE);