~ubuntu-branches/ubuntu/wily/mysql-5.6/wily

« back to all changes in this revision

Viewing changes to storage/innobase/row/row0mysql.cc

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2015-04-16 20:07:10 UTC
  • mto: (1.3.9 vivid-proposed)
  • mto: This revision was merged to the branch mainline in revision 11.
  • Revision ID: package-import@ubuntu.com-20150416200710-pcrsa022082zj46k
Tags: upstream-5.6.24
ImportĀ upstreamĀ versionĀ 5.6.24

Show diffs side-by-side

added added

removed removed

Lines of Context:
3411
3411
                goto funct_exit;
3412
3412
        }
3413
3413
 
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);
3418
3418
 
3419
 
                ut_a(!DICT_TF2_FLAG_IS_SET(table, DICT_TF2_TEMPORARY));
3420
 
 
3421
3419
                dict_get_and_save_data_dir_path(table, true);
3422
3420
 
3423
3421
                if (flags != ULINT_UNDEFINED
4217
4215
                is_temp = DICT_TF2_FLAG_IS_SET(table, DICT_TF2_TEMPORARY);
4218
4216
 
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) {
4786
4785
        ibool           old_is_tmp, new_is_tmp;
4787
4786
        pars_info_t*    info                    = NULL;
4788
4787
        int             retry;
 
4788
        bool            aux_fts_rename          = false;
4789
4789
 
4790
4790
        ut_a(old_name != NULL);
4791
4791
        ut_a(new_name != NULL);
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);
5075
 
 
5076
 
                if (err != DB_SUCCESS && (table->space != 0)) {
5077
 
                        char*   orig_name = table->name;
5078
 
                        trx_t*  trx_bg = trx_allocate_for_background();
5079
 
 
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);
5088
 
 
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;
5099
 
 
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;
5103
5077
                }
5104
5078
        }
5105
5079
 
5200
5174
        }
5201
5175
 
5202
5176
funct_exit:
 
5177
        if (aux_fts_rename && err != DB_SUCCESS
 
5178
            && table != NULL && (table->space != 0)) {
 
5179
 
 
5180
                char*   orig_name = table->name;
 
5181
                trx_t*  trx_bg = trx_allocate_for_background();
 
5182
 
 
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);
 
5191
 
 
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;
 
5202
 
 
5203
                trx_bg->dict_operation_lock_mode = 0;
 
5204
                trx_commit_for_mysql(trx_bg);
 
5205
                trx_free_for_background(trx_bg);
 
5206
        }
 
5207
 
5203
5208
        if (table != NULL) {
5204
5209
                dict_table_close(table, dict_locked, FALSE);
5205
5210
        }