From 6e3a51e06a618ac1d1182a150e3951dca70516d0 Mon Sep 17 00:00:00 2001 From: mmakela Date: Tue, 6 Apr 2010 12:18:47 +0000 Subject: [PATCH] branches/innodb+: Merge revisions 6925:6949 from branches/zip: ------------------------------------------------------------------------ r6949 | mmakela | 2010-04-06 16:11:46 +0300 (Tue, 06 Apr 2010) | 7 lines branches/zip: Add debug checks to track down Issue #461. dict_table_check_for_dup_indexes(): Add the flag tmp_ok. If !tmp_ok, check that no index name starts with TEMP_INDEX_PREFIX. ha_innobase::add_index(), ha_innobase::prepare_drop_index(), ha_innobase::final_drop_index(): Call dict_table_check_for_dup_indexes(). ------------------------------------------------------------------------ --- dict/dict0dict.c | 13 ++++++++----- handler/handler0alter.cc | 14 +++++++++++--- include/dict0dict.h | 5 +++-- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/dict/dict0dict.c b/dict/dict0dict.c index 378c0d0c73c..a58ca2e7802 100644 --- a/dict/dict0dict.c +++ b/dict/dict0dict.c @@ -4781,8 +4781,10 @@ UNIV_INTERN void dict_table_check_for_dup_indexes( /*=============================*/ - const dict_table_t* table) /*!< in: Check for dup indexes + const dict_table_t* table, /*!< in: Check for dup indexes in this table */ + ibool tmp_ok) /*!< in: TRUE=allow temporary + index names */ { /* Check for duplicates, ignoring indexes that are marked as to be dropped */ @@ -4796,9 +4798,11 @@ dict_table_check_for_dup_indexes( ut_a(UT_LIST_GET_LEN(table->indexes) > 0); index1 = UT_LIST_GET_FIRST(table->indexes); - index2 = UT_LIST_GET_NEXT(indexes, index1); - while (index1 && index2) { + do { + ut_ad(tmp_ok || *index1->name != TEMP_INDEX_PREFIX); + + index2 = UT_LIST_GET_NEXT(indexes, index1); while (index2) { @@ -4810,8 +4814,7 @@ dict_table_check_for_dup_indexes( } index1 = UT_LIST_GET_NEXT(indexes, index1); - index2 = UT_LIST_GET_NEXT(indexes, index1); - } + } while (index1); } #endif /* UNIV_DEBUG */ diff --git a/handler/handler0alter.cc b/handler/handler0alter.cc index 071253d2dae..9836fb11ebc 100644 --- a/handler/handler0alter.cc +++ b/handler/handler0alter.cc @@ -722,6 +722,8 @@ err_exit: row_mysql_lock_data_dictionary(trx); dict_locked = TRUE; + ut_d(dict_table_check_for_dup_indexes(innodb_table, FALSE)); + /* If a new primary key is defined for the table we need to drop the original table and rebuild all indexes. */ @@ -754,6 +756,8 @@ err_exit: user_thd); } + ut_d(dict_table_check_for_dup_indexes(innodb_table, + FALSE)); row_mysql_unlock_data_dictionary(trx); goto err_exit; } @@ -828,7 +832,7 @@ error_handling: row_mysql_lock_data_dictionary(trx); dict_locked = TRUE; - ut_d(dict_table_check_for_dup_indexes(prebuilt->table)); + ut_d(dict_table_check_for_dup_indexes(prebuilt->table, TRUE)); if (!new_primary) { error = row_merge_rename_indexes(trx, indexed_table); @@ -916,6 +920,8 @@ convert_error: trx_commit_for_mysql(prebuilt->trx); } + ut_d(dict_table_check_for_dup_indexes(innodb_table, FALSE)); + if (dict_locked) { row_mysql_unlock_data_dictionary(trx); } @@ -959,6 +965,7 @@ ha_innobase::prepare_drop_index( /* Test and mark all the indexes to be dropped */ row_mysql_lock_data_dictionary(trx); + ut_d(dict_table_check_for_dup_indexes(prebuilt->table, FALSE)); /* Check that none of the indexes have previously been flagged for deletion. */ @@ -1124,6 +1131,7 @@ func_exit: } while (index); } + ut_d(dict_table_check_for_dup_indexes(prebuilt->table, FALSE)); row_mysql_unlock_data_dictionary(trx); DBUG_RETURN(err); @@ -1170,6 +1178,7 @@ ha_innobase::final_drop_index( prebuilt->table->flags, user_thd); row_mysql_lock_data_dictionary(trx); + ut_d(dict_table_check_for_dup_indexes(prebuilt->table, FALSE)); if (UNIV_UNLIKELY(err)) { @@ -1210,9 +1219,8 @@ ha_innobase::final_drop_index( valid index entry count in the translation table to zero */ share->idx_trans_tbl.index_count = 0; - ut_d(dict_table_check_for_dup_indexes(prebuilt->table)); - func_exit: + ut_d(dict_table_check_for_dup_indexes(prebuilt->table, FALSE)); trx_commit_for_mysql(trx); trx_commit_for_mysql(prebuilt->trx); row_mysql_unlock_data_dictionary(trx); diff --git a/include/dict0dict.h b/include/dict0dict.h index 12396556c2d..788616d682a 100644 --- a/include/dict0dict.h +++ b/include/dict0dict.h @@ -928,9 +928,10 @@ UNIV_INTERN void dict_table_check_for_dup_indexes( /*=============================*/ - const dict_table_t* table); /*!< in: Check for dup indexes + const dict_table_t* table, /*!< in: Check for dup indexes in this table */ - + ibool tmp_ok);/*!< in: TRUE=allow temporary + index names */ #endif /* UNIV_DEBUG */ /**********************************************************************//** Builds a node pointer out of a physical record and a page number.