diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2017-12-08 15:18:39 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2017-12-08 16:00:25 +0200 |
commit | 39450498096a450a98e79bd1bc59d50a0903e1cc (patch) | |
tree | 2b34bf1af16c767a747681698c952a81ff34f736 | |
parent | 094b0f869bfd0f6408d34e6dd96ad3af27983959 (diff) | |
download | mariadb-git-39450498096a450a98e79bd1bc59d50a0903e1cc.tar.gz |
Remove space_name_list_t
fil_get_space_names(): Remove.
fts_drop_orphaned_tables(): Iterate fil_system->space_list directly.
-rw-r--r-- | storage/innobase/fil/fil0fil.cc | 45 | ||||
-rw-r--r-- | storage/innobase/fts/fts0fts.cc | 58 | ||||
-rw-r--r-- | storage/innobase/include/fil0fil.h | 17 |
3 files changed, 19 insertions, 101 deletions
diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index 3b496e3959f..24bdaf2c263 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -6160,51 +6160,6 @@ fil_delete_file( } } -/** -Iterate over all the spaces in the space list and fetch the -tablespace names. It will return a copy of the name that must be -freed by the caller using: delete[]. -@return DB_SUCCESS if all OK. */ -dberr_t -fil_get_space_names( -/*================*/ - space_name_list_t& space_name_list) - /*!< in/out: List to append to */ -{ - fil_space_t* space; - dberr_t err = DB_SUCCESS; - - mutex_enter(&fil_system->mutex); - - for (space = UT_LIST_GET_FIRST(fil_system->space_list); - space != NULL; - space = UT_LIST_GET_NEXT(space_list, space)) { - - if (space->purpose == FIL_TYPE_TABLESPACE) { - ulint len; - char* name; - - len = ::strlen(space->name); - name = UT_NEW_ARRAY_NOKEY(char, len + 1); - - if (name == 0) { - /* Caller to free elements allocated so far. */ - err = DB_OUT_OF_MEMORY; - break; - } - - memcpy(name, space->name, len); - name[len] = 0; - - space_name_list.push_back(name); - } - } - - mutex_exit(&fil_system->mutex); - - return(err); -} - /** Generate redo log for swapping two .ibd files @param[in] old_table old table @param[in] new_table new table diff --git a/storage/innobase/fts/fts0fts.cc b/storage/innobase/fts/fts0fts.cc index 056eee5187a..cfc4b61c441 100644 --- a/storage/innobase/fts/fts0fts.cc +++ b/storage/innobase/fts/fts0fts.cc @@ -6991,15 +6991,6 @@ fts_drop_orphaned_tables(void) que_t* graph; ib_vector_t* tables; ib_alloc_t* heap_alloc; - space_name_list_t space_name_list; - dberr_t error = DB_SUCCESS; - - /* Note: We have to free the memory after we are done with the list. */ - error = fil_get_space_names(space_name_list); - - if (error == DB_OUT_OF_MEMORY) { - ib::fatal() << "Out of memory"; - } heap = mem_heap_create(1024); heap_alloc = ib_heap_allocator_create(heap); @@ -7012,35 +7003,32 @@ fts_drop_orphaned_tables(void) users can't map them back to table names and this will create unnecessary clutter. */ - for (space_name_list_t::iterator it = space_name_list.begin(); - it != space_name_list.end(); - ++it) { - - fts_aux_table_t* fts_aux_table; + mutex_enter(&fil_system->mutex); - fts_aux_table = static_cast<fts_aux_table_t*>( - ib_vector_push(tables, NULL)); + for (fil_space_t* space = UT_LIST_GET_FIRST(fil_system->space_list); + space != NULL; + space = UT_LIST_GET_NEXT(space_list, space)) { - memset(fts_aux_table, 0x0, sizeof(*fts_aux_table)); - - if (!fts_is_aux_table_name(fts_aux_table, *it, strlen(*it))) { - ib_vector_pop(tables); - } else { - ulint len = strlen(*it); - - fts_aux_table->id = fil_space_get_id_by_name(*it); + if (space->purpose != FIL_TYPE_TABLESPACE) { + continue; + } - /* We got this list from fil0fil.cc. The tablespace - with this name must exist. */ - ut_a(fts_aux_table->id != ULINT_UNDEFINED); + fts_aux_table_t fts_aux_table; + memset(&fts_aux_table, 0x0, sizeof fts_aux_table); - fts_aux_table->name = static_cast<char*>( - mem_heap_dup(heap, *it, len + 1)); + size_t len = strlen(space->name); - fts_aux_table->name[len] = 0; + if (!fts_is_aux_table_name(&fts_aux_table, space->name, len)) { + continue; } + + fts_aux_table.id = space->id; + fts_aux_table.name = mem_heap_strdupl(heap, space->name, len); + ib_vector_push(tables, &fts_aux_table); } + mutex_exit(&fil_system->mutex); + trx = trx_allocate_for_background(); trx->op_info = "dropping orphaned FTS tables"; row_mysql_lock_data_dictionary(trx); @@ -7068,7 +7056,7 @@ fts_drop_orphaned_tables(void) "CLOSE c;"); for (;;) { - error = fts_eval_sql(trx, graph); + dberr_t error = fts_eval_sql(trx, graph); if (error == DB_SUCCESS) { fts_check_and_drop_orphaned_tables(trx, tables); @@ -7101,14 +7089,6 @@ fts_drop_orphaned_tables(void) if (heap != NULL) { mem_heap_free(heap); } - - /** Free the memory allocated to store the .ibd names. */ - for (space_name_list_t::iterator it = space_name_list.begin(); - it != space_name_list.end(); - ++it) { - - UT_DELETE_ARRAY(*it); - } } /**********************************************************************//** diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h index 9fa507c2114..1027cf5cbb7 100644 --- a/storage/innobase/include/fil0fil.h +++ b/storage/innobase/include/fil0fil.h @@ -35,16 +35,11 @@ Created 10/25/1995 Heikki Tuuri #include "page0size.h" #include "ibuf0types.h" -#include <list> -#include <vector> - // Forward declaration struct trx_t; class page_id_t; class truncate_t; -typedef std::list<char*, ut_allocator<char*> > space_name_list_t; - /** Structure containing encryption specification */ struct fil_space_crypt_t; @@ -1492,18 +1487,6 @@ ulint fil_space_get_id_by_name( const char* tablespace); -/** -Iterate over all the spaces in the space list and fetch the -tablespace names. It will return a copy of the name that must be -freed by the caller using: delete[]. -@return DB_SUCCESS if all OK. */ -dberr_t -fil_get_space_names( -/*================*/ - space_name_list_t& space_name_list) - /*!< in/out: Vector for collecting the names. */ - MY_ATTRIBUTE((warn_unused_result)); - /** Generate redo log for swapping two .ibd files @param[in] old_table old table @param[in] new_table new table |