summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2019-05-17 14:32:53 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2019-05-17 14:32:53 +0300
commit5fd7502e7797ecc9e9c5b5dbe35874c18839440c (patch)
tree4aa4e0116e5ac7566e636507916f62dffcdc0b01
parentd682dc2e709c22bdd6012295b55d3908fe6c546d (diff)
downloadmariadb-git-5fd7502e7797ecc9e9c5b5dbe35874c18839440c.tar.gz
MDEV-19513: Allocate dict_sys statically
dict_sys_t::create(): Renamed from dict_init(). dict_sys_t::close(): Renamed from dict_close(). dict_sys_t::add(): Sliced from dict_table_t::add_to_cache(). dict_sys_t::remove(): Renamed from dict_table_remove_from_cache(). dict_sys_t::prevent_eviction(): Renamed from dict_table_move_from_lru_to_non_lru(). dict_sys_t::acquire(): Replaces dict_move_to_mru() and some more logic. dict_sys_t::resize(): Renamed from dict_resize(). dict_sys_t::find(): Replaces dict_lru_find_table() and dict_non_lru_find_table().
-rw-r--r--storage/innobase/btr/btr0scrub.cc12
-rw-r--r--storage/innobase/btr/btr0sea.cc20
-rw-r--r--storage/innobase/buf/buf0buf.cc3
-rw-r--r--storage/innobase/dict/dict0boot.cc28
-rw-r--r--storage/innobase/dict/dict0crea.cc84
-rw-r--r--storage/innobase/dict/dict0defrag_bg.cc16
-rw-r--r--storage/innobase/dict/dict0dict.cc596
-rw-r--r--storage/innobase/dict/dict0load.cc60
-rw-r--r--storage/innobase/dict/dict0stats.cc70
-rw-r--r--storage/innobase/dict/dict0stats_bg.cc22
-rw-r--r--storage/innobase/fil/fil0fil.cc2
-rw-r--r--storage/innobase/fts/fts0config.cc4
-rw-r--r--storage/innobase/fts/fts0fts.cc18
-rw-r--r--storage/innobase/fts/fts0opt.cc12
-rw-r--r--storage/innobase/fts/fts0sql.cc8
-rw-r--r--storage/innobase/handler/ha_innodb.cc52
-rw-r--r--storage/innobase/handler/handler0alter.cc62
-rw-r--r--storage/innobase/handler/i_s.cc106
-rw-r--r--storage/innobase/include/btr0sea.h2
-rw-r--r--storage/innobase/include/dict0boot.ic8
-rw-r--r--storage/innobase/include/dict0dict.h157
-rw-r--r--storage/innobase/include/dict0dict.ic21
-rw-r--r--storage/innobase/include/dict0load.h2
-rw-r--r--storage/innobase/include/dict0mem.h6
-rw-r--r--storage/innobase/include/dict0priv.ic6
-rw-r--r--storage/innobase/include/dict0stats.ic4
-rw-r--r--storage/innobase/include/dict0stats_bg.h4
-rw-r--r--storage/innobase/include/dict0types.h3
-rw-r--r--storage/innobase/include/fts0fts.h8
-rw-r--r--storage/innobase/include/log0log.ic2
-rw-r--r--storage/innobase/include/que0que.h6
-rw-r--r--storage/innobase/pars/pars0pars.cc2
-rw-r--r--storage/innobase/pars/pars0sym.cc2
-rw-r--r--storage/innobase/que/que0que.cc14
-rw-r--r--storage/innobase/row/row0import.cc12
-rw-r--r--storage/innobase/row/row0ins.cc4
-rw-r--r--storage/innobase/row/row0merge.cc12
-rw-r--r--storage/innobase/row/row0mysql.cc20
-rw-r--r--storage/innobase/row/row0uins.cc14
-rw-r--r--storage/innobase/row/row0umod.cc14
-rw-r--r--storage/innobase/srv/srv0start.cc36
-rw-r--r--storage/innobase/trx/trx0trx.cc8
42 files changed, 660 insertions, 882 deletions
diff --git a/storage/innobase/btr/btr0scrub.cc b/storage/innobase/btr/btr0scrub.cc
index a4ae24b8946..67c06016c72 100644
--- a/storage/innobase/btr/btr0scrub.cc
+++ b/storage/innobase/btr/btr0scrub.cc
@@ -1,5 +1,5 @@
// Copyright (c) 2014, Google Inc.
-// Copyright (c) 2017, MariaDB Corporation.
+// Copyright (c) 2017, 2019, MariaDB Corporation.
/**************************************************//**
@file btr/btr0scrub.cc
@@ -119,13 +119,13 @@ btr_scrub_lock_dict_func(ulint space_id, bool lock_to_close_table,
time_t last = start;
/* FIXME: this is not the proper way of doing things. The
- dict_sys->mutex should not be held by any thread for longer
+ dict_sys.mutex should not be held by any thread for longer
than a few microseconds. It must not be held during I/O,
for example. So, what is the purpose for this busy-waiting?
This function should be rewritten as part of MDEV-8139:
Fix scrubbing tests. */
- while (mutex_enter_nowait(&(dict_sys->mutex))) {
+ while (mutex_enter_nowait(&dict_sys.mutex)) {
/* if we lock to close a table, we wait forever
* if we don't lock to close a table, we check if space
* is closing, and then instead give up
@@ -157,7 +157,7 @@ btr_scrub_lock_dict_func(ulint space_id, bool lock_to_close_table,
}
}
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
return true;
}
@@ -204,10 +204,10 @@ btr_scrub_table_close_for_thread(
/* If tablespace is not marked as stopping perform
the actual close. */
if (!space->is_stopping()) {
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
/* perform the actual closing */
btr_scrub_table_close(scrub_data->current_table);
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
}
space->release();
}
diff --git a/storage/innobase/btr/btr0sea.cc b/storage/innobase/btr/btr0sea.cc
index ca350d02316..f595065c50c 100644
--- a/storage/innobase/btr/btr0sea.cc
+++ b/storage/innobase/btr/btr0sea.cc
@@ -342,7 +342,7 @@ btr_search_disable_ref_count(
{
dict_index_t* index;
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
for (index = dict_table_get_first_index(table);
index != NULL;
@@ -352,21 +352,21 @@ btr_search_disable_ref_count(
}
/** Disable the adaptive hash search system and empty the index.
-@param[in] need_mutex need to acquire dict_sys->mutex */
+@param[in] need_mutex need to acquire dict_sys.mutex */
void btr_search_disable(bool need_mutex)
{
dict_table_t* table;
if (need_mutex) {
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
}
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
btr_search_x_lock_all();
if (!btr_search_enabled) {
if (need_mutex) {
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
}
btr_search_x_unlock_all();
@@ -377,20 +377,20 @@ void btr_search_disable(bool need_mutex)
/* Clear the index->search_info->ref_count of every index in
the data dictionary cache. */
- for (table = UT_LIST_GET_FIRST(dict_sys->table_LRU); table;
+ for (table = UT_LIST_GET_FIRST(dict_sys.table_LRU); table;
table = UT_LIST_GET_NEXT(table_LRU, table)) {
btr_search_disable_ref_count(table);
}
- for (table = UT_LIST_GET_FIRST(dict_sys->table_non_LRU); table;
+ for (table = UT_LIST_GET_FIRST(dict_sys.table_non_LRU); table;
table = UT_LIST_GET_NEXT(table_LRU, table)) {
btr_search_disable_ref_count(table);
}
if (need_mutex) {
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
}
/* Set all block->index = NULL. */
@@ -1113,7 +1113,7 @@ retry:
ut_ad(page_is_leaf(block->frame));
/* We must not dereference index here, because it could be freed
- if (index->table->n_ref_count == 0 && !mutex_own(&dict_sys->mutex)).
+ if (index->table->n_ref_count == 0 && !mutex_own(&dict_sys.mutex)).
Determine the ahi_slot based on the block contents. */
const index_id_t index_id
@@ -1305,7 +1305,7 @@ void btr_search_drop_page_hash_when_freed(const page_id_t page_id)
be open, or we should be in the process of
dropping the table (preventing eviction). */
ut_ad(index->table->get_ref_count() > 0
- || mutex_own(&dict_sys->mutex));
+ || mutex_own(&dict_sys.mutex));
btr_search_drop_page_hash_index(block);
}
}
diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc
index 37dd04f0d8e..d4845c7a8b4 100644
--- a/storage/innobase/buf/buf0buf.cc
+++ b/storage/innobase/buf/buf0buf.cc
@@ -3089,8 +3089,7 @@ calc_buf_pool_size:
btr_search_sys_resize(
buf_pool_get_curr_size() / sizeof(void*) / 64);
- /* normalize dict_sys */
- dict_resize();
+ dict_sys.resize();
ib::info() << "Resized hash tables at lock_sys,"
#ifdef BTR_CUR_HASH_ADAPT
diff --git a/storage/innobase/dict/dict0boot.cc b/storage/innobase/dict/dict0boot.cc
index 2a80def7335..9b6259decc3 100644
--- a/storage/innobase/dict/dict0boot.cc
+++ b/storage/innobase/dict/dict0boot.cc
@@ -111,9 +111,9 @@ dict_hdr_flush_row_id(void)
row_id_t id;
mtr_t mtr;
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
- id = dict_sys->row_id;
+ id = dict_sys.row_id;
mtr_start(&mtr);
@@ -266,11 +266,11 @@ dict_boot(void)
mtr_start(&mtr);
/* Create the hash tables etc. */
- dict_init();
+ dict_sys.create();
heap = mem_heap_create(450);
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
/* Get the dictionary header */
dict_hdr = dict_hdr_get(&mtr);
@@ -285,7 +285,7 @@ dict_boot(void)
..._MARGIN, it will immediately be updated to the disk-based
header. */
- dict_sys->row_id = DICT_HDR_ROW_ID_WRITE_MARGIN
+ dict_sys.row_id = DICT_HDR_ROW_ID_WRITE_MARGIN
+ ut_uint64_align_up(mach_read_from_8(dict_hdr + DICT_HDR_ROW_ID),
DICT_HDR_ROW_ID_WRITE_MARGIN);
@@ -314,7 +314,7 @@ dict_boot(void)
dict_table_add_system_columns(table, heap);
table->add_to_cache();
- dict_sys->sys_tables = table;
+ dict_sys.sys_tables = table;
mem_heap_empty(heap);
index = dict_mem_index_create(table, "CLUST_IND",
@@ -355,7 +355,7 @@ dict_boot(void)
dict_table_add_system_columns(table, heap);
table->add_to_cache();
- dict_sys->sys_columns = table;
+ dict_sys.sys_columns = table;
mem_heap_empty(heap);
index = dict_mem_index_create(table, "CLUST_IND",
@@ -398,7 +398,7 @@ dict_boot(void)
dict_table_get_nth_col(table, DICT_COL__SYS_INDEXES__MERGE_THRESHOLD)
->def_val.len = UNIV_SQL_NULL;
table->add_to_cache();
- dict_sys->sys_indexes = table;
+ dict_sys.sys_indexes = table;
mem_heap_empty(heap);
index = dict_mem_index_create(table, "CLUST_IND",
@@ -427,7 +427,7 @@ dict_boot(void)
dict_table_add_system_columns(table, heap);
table->add_to_cache();
- dict_sys->sys_fields = table;
+ dict_sys.sys_fields = table;
mem_heap_free(heap);
index = dict_mem_index_create(table, "CLUST_IND",
@@ -475,14 +475,14 @@ dict_boot(void)
if (err == DB_SUCCESS) {
/* Load definitions of other indexes on system tables */
- dict_load_sys_table(dict_sys->sys_tables);
- dict_load_sys_table(dict_sys->sys_columns);
- dict_load_sys_table(dict_sys->sys_indexes);
- dict_load_sys_table(dict_sys->sys_fields);
+ dict_load_sys_table(dict_sys.sys_tables);
+ dict_load_sys_table(dict_sys.sys_columns);
+ dict_load_sys_table(dict_sys.sys_indexes);
+ dict_load_sys_table(dict_sys.sys_fields);
}
}
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
return(err);
}
diff --git a/storage/innobase/dict/dict0crea.cc b/storage/innobase/dict/dict0crea.cc
index d8b9bcdaf39..59572fd11dd 100644
--- a/storage/innobase/dict/dict0crea.cc
+++ b/storage/innobase/dict/dict0crea.cc
@@ -56,7 +56,6 @@ dict_create_sys_tables_tuple(
which the memory for the built
tuple is allocated */
{
- dict_table_t* sys_tables;
dtuple_t* entry;
dfield_t* dfield;
byte* ptr;
@@ -67,11 +66,9 @@ dict_create_sys_tables_tuple(
ut_ad(heap);
ut_ad(table->n_cols >= DATA_N_SYS_COLS);
- sys_tables = dict_sys->sys_tables;
-
entry = dtuple_create(heap, 8 + DATA_N_SYS_COLS);
- dict_table_copy_types(entry, sys_tables);
+ dict_table_copy_types(entry, dict_sys.sys_tables);
/* 0: NAME -----------------------------*/
dfield = dtuple_get_nth_field(
@@ -169,7 +166,6 @@ dict_create_sys_columns_tuple(
which the memory for the built
tuple is allocated */
{
- dict_table_t* sys_columns;
dtuple_t* entry;
const dict_col_t* column;
dfield_t* dfield;
@@ -193,11 +189,9 @@ dict_create_sys_columns_tuple(
ut_ad(!column->is_virtual());
}
- sys_columns = dict_sys->sys_columns;
-
entry = dtuple_create(heap, 7 + DATA_N_SYS_COLS);
- dict_table_copy_types(entry, sys_columns);
+ dict_table_copy_types(entry, dict_sys.sys_columns);
/* 0: TABLE_ID -----------------------*/
dfield = dtuple_get_nth_field(entry, DICT_COL__SYS_COLUMNS__TABLE_ID);
@@ -288,7 +282,6 @@ dict_create_sys_virtual_tuple(
ulint b_col_n,
mem_heap_t* heap)
{
- dict_table_t* sys_virtual;
dtuple_t* entry;
const dict_col_t* base_column;
dfield_t* dfield;
@@ -301,12 +294,10 @@ dict_create_sys_virtual_tuple(
dict_v_col_t* v_col = dict_table_get_nth_v_col(table, v_col_n);
base_column = v_col->base_col[b_col_n];
- sys_virtual = dict_sys->sys_virtual;
-
entry = dtuple_create(heap, DICT_NUM_COLS__SYS_VIRTUAL
+ DATA_N_SYS_COLS);
- dict_table_copy_types(entry, sys_virtual);
+ dict_table_copy_types(entry, dict_sys.sys_virtual);
/* 0: TABLE_ID -----------------------*/
dfield = dtuple_get_nth_field(entry, DICT_COL__SYS_VIRTUAL__TABLE_ID);
@@ -350,7 +341,7 @@ dict_build_table_def_step(
que_thr_t* thr, /*!< in: query thread */
tab_node_t* node) /*!< in: table create node */
{
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
dict_table_t* table = node->table;
trx_t* trx = thr_get_trx(thr);
ut_ad(!table->is_temporary());
@@ -484,24 +475,21 @@ dict_create_sys_indexes_tuple(
which the memory for the built
tuple is allocated */
{
- dict_table_t* sys_indexes;
dtuple_t* entry;
dfield_t* dfield;
byte* ptr;
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
ut_ad(index);
ut_ad(index->table->space || index->table->file_unreadable);
ut_ad(!index->table->space
|| index->table->space->id == index->table->space_id);
ut_ad(heap);
- sys_indexes = dict_sys->sys_indexes;
-
entry = dtuple_create(
heap, DICT_NUM_COLS__SYS_INDEXES + DATA_N_SYS_COLS);
- dict_table_copy_types(entry, sys_indexes);
+ dict_table_copy_types(entry, dict_sys.sys_indexes);
/* 0: TABLE_ID -----------------------*/
dfield = dtuple_get_nth_field(
@@ -605,7 +593,6 @@ dict_create_sys_fields_tuple(
which the memory for the built
tuple is allocated */
{
- dict_table_t* sys_fields;
dtuple_t* entry;
dict_field_t* field;
dfield_t* dfield;
@@ -625,11 +612,9 @@ dict_create_sys_fields_tuple(
field = dict_index_get_nth_field(index, fld_no);
- sys_fields = dict_sys->sys_fields;
-
entry = dtuple_create(heap, 3 + DATA_N_SYS_COLS);
- dict_table_copy_types(entry, sys_fields);
+ dict_table_copy_types(entry, dict_sys.sys_fields);
/* 0: INDEX_ID -----------------------*/
dfield = dtuple_get_nth_field(entry, DICT_COL__SYS_FIELDS__INDEX_ID);
@@ -724,7 +709,7 @@ dict_build_index_def_step(
dtuple_t* row;
trx_t* trx;
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
trx = thr_get_trx(thr);
@@ -775,7 +760,7 @@ dict_build_index_def(
dict_index_t* index, /*!< in/out: index */
trx_t* trx) /*!< in/out: InnoDB transaction handle */
{
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
if (trx->table_id == 0) {
/* Record only the first table id. */
@@ -821,15 +806,12 @@ dict_create_index_tree_step(
mtr_t mtr;
btr_pcur_t pcur;
dict_index_t* index;
- dict_table_t* sys_indexes;
dtuple_t* search_tuple;
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
index = node->index;
- sys_indexes = dict_sys->sys_indexes;
-
if (index->type == DICT_FTS) {
/* FTS index does not need an index tree */
return(DB_SUCCESS);
@@ -843,7 +825,7 @@ dict_create_index_tree_step(
search_tuple = dict_create_search_tuple(node->ind_row, node->heap);
- btr_pcur_open(UT_LIST_GET_FIRST(sys_indexes->indexes),
+ btr_pcur_open(UT_LIST_GET_FIRST(dict_sys.sys_indexes->indexes),
search_tuple, PAGE_CUR_L, BTR_MODIFY_LEAF,
&pcur, &mtr);
@@ -893,7 +875,7 @@ dict_create_index_tree_in_mem(
{
mtr_t mtr;
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
ut_ad(!(index->type & DICT_FTS));
mtr_start(&mtr);
@@ -929,8 +911,8 @@ dict_drop_index_tree(
ulint space;
ulint root_page_no;
- ut_ad(mutex_own(&dict_sys->mutex));
- ut_a(!dict_table_is_comp(dict_sys->sys_indexes));
+ ut_ad(mutex_own(&dict_sys.mutex));
+ ut_a(!dict_table_is_comp(dict_sys.sys_indexes));
ptr = rec_get_nth_field_old(rec, DICT_FLD__SYS_INDEXES__PAGE_NO, &len);
@@ -990,8 +972,8 @@ dict_recreate_index_tree(
mtr_t* mtr) /*!< in/out: mtr having the latch
on the record page. */
{
- ut_ad(mutex_own(&dict_sys->mutex));
- ut_a(!dict_table_is_comp(dict_sys->sys_indexes));
+ ut_ad(mutex_own(&dict_sys.mutex));
+ ut_a(!dict_table_is_comp(dict_sys.sys_indexes));
ut_ad(!table->space || table->space->id == table->space_id);
ulint len;
@@ -1082,15 +1064,15 @@ tab_create_graph_create(
node->mode = mode;
node->key_id = key_id;
- node->tab_def = ins_node_create(INS_DIRECT, dict_sys->sys_tables,
+ node->tab_def = ins_node_create(INS_DIRECT, dict_sys.sys_tables,
heap);
node->tab_def->common.parent = node;
- node->col_def = ins_node_create(INS_DIRECT, dict_sys->sys_columns,
+ node->col_def = ins_node_create(INS_DIRECT, dict_sys.sys_columns,
heap);
node->col_def->common.parent = node;
- node->v_col_def = ins_node_create(INS_DIRECT, dict_sys->sys_virtual,
+ node->v_col_def = ins_node_create(INS_DIRECT, dict_sys.sys_virtual,
heap);
node->v_col_def->common.parent = node;
@@ -1129,11 +1111,11 @@ ind_create_graph_create(
node->heap = mem_heap_create(256);
node->ind_def = ins_node_create(INS_DIRECT,
- dict_sys->sys_indexes, heap);
+ dict_sys.sys_indexes, heap);
node->ind_def->common.parent = node;
node->field_def = ins_node_create(INS_DIRECT,
- dict_sys->sys_fields, heap);
+ dict_sys.sys_fields, heap);
node->field_def->common.parent = node;
return(node);
@@ -1152,7 +1134,7 @@ dict_create_table_step(
trx_t* trx;
ut_ad(thr);
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
trx = thr_get_trx(thr);
@@ -1294,7 +1276,7 @@ dict_create_index_step(
trx_t* trx;
ut_ad(thr);
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
trx = thr_get_trx(thr);
@@ -1453,7 +1435,7 @@ dict_check_if_system_table_exists(
ut_a(srv_get_active_thread_type() == SRV_NONE);
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
sys_table = dict_table_get_low(tablename);
@@ -1471,7 +1453,7 @@ dict_check_if_system_table_exists(
dict_table_prevent_eviction(sys_table);
}
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
return(error);
}
@@ -1640,9 +1622,9 @@ dict_create_or_check_sys_virtual()
"SYS_VIRTUAL", DICT_NUM_FIELDS__SYS_VIRTUAL + 1, 1);
if (err == DB_SUCCESS) {
- mutex_enter(&dict_sys->mutex);
- dict_sys->sys_virtual = dict_table_get_low("SYS_VIRTUAL");
- mutex_exit(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
+ dict_sys.sys_virtual = dict_table_get_low("SYS_VIRTUAL");
+ mutex_exit(&dict_sys.mutex);
return(DB_SUCCESS);
}
@@ -1716,9 +1698,9 @@ dict_create_or_check_sys_virtual()
dberr_t sys_virtual_err = dict_check_if_system_table_exists(
"SYS_VIRTUAL", DICT_NUM_FIELDS__SYS_VIRTUAL + 1, 1);
ut_a(sys_virtual_err == DB_SUCCESS);
- mutex_enter(&dict_sys->mutex);
- dict_sys->sys_virtual = dict_table_get_low("SYS_VIRTUAL");
- mutex_exit(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
+ dict_sys.sys_virtual = dict_table_get_low("SYS_VIRTUAL");
+ mutex_exit(&dict_sys.mutex);
return(err);
}
@@ -2115,7 +2097,7 @@ dict_create_add_foreigns_to_dictionary(
dict_foreign_t* foreign;
dberr_t error;
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
if (NULL == dict_table_get_low("SYS_FOREIGN")) {
@@ -2346,7 +2328,7 @@ dict_delete_tablespace_and_datafiles(
dberr_t err = DB_SUCCESS;
ut_ad(rw_lock_own(dict_operation_lock, RW_LOCK_X));
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
ut_ad(srv_sys_tablespaces_open);
trx->op_info = "delete tablespace and datafiles from dictionary";
diff --git a/storage/innobase/dict/dict0defrag_bg.cc b/storage/innobase/dict/dict0defrag_bg.cc
index 6347a239812..bec6ce0b49a 100644
--- a/storage/innobase/dict/dict0defrag_bg.cc
+++ b/storage/innobase/dict/dict0defrag_bg.cc
@@ -151,7 +151,7 @@ dict_stats_defrag_pool_del(
{
ut_a((table && !index) || (!table && index));
ut_ad(!srv_read_only_mode);
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
mutex_enter(&defrag_pool_mutex);
@@ -193,7 +193,7 @@ dict_stats_process_entry_from_defrag_pool()
dict_table_t* table;
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
/* If the table is no longer cached, we've already lost the in
memory stats so there's nothing really to write to disk. */
@@ -208,11 +208,11 @@ dict_stats_process_entry_from_defrag_pool()
if (table) {
dict_table_close(table, TRUE, FALSE);
}
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
return;
}
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
dict_stats_save_defrag_stats(index);
dict_table_close(table, FALSE, FALSE);
}
@@ -245,7 +245,7 @@ dict_stats_save_defrag_summary(
}
rw_lock_x_lock(dict_operation_lock);
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
ret = dict_stats_save_index_stat(index, now, "n_pages_freed",
index->stat_defrag_n_pages_freed,
@@ -254,7 +254,7 @@ dict_stats_save_defrag_summary(
" last defragmentation run.",
NULL);
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
rw_lock_x_unlock(dict_operation_lock);
return (ret);
@@ -297,7 +297,7 @@ dict_stats_save_defrag_stats(
rw_lock_x_lock(dict_operation_lock);
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
ret = dict_stats_save_index_stat(index, now, "n_page_split",
index->stat_defrag_n_page_split,
NULL,
@@ -327,7 +327,7 @@ dict_stats_save_defrag_stats(
NULL);
end:
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
rw_lock_x_unlock(dict_operation_lock);
return (ret);
diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc
index 9c5293d0f9d..c8c694ea9e8 100644
--- a/storage/innobase/dict/dict0dict.cc
+++ b/storage/innobase/dict/dict0dict.cc
@@ -85,7 +85,7 @@ ib_warn_row_too_big(const dict_table_t* table);
#include <algorithm>
/** the dictionary system */
-dict_sys_t* dict_sys = NULL;
+dict_sys_t dict_sys;
/** @brief the data dictionary rw-latch protecting dict_sys
@@ -178,22 +178,6 @@ static
ibool
dict_lru_validate(void);
/*===================*/
-/**********************************************************************//**
-Check if table is in the dictionary table LRU list.
-@return TRUE if table found */
-static
-ibool
-dict_lru_find_table(
-/*================*/
- const dict_table_t* find_table); /*!< in: table to find */
-/**********************************************************************//**
-Check if a table exists in the dict table non-LRU list.
-@return TRUE if table found */
-static
-ibool
-dict_non_lru_find_table(
-/*====================*/
- const dict_table_t* find_table); /*!< in: table to find */
#endif /* UNIV_DEBUG */
/* Stream for storing detailed information about the latest foreign key
@@ -252,22 +236,6 @@ dict_get_db_name_len(
return ulint(s - name);
}
-/** Reserve the dictionary system mutex. */
-void
-dict_mutex_enter_for_mysql_func(const char *file, unsigned line)
-{
- mutex_enter_loc(&dict_sys->mutex, file, line);
-}
-
-/********************************************************************//**
-Releases the dictionary system mutex for MySQL. */
-void
-dict_mutex_exit_for_mysql(void)
-/*===========================*/
-{
- mutex_exit(&dict_sys->mutex);
-}
-
/** Allocate and init a dict_table_t's stats latch.
This function must not be called concurrently on the same table object.
@param[in,out] table_void table whose stats latch to create */
@@ -418,7 +386,7 @@ static dict_table_t* dict_table_open_on_id_low(
dict_err_ignore_t ignore_err,
bool cached_only)
{
- dict_table_t* table = dict_sys->get_table(table_id);
+ dict_table_t* table = dict_sys.get_table(table_id);
if (!table && !cached_only) {
table = dict_load_table_on_id(table_id, ignore_err);
@@ -470,7 +438,7 @@ dict_table_try_drop_aborted(
/**********************************************************************//**
When opening a table,
try to drop any indexes after an aborted index creation.
-Release the dict_sys->mutex. */
+Release the dict_sys.mutex. */
static
void
dict_table_try_drop_aborted_and_mutex_exit(
@@ -490,11 +458,11 @@ dict_table_try_drop_aborted_and_mutex_exit(
was aborted. */
table_id_t table_id = table->id;
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
dict_table_try_drop_aborted(table, table_id, 1);
} else {
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
}
}
@@ -510,10 +478,10 @@ dict_table_close(
index creation */
{
if (!dict_locked) {
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
}
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
ut_a(table->get_ref_count() > 0);
const bool last_handle = table->release();
@@ -532,14 +500,7 @@ dict_table_close(
MONITOR_DEC(MONITOR_TABLE_REFERENCE);
ut_ad(dict_lru_validate());
-
-#ifdef UNIV_DEBUG
- if (table->can_be_evicted) {
- ut_ad(dict_lru_find_table(table));
- } else {
- ut_ad(dict_non_lru_find_table(table));
- }
-#endif /* UNIV_DEBUG */
+ ut_ad(dict_sys.find(table));
if (!dict_locked) {
table_id_t table_id = table->id;
@@ -547,7 +508,7 @@ dict_table_close(
&& table->drop_aborted
&& dict_table_get_first_index(table);
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
if (drop_aborted) {
dict_table_try_drop_aborted(NULL, table_id, 0);
@@ -557,9 +518,9 @@ dict_table_close(
/********************************************************************//**
Closes the only open handle to a table and drops a table while assuring
-that dict_sys->mutex is held the whole time. This assures that the table
+that dict_sys.mutex is held the whole time. This assures that the table
is not evicted after the close when the count of open handles goes to zero.
-Because dict_sys->mutex is held, we do not need to call
+Because dict_sys.mutex is held, we do not need to call
dict_table_prevent_eviction(). */
void
dict_table_close_and_drop(
@@ -569,7 +530,7 @@ dict_table_close_and_drop(
{
dberr_t err = DB_SUCCESS;
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
ut_ad(rw_lock_own(dict_operation_lock, RW_LOCK_X));
ut_ad(trx->dict_operation != TRX_DICT_OP_NONE);
ut_ad(trx_state_eq(trx, TRX_STATE_ACTIVE));
@@ -996,10 +957,10 @@ dict_table_open_on_id(
dict_table_t* table;
if (!dict_locked) {
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
}
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
table = dict_table_open_on_id_low(
table_id,
@@ -1009,13 +970,7 @@ dict_table_open_on_id(
table_op == DICT_TABLE_OP_OPEN_ONLY_IF_CACHED);
if (table != NULL) {
-
- if (table->can_be_evicted) {
- dict_move_to_mru(table);
- }
-
- table->acquire();
-
+ dict_sys.acquire(table);
MONITOR_INC(MONITOR_TABLE_REFERENCE);
}
@@ -1075,58 +1030,49 @@ dict_table_col_in_clustered_key(
return(FALSE);
}
-/**********************************************************************//**
-Inits the data dictionary module. */
-void
-dict_init(void)
-/*===========*/
+/** Initialise the data dictionary cache. */
+void dict_sys_t::create()
{
- dict_operation_lock = static_cast<rw_lock_t*>(
- ut_zalloc_nokey(sizeof(*dict_operation_lock)));
+ ut_ad(!is_initialised());
+ dict_operation_lock = static_cast<rw_lock_t*>(
+ ut_zalloc_nokey(sizeof(*dict_operation_lock)));
- dict_sys = new (ut_zalloc_nokey(sizeof(*dict_sys))) dict_sys_t();
+ ut_d(m_initialised= true);
+ UT_LIST_INIT(table_LRU, &dict_table_t::table_LRU);
+ UT_LIST_INIT(table_non_LRU, &dict_table_t::table_LRU);
- UT_LIST_INIT(dict_sys->table_LRU, &dict_table_t::table_LRU);
- UT_LIST_INIT(dict_sys->table_non_LRU, &dict_table_t::table_LRU);
+ mutex_create(LATCH_ID_DICT_SYS, &mutex);
- mutex_create(LATCH_ID_DICT_SYS, &dict_sys->mutex);
+ const ulint hash_size = buf_pool_get_curr_size()
+ / (DICT_POOL_PER_TABLE_HASH * UNIV_WORD_SIZE);
- const ulint hash_size = buf_pool_get_curr_size()
- / (DICT_POOL_PER_TABLE_HASH * UNIV_WORD_SIZE);
+ table_hash= hash_create(hash_size);
+ table_id_hash= hash_create(hash_size);
+ temp_id_hash= hash_create(hash_size);
- dict_sys->table_hash = hash_create(hash_size);
- dict_sys->table_id_hash = hash_create(hash_size);
- dict_sys->temp_id_hash = hash_create(hash_size);
+ rw_lock_create(dict_operation_lock_key,
+ dict_operation_lock, SYNC_DICT_OPERATION);
- rw_lock_create(dict_operation_lock_key,
- dict_operation_lock, SYNC_DICT_OPERATION);
+ if (!srv_read_only_mode)
+ {
+ dict_foreign_err_file= os_file_create_tmpfile();
+ ut_a(dict_foreign_err_file);
+ }
- if (!srv_read_only_mode) {
- dict_foreign_err_file = os_file_create_tmpfile();
- ut_a(dict_foreign_err_file);
- }
-
- mutex_create(LATCH_ID_DICT_FOREIGN_ERR, &dict_foreign_err_mutex);
+ mutex_create(LATCH_ID_DICT_FOREIGN_ERR, &dict_foreign_err_mutex);
}
-/**********************************************************************//**
-Move to the most recently used segment of the LRU list. */
-void
-dict_move_to_mru(
-/*=============*/
- dict_table_t* table) /*!< in: table to move to MRU */
+/** Acquire a reference to a cached table. */
+inline void dict_sys_t::acquire(dict_table_t* table)
{
- ut_ad(mutex_own(&dict_sys->mutex));
- ut_ad(dict_lru_validate());
- ut_ad(dict_lru_find_table(table));
-
- ut_a(table->can_be_evicted);
-
- UT_LIST_REMOVE(dict_sys->table_LRU, table);
-
- UT_LIST_ADD_FIRST(dict_sys->table_LRU, table);
-
- ut_ad(dict_lru_validate());
+ ut_ad(dict_sys.find(table));
+ if (table->can_be_evicted)
+ {
+ UT_LIST_REMOVE(dict_sys.table_LRU, table);
+ UT_LIST_ADD_FIRST(dict_sys.table_LRU, table);
+ }
+
+ table->acquire();
}
/**********************************************************************//**
@@ -1152,11 +1098,11 @@ dict_table_open_on_name(
DBUG_PRINT("dict_table_open_on_name", ("table: '%s'", table_name));
if (!dict_locked) {
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
}
ut_ad(table_name);
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
table = dict_table_check_if_in_cache_low(table_name);
@@ -1172,7 +1118,7 @@ dict_table_open_on_name(
if (ignore_err == DICT_ERR_IGNORE_NONE
&& !table->is_readable()) {
/* Make life easy for drop table. */
- dict_table_prevent_eviction(table);
+ dict_sys.prevent_eviction(table);
if (table->corrupted) {
@@ -1180,31 +1126,22 @@ dict_table_open_on_name(
<< " is corrupted. Please "
"drop the table and recreate.";
if (!dict_locked) {
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
}
DBUG_RETURN(NULL);
}
- if (table->can_be_evicted) {
- dict_move_to_mru(table);
- }
-
- table->acquire();
+ dict_sys.acquire(table);
if (!dict_locked) {
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
}
DBUG_RETURN(table);
}
- if (table->can_be_evicted) {
- dict_move_to_mru(table);
- }
-
- table->acquire();
-
+ dict_sys.acquire(table);
MONITOR_INC(MONITOR_TABLE_REFERENCE);
}
@@ -1257,60 +1194,60 @@ dict_table_add_system_columns(
/** Add the table definition to the data dictionary cache */
void dict_table_t::add_to_cache()
{
- ut_ad(dict_lru_validate());
- ut_ad(mutex_own(&dict_sys->mutex));
-
cached = TRUE;
- ulint fold = ut_fold_string(name.m_name);
+ dict_sys.add(this);
+}
+
+/** Add a table definition to the data dictionary cache */
+inline void dict_sys_t::add(dict_table_t* table)
+{
+ ut_ad(!find(table));
+
+ ulint fold = ut_fold_string(table->name.m_name);
/* Look for a table with the same name: error if such exists */
{
dict_table_t* table2;
- HASH_SEARCH(name_hash, dict_sys->table_hash, fold,
+ HASH_SEARCH(name_hash, table_hash, fold,
dict_table_t*, table2, ut_ad(table2->cached),
- !strcmp(table2->name.m_name, name.m_name));
+ !strcmp(table2->name.m_name, table->name.m_name));
ut_a(table2 == NULL);
#ifdef UNIV_DEBUG
/* Look for the same table pointer with a different name */
- HASH_SEARCH_ALL(name_hash, dict_sys->table_hash,
+ HASH_SEARCH_ALL(name_hash, table_hash,
dict_table_t*, table2, ut_ad(table2->cached),
- table2 == this);
+ table2 == table);
ut_ad(table2 == NULL);
#endif /* UNIV_DEBUG */
}
- HASH_INSERT(dict_table_t, name_hash, dict_sys->table_hash, fold,
- this);
+ HASH_INSERT(dict_table_t, name_hash, table_hash, fold, table);
/* Look for a table with the same id: error if such exists */
- hash_table_t* id_hash = is_temporary()
- ? dict_sys->temp_id_hash : dict_sys->table_id_hash;
- const ulint id_fold = ut_fold_ull(id);
+ hash_table_t* id_hash = table->is_temporary()
+ ? temp_id_hash : table_id_hash;
+ const ulint id_fold = ut_fold_ull(table->id);
{
dict_table_t* table2;
HASH_SEARCH(id_hash, id_hash, id_fold,
dict_table_t*, table2, ut_ad(table2->cached),
- table2->id == id);
+ table2->id == table->id);
ut_a(table2 == NULL);
#ifdef UNIV_DEBUG
/* Look for the same table pointer with a different id */
HASH_SEARCH_ALL(id_hash, id_hash,
dict_table_t*, table2, ut_ad(table2->cached),
- table2 == this);
+ table2 == table);
ut_ad(table2 == NULL);
#endif /* UNIV_DEBUG */
- HASH_INSERT(dict_table_t, id_hash, id_hash, id_fold, this);
- }
-
- if (can_be_evicted) {
- UT_LIST_ADD_FIRST(dict_sys->table_LRU, this);
- } else {
- UT_LIST_ADD_FIRST(dict_sys->table_non_LRU, this);
+ HASH_INSERT(dict_table_t, id_hash, id_hash, id_fold, table);
}
+ UT_LIST_ADD_FIRST(table->can_be_evicted ? table_LRU : table_non_LRU,
+ table);
ut_ad(dict_lru_validate());
}
@@ -1323,7 +1260,7 @@ dict_table_can_be_evicted(
/*======================*/
dict_table_t* table) /*!< in: table to test */
{
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
ut_ad(rw_lock_own(dict_operation_lock, RW_LOCK_X));
ut_a(table->can_be_evicted);
@@ -1391,11 +1328,11 @@ dict_make_room_in_cache(
ut_a(pct_check > 0);
ut_a(pct_check <= 100);
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
ut_ad(rw_lock_own(dict_operation_lock, RW_LOCK_X));
ut_ad(dict_lru_validate());
- i = len = UT_LIST_GET_LEN(dict_sys->table_LRU);
+ i = len = UT_LIST_GET_LEN(dict_sys.table_LRU);
if (len < max_tables) {
return(0);
@@ -1409,7 +1346,7 @@ dict_make_room_in_cache(
/* Find a suitable candidate to evict from the cache. Don't scan the
entire LRU list. Only scan pct_check list entries. */
- for (table = UT_LIST_GET_LAST(dict_sys->table_LRU);
+ for (table = UT_LIST_GET_LAST(dict_sys.table_LRU);
table != NULL
&& i > check_up_to
&& (len - n_evicted) > max_tables;
@@ -1428,7 +1365,7 @@ dict_make_room_in_cache(
ut_ad(0);
}
};);
- dict_table_remove_from_cache(table, true);
+ dict_sys.remove(table, true);
++n_evicted;
}
@@ -1439,25 +1376,6 @@ dict_make_room_in_cache(
return(n_evicted);
}
-/**********************************************************************//**
-Move a table to the non-LRU list from the LRU list. */
-void
-dict_table_move_from_lru_to_non_lru(
-/*================================*/
- dict_table_t* table) /*!< in: table to move from LRU to non-LRU */
-{
- ut_ad(mutex_own(&dict_sys->mutex));
- ut_ad(dict_lru_find_table(table));
-
- ut_a(table->can_be_evicted);
-
- UT_LIST_REMOVE(dict_sys->table_LRU, table);
-
- UT_LIST_ADD_LAST(dict_sys->table_non_LRU, table);
-
- table->can_be_evicted = FALSE;
-}
-
/** Looks for an index with the given id given a table instance.
@param[in] table table instance
@param[in] id index id
@@ -1493,14 +1411,11 @@ dict_index_find_on_id_low(
/*======================*/
index_id_t id) /*!< in: index id */
{
- dict_table_t* table;
+ if (!dict_sys.is_initialised()) return NULL;
- /* This can happen if the system tablespace is the wrong page size */
- if (dict_sys == NULL) {
- return(NULL);
- }
+ dict_table_t* table;
- for (table = UT_LIST_GET_FIRST(dict_sys->table_LRU);
+ for (table = UT_LIST_GET_FIRST(dict_sys.table_LRU);
table != NULL;
table = UT_LIST_GET_NEXT(table_LRU, table)) {
@@ -1511,7 +1426,7 @@ dict_index_find_on_id_low(
}
}
- for (table = UT_LIST_GET_FIRST(dict_sys->table_non_LRU);
+ for (table = UT_LIST_GET_FIRST(dict_sys.table_non_LRU);
table != NULL;
table = UT_LIST_GET_NEXT(table_LRU, table)) {
@@ -1564,7 +1479,7 @@ dict_table_rename_in_cache(
char old_name[MAX_FULL_NAME_LEN + 1];
os_file_type_t ftype;
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
/* store the old/current name to an automatic variable */
ut_a(strlen(table->name.m_name) < sizeof old_name);
@@ -1574,7 +1489,7 @@ dict_table_rename_in_cache(
/* Look for a table with the same name: error if such exists */
dict_table_t* table2;
- HASH_SEARCH(name_hash, dict_sys->table_hash, fold,
+ HASH_SEARCH(name_hash, dict_sys.table_hash, fold,
dict_table_t*, table2, ut_ad(table2->cached),
(ut_strcmp(table2->name.m_name, new_name) == 0));
DBUG_EXECUTE_IF("dict_table_rename_in_cache_failure",
@@ -1668,7 +1583,7 @@ dict_table_rename_in_cache(
}
/* Remove table from the hash tables of tables */
- HASH_DELETE(dict_table_t, name_hash, dict_sys->table_hash,
+ HASH_DELETE(dict_table_t, name_hash, dict_sys.table_hash,
ut_fold_string(old_name), table);
if (strlen(new_name) > strlen(table->name.m_name)) {
@@ -1683,7 +1598,7 @@ dict_table_rename_in_cache(
strcpy(table->name.m_name, new_name);
/* Add table to hash table of tables */
- HASH_INSERT(dict_table_t, name_hash, dict_sys->table_hash, fold,
+ HASH_INSERT(dict_table_t, name_hash, dict_sys.table_hash, fold,
table);
if (!rename_also_foreigns) {
@@ -1947,18 +1862,18 @@ dict_table_change_id_in_cache(
dict_table_t* table, /*!< in/out: table object already in cache */
table_id_t new_id) /*!< in: new id to set */
{
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
ut_ad(!table->is_temporary());
/* Remove the table from the hash table of id's */
- HASH_DELETE(dict_table_t, id_hash, dict_sys->table_id_hash,
+ HASH_DELETE(dict_table_t, id_hash, dict_sys.table_id_hash,
ut_fold_ull(table->id), table);
table->id = new_id;
/* Add the table back to the hash table */
- HASH_INSERT(dict_table_t, id_hash, dict_sys->table_id_hash,
+ HASH_INSERT(dict_table_t, id_hash, dict_sys.table_id_hash,
ut_fold_ull(table->id), table);
}
@@ -1966,7 +1881,7 @@ dict_table_change_id_in_cache(
@param[in,out] table cached table definition to be evicted
@param[in] lru whether this is part of least-recently-used eviction
@param[in] keep whether to keep (not free) the object */
-void dict_table_remove_from_cache(dict_table_t* table, bool lru, bool keep)
+void dict_sys_t::remove(dict_table_t* table, bool lru, bool keep)
{
dict_foreign_t* foreign;
dict_index_t* index;
@@ -1974,7 +1889,7 @@ void dict_table_remove_from_cache(dict_table_t* table, bool lru, bool keep)
ut_ad(dict_lru_validate());
ut_a(table->get_ref_count() == 0);
ut_a(table->n_rec_locks == 0);
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(find(table));
ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
/* Remove the foreign constraints from the cache */
@@ -2003,32 +1918,28 @@ void dict_table_remove_from_cache(dict_table_t* table, bool lru, bool keep)
/* Remove table from the hash tables of tables */
- HASH_DELETE(dict_table_t, name_hash, dict_sys->table_hash,
+ HASH_DELETE(dict_table_t, name_hash, table_hash,
ut_fold_string(table->name.m_name), table);
hash_table_t* id_hash = table->is_temporary()
- ? dict_sys->temp_id_hash : dict_sys->table_id_hash;
+ ? temp_id_hash : table_id_hash;
const ulint id_fold = ut_fold_ull(table->id);
HASH_DELETE(dict_table_t, id_hash, id_hash, id_fold, table);
/* Remove table from LRU or non-LRU list. */
if (table->can_be_evicted) {
- ut_ad(dict_lru_find_table(table));
- UT_LIST_REMOVE(dict_sys->table_LRU, table);
+ UT_LIST_REMOVE(table_LRU, table);
} else {
- ut_ad(dict_non_lru_find_table(table));
- UT_LIST_REMOVE(dict_sys->table_non_LRU, table);
+ UT_LIST_REMOVE(table_non_LRU, table);
}
- ut_ad(dict_lru_validate());
-
if (lru && table->drop_aborted) {
/* When evicting the table definition,
drop the orphan indexes from the data dictionary
and free the index pages. */
trx_t* trx = trx_create();
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
ut_ad(rw_lock_own(dict_operation_lock, RW_LOCK_X));
/* Mimic row_mysql_lock_data_dictionary(). */
@@ -2318,7 +2229,7 @@ dict_index_add_to_cache(
ulint n_ord;
ulint i;
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
ut_ad(index->n_def == index->n_fields);
ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
ut_ad(!dict_index_is_online_ddl(index));
@@ -2462,7 +2373,7 @@ dict_index_remove_from_cache_low(
ut_ad(table && index);
ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
/* No need to acquire the dict_index_t::lock here because
there can't be any active operations on this index (or table). */
@@ -2544,7 +2455,7 @@ dict_index_find_cols(
const dict_table_t* table = index->table;
ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
for (ulint i = 0; i < index->n_fields; i++) {
ulint j;
@@ -2845,7 +2756,7 @@ dict_index_build_internal_clust(
ut_ad(dict_index_is_clust(index));
ut_ad(!dict_index_is_ibuf(index));
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
/* Create a new index object with certainly enough fields */
new_index = dict_mem_index_create(index->table, index->name,
@@ -2997,7 +2908,7 @@ dict_index_build_internal_non_clust(
ut_ad(table && index);
ut_ad(!dict_index_is_clust(index));
ut_ad(!dict_index_is_ibuf(index));
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
/* The clustered index should be the first in the list of indexes */
clust_index = UT_LIST_GET_FIRST(table->indexes);
@@ -3091,7 +3002,7 @@ dict_index_build_internal_fts(
dict_index_t* new_index;
ut_ad(index->type == DICT_FTS);
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
/* Create a new index */
new_index = dict_mem_index_create(index->table, index->name,
@@ -3165,7 +3076,7 @@ dict_foreign_remove_from_cache(
/*===========================*/
dict_foreign_t* foreign) /*!< in, own: foreign constraint */
{
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
ut_a(foreign);
if (foreign->referenced_table != NULL) {
@@ -3190,7 +3101,7 @@ dict_foreign_find(
dict_table_t* table, /*!< in: table object */
dict_foreign_t* foreign) /*!< in: foreign constraint */
{
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
ut_ad(dict_foreign_set_validate(table->foreign_set));
ut_ad(dict_foreign_set_validate(table->referenced_set));
@@ -3246,7 +3157,7 @@ dict_foreign_find_index(
{
dict_index_t* index;
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
if (error) {
*error = DB_FOREIGN_KEY_INDEX_NOT_FOUND;
@@ -3369,7 +3280,7 @@ dict_foreign_add_to_cache(
DBUG_ENTER("dict_foreign_add_to_cache");
DBUG_PRINT("dict_foreign_add_to_cache", ("id: %s", foreign->id));
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
for_table = dict_table_check_if_in_cache_low(
foreign->foreign_table_name_lookup);
@@ -3492,11 +3403,11 @@ dict_foreign_add_to_cache(
list. Otherwise it will be evicted from the cache. */
if (ref_table != NULL) {
- dict_table_prevent_eviction(ref_table);
+ dict_sys.prevent_eviction(ref_table);
}
if (for_table != NULL) {
- dict_table_prevent_eviction(for_table);
+ dict_sys.prevent_eviction(for_table);
}
ut_ad(dict_lru_validate());
@@ -4289,7 +4200,7 @@ dict_create_foreign_constraints_low(
char create_name[MAX_TABLE_NAME_LEN + 1];
ut_ad(!srv_read_only_mode);
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
table = dict_table_get_low(name);
/* First check if we are actually doing an ALTER TABLE, and in that
@@ -5202,7 +5113,7 @@ dict_foreign_parse_drop_constraints(
ptr = str;
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
loop:
ptr = dict_scan_to(ptr, "DROP");
@@ -5304,14 +5215,14 @@ syntax_error:
/**********************************************************************//**
Returns an index object if it is found in the dictionary cache.
-Assumes that dict_sys->mutex is already being held.
+Assumes that dict_sys.mutex is already being held.
@return index, NULL if not found */
dict_index_t*
dict_index_get_if_in_cache_low(
/*===========================*/
index_id_t index_id) /*!< in: index id */
{
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
return(dict_index_find_on_id_low(index_id));
}
@@ -5327,15 +5238,15 @@ dict_index_get_if_in_cache(
{
dict_index_t* index;
- if (dict_sys == NULL) {
+ if (!dict_sys.is_initialised()) {
return(NULL);
}
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
index = dict_index_get_if_in_cache_low(index_id);
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
return(index);
}
@@ -5618,7 +5529,7 @@ dict_print_info_on_foreign_keys(
dict_foreign_t* foreign;
std::string str;
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
for (dict_foreign_set::iterator it = table->foreign_set.begin();
it != table->foreign_set.end();
@@ -5685,12 +5596,12 @@ dict_print_info_on_foreign_keys(
}
}
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
return str;
}
/** Given a space_id of a file-per-table tablespace, search the
-dict_sys->table_LRU list and return the dict_table_t* pointer for it.
+dict_sys.table_LRU list and return the dict_table_t* pointer for it.
@param space tablespace
@return table if found, NULL if not */
static
@@ -5703,13 +5614,13 @@ dict_find_single_table_by_space(const fil_space_t* space)
ut_ad(space->id > 0);
- if (dict_sys == NULL) {
+ if (!dict_sys.is_initialised()) {
/* This could happen when it's in redo processing. */
return(NULL);
}
- table = UT_LIST_GET_FIRST(dict_sys->table_LRU);
- num_item = UT_LIST_GET_LEN(dict_sys->table_LRU);
+ table = UT_LIST_GET_FIRST(dict_sys.table_LRU);
+ num_item = UT_LIST_GET_LEN(dict_sys.table_LRU);
/* This function intentionally does not acquire mutex as it is used
by error handling code in deep call stack as last means to avoid
@@ -5783,9 +5694,9 @@ dict_set_corrupted(
row_mysql_lock_data_dictionary(trx);
}
- ut_ad(mutex_own(&dict_sys->mutex));
- ut_ad(!dict_table_is_comp(dict_sys->sys_tables));
- ut_ad(!dict_table_is_comp(dict_sys->sys_indexes));
+ ut_ad(mutex_own(&dict_sys.mutex));
+ ut_ad(!dict_table_is_comp(dict_sys.sys_tables));
+ ut_ad(!dict_table_is_comp(dict_sys.sys_indexes));
ut_ad(!sync_check_iterate(dict_sync_check()));
/* Mark the table as corrupted only if the clustered index
@@ -5813,7 +5724,7 @@ dict_set_corrupted(
mtr_start(&mtr);
index->type |= DICT_CORRUPT;
- sys_index = UT_LIST_GET_FIRST(dict_sys->sys_indexes->indexes);
+ sys_index = UT_LIST_GET_FIRST(dict_sys.sys_indexes->indexes);
/* Find the index row in SYS_INDEXES */
tuple = dtuple_create(heap, 2);
@@ -5873,9 +5784,9 @@ dict_set_corrupted_index_cache_only(
{
ut_ad(index != NULL);
ut_ad(index->table != NULL);
- ut_ad(mutex_own(&dict_sys->mutex));
- ut_ad(!dict_table_is_comp(dict_sys->sys_tables));
- ut_ad(!dict_table_is_comp(dict_sys->sys_indexes));
+ ut_ad(mutex_own(&dict_sys.mutex));
+ ut_ad(!dict_table_is_comp(dict_sys.sys_tables));
+ ut_ad(!dict_table_is_comp(dict_sys.sys_indexes));
/* Mark the table as corrupted only if the clustered index
is corrupted */
@@ -5903,11 +5814,11 @@ dict_index_set_merge_threshold(
btr_cur_t cursor;
ut_ad(index != NULL);
- ut_ad(!dict_table_is_comp(dict_sys->sys_tables));
- ut_ad(!dict_table_is_comp(dict_sys->sys_indexes));
+ ut_ad(!dict_table_is_comp(dict_sys.sys_tables));
+ ut_ad(!dict_table_is_comp(dict_sys.sys_indexes));
rw_lock_x_lock(dict_operation_lock);
- mutex_enter(&(dict_sys->mutex));
+ mutex_enter(&dict_sys.mutex);
heap = mem_heap_create(sizeof(dtuple_t) + 2 * (sizeof(dfield_t)
+ sizeof(que_fork_t) + sizeof(upd_node_t)
@@ -5915,7 +5826,7 @@ dict_index_set_merge_threshold(
mtr_start(&mtr);
- sys_index = UT_LIST_GET_FIRST(dict_sys->sys_indexes->indexes);
+ sys_index = UT_LIST_GET_FIRST(dict_sys.sys_indexes->indexes);
/* Find the index row in SYS_INDEXES */
tuple = dtuple_create(heap, 2);
@@ -5955,7 +5866,7 @@ dict_index_set_merge_threshold(
mtr_commit(&mtr);
mem_heap_free(heap);
- mutex_exit(&(dict_sys->mutex));
+ mutex_exit(&dict_sys.mutex);
rw_lock_x_unlock(dict_operation_lock);
}
@@ -5987,14 +5898,14 @@ void
dict_set_merge_threshold_all_debug(
uint merge_threshold_all)
{
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
dict_set_merge_threshold_list_debug(
- &dict_sys->table_LRU, merge_threshold_all);
+ &dict_sys.table_LRU, merge_threshold_all);
dict_set_merge_threshold_list_debug(
- &dict_sys->table_non_LRU, merge_threshold_all);
+ &dict_sys.table_non_LRU, merge_threshold_all);
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
}
#endif /* UNIV_DEBUG */
@@ -6140,7 +6051,7 @@ dict_table_check_for_dup_indexes(
const dict_index_t* index1;
const dict_index_t* index2;
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
/* The primary index _must_ exist */
ut_a(UT_LIST_GET_LEN(table->indexes) > 0);
@@ -6217,7 +6128,7 @@ dict_table_schema_check(
dict_table_t* table;
ulint i;
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
table = dict_table_get_low(req_schema->table_name);
@@ -6461,113 +6372,98 @@ dict_fs2utf8(
}
}
-/** Resize the hash tables besed on the current buffer pool size. */
-void
-dict_resize()
+/** Resize the hash tables based on the current buffer pool size. */
+void dict_sys_t::resize()
{
- dict_table_t* table;
+ ut_ad(m_initialised);
+ mutex_enter(&mutex);
- mutex_enter(&dict_sys->mutex);
+ /* all table entries are in table_LRU and table_non_LRU lists */
+ hash_table_free(table_hash);
+ hash_table_free(table_id_hash);
+ hash_table_free(temp_id_hash);
- /* all table entries are in table_LRU and table_non_LRU lists */
- hash_table_free(dict_sys->table_hash);
- hash_table_free(dict_sys->table_id_hash);
- hash_table_free(dict_sys->temp_id_hash);
+ const ulint hash_size = buf_pool_get_curr_size()
+ / (DICT_POOL_PER_TABLE_HASH * UNIV_WORD_SIZE);
+ table_hash = hash_create(hash_size);
+ table_id_hash = hash_create(hash_size);
+ temp_id_hash = hash_create(hash_size);
- const ulint hash_size = buf_pool_get_curr_size()
- / (DICT_POOL_PER_TABLE_HASH * UNIV_WORD_SIZE);
- dict_sys->table_hash = hash_create(hash_size);
- dict_sys->table_id_hash = hash_create(hash_size);
- dict_sys->temp_id_hash = hash_create(hash_size);
+ for (dict_table_t* table= UT_LIST_GET_FIRST(table_LRU); table;
+ table= UT_LIST_GET_NEXT(table_LRU, table))
+ {
+ ut_ad(!table->is_temporary());
+ ulint fold= ut_fold_string(table->name.m_name);
+ ulint id_fold= ut_fold_ull(table->id);
- for (table = UT_LIST_GET_FIRST(dict_sys->table_LRU); table;
- table = UT_LIST_GET_NEXT(table_LRU, table)) {
- ut_ad(!table->is_temporary());
- ulint fold = ut_fold_string(table->name.m_name);
- ulint id_fold = ut_fold_ull(table->id);
+ HASH_INSERT(dict_table_t, name_hash, table_hash, fold, table);
+ HASH_INSERT(dict_table_t, id_hash, table_id_hash, id_fold, table);
+ }
- HASH_INSERT(dict_table_t, name_hash, dict_sys->table_hash,
- fold, table);
+ for (dict_table_t* table = UT_LIST_GET_FIRST(table_non_LRU); table;
+ table = UT_LIST_GET_NEXT(table_LRU, table)) {
+ ulint fold = ut_fold_string(table->name.m_name);
+ ulint id_fold = ut_fold_ull(table->id);
- HASH_INSERT(dict_table_t, id_hash, dict_sys->table_id_hash,
- id_fold, table);
- }
+ HASH_INSERT(dict_table_t, name_hash, table_hash, fold, table);
- for (table = UT_LIST_GET_FIRST(dict_sys->table_non_LRU); table;
- table = UT_LIST_GET_NEXT(table_LRU, table)) {
- ulint fold = ut_fold_string(table->name.m_name);
- ulint id_fold = ut_fold_ull(table->id);
-
- HASH_INSERT(dict_table_t, name_hash, dict_sys->table_hash,
- fold, table);
+ hash_table_t* id_hash = table->is_temporary()
+ ? temp_id_hash : table_id_hash;
- hash_table_t* id_hash = table->is_temporary()
- ? dict_sys->temp_id_hash : dict_sys->table_id_hash;
+ HASH_INSERT(dict_table_t, id_hash, id_hash, id_fold, table);
+ }
- HASH_INSERT(dict_table_t, id_hash, id_hash, id_fold, table);
- }
-
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&mutex);
}
-/**********************************************************************//**
-Closes the data dictionary module. */
-void
-dict_close(void)
-/*============*/
+/** Close the data dictionary cache on shutdown. */
+void dict_sys_t::close()
{
- if (dict_sys == NULL) {
- /* This should only happen if a failure occurred
- during redo log processing. */
- return;
- }
+ if (!is_initialised()) return;
- /* Acquire only because it's a pre-condition. */
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&mutex);
- /* Free the hash elements. We don't remove them from the table
- because we are going to destroy the table anyway. */
- for (ulint i = 0; i < hash_get_n_cells(dict_sys->table_hash); i++) {
- dict_table_t* table;
+ /* Free the hash elements. We don't remove them from the table
+ because we are going to destroy the table anyway. */
+ for (ulint i = 0; i < hash_get_n_cells(table_hash); i++)
+ {
+ dict_table_t* table = static_cast<dict_table_t*>(HASH_GET_FIRST(table_hash,
+ i));
- table = static_cast<dict_table_t*>(
- HASH_GET_FIRST(dict_sys->table_hash, i));
+ while (table)
+ {
+ dict_table_t* prev_table = table;
+ table = static_cast<dict_table_t*>(HASH_GET_NEXT(name_hash, prev_table));
+ dict_sys.remove(prev_table);
+ }
+ }
- while (table) {
- dict_table_t* prev_table = table;
+ hash_table_free(table_hash);
- table = static_cast<dict_table_t*>(
- HASH_GET_NEXT(name_hash, prev_table));
- ut_ad(prev_table->magic_n == DICT_TABLE_MAGIC_N);
- dict_table_remove_from_cache(prev_table);
- }
- }
+ /* table_id_hash contains the same elements as in table_hash,
+ therefore we don't delete the individual elements. */
+ hash_table_free(table_id_hash);
- hash_table_free(dict_sys->table_hash);
+ /* No temporary tables should exist at this point. */
+ hash_table_free(temp_id_hash);
- /* The elements are the same instance as in dict_sys->table_hash,
- therefore we don't delete the individual elements. */
- hash_table_free(dict_sys->table_id_hash);
- hash_table_free(dict_sys->temp_id_hash);
+ mutex_exit(&mutex);
+ mutex_free(&mutex);
- mutex_exit(&dict_sys->mutex);
- mutex_free(&dict_sys->mutex);
+ rw_lock_free(dict_operation_lock);
- rw_lock_free(dict_operation_lock);
+ ut_free(dict_operation_lock);
+ dict_operation_lock = NULL;
- ut_free(dict_operation_lock);
- dict_operation_lock = NULL;
+ mutex_free(&dict_foreign_err_mutex);
- mutex_free(&dict_foreign_err_mutex);
+ if (dict_foreign_err_file)
+ {
+ fclose(dict_foreign_err_file);
+ dict_foreign_err_file = NULL;
+ }
- if (dict_foreign_err_file) {
- fclose(dict_foreign_err_file);
- dict_foreign_err_file = NULL;
- }
-
- ut_free(dict_sys);
-
- dict_sys = NULL;
+ ut_d(m_initialised= false);
}
#ifdef UNIV_DEBUG
@@ -6581,16 +6477,16 @@ dict_lru_validate(void)
{
dict_table_t* table;
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
- for (table = UT_LIST_GET_FIRST(dict_sys->table_LRU);
+ for (table = UT_LIST_GET_FIRST(dict_sys.table_LRU);
table != NULL;
table = UT_LIST_GET_NEXT(table_LRU, table)) {
ut_a(table->can_be_evicted);
}
- for (table = UT_LIST_GET_FIRST(dict_sys->table_non_LRU);
+ for (table = UT_LIST_GET_FIRST(dict_sys.table_non_LRU);
table != NULL;
table = UT_LIST_GET_NEXT(table_LRU, table)) {
@@ -6599,62 +6495,6 @@ dict_lru_validate(void)
return(TRUE);
}
-
-/**********************************************************************//**
-Check if a table exists in the dict table LRU list.
-@return TRUE if table found in LRU list */
-static
-ibool
-dict_lru_find_table(
-/*================*/
- const dict_table_t* find_table) /*!< in: table to find */
-{
- dict_table_t* table;
-
- ut_ad(find_table != NULL);
- ut_ad(mutex_own(&dict_sys->mutex));
-
- for (table = UT_LIST_GET_FIRST(dict_sys->table_LRU);
- table != NULL;
- table = UT_LIST_GET_NEXT(table_LRU, table)) {
-
- ut_a(table->can_be_evicted);
-
- if (table == find_table) {
- return(TRUE);
- }
- }
-
- return(FALSE);
-}
-
-/**********************************************************************//**
-Check if a table exists in the dict table non-LRU list.
-@return TRUE if table found in non-LRU list */
-static
-ibool
-dict_non_lru_find_table(
-/*====================*/
- const dict_table_t* find_table) /*!< in: table to find */
-{
- dict_table_t* table;
-
- ut_ad(find_table != NULL);
- ut_ad(mutex_own(&dict_sys->mutex));
-
- for (table = UT_LIST_GET_FIRST(dict_sys->table_non_LRU);
- table != NULL;
- table = UT_LIST_GET_NEXT(table_LRU, table)) {
-
- ut_a(!table->can_be_evicted);
-
- if (table == find_table) {
- return(TRUE);
- }
- }
-
- return(FALSE);
-}
#endif /* UNIV_DEBUG */
/*********************************************************************//**
Check an index to see whether its first fields are the columns in the array,
@@ -6943,8 +6783,8 @@ ulint
dict_sys_get_size()
{
/* No mutex; this is a very crude approximation anyway */
- ulint size = UT_LIST_GET_LEN(dict_sys->table_LRU)
- + UT_LIST_GET_LEN(dict_sys->table_non_LRU);
+ ulint size = UT_LIST_GET_LEN(dict_sys.table_LRU)
+ + UT_LIST_GET_LEN(dict_sys.table_non_LRU);
size *= sizeof(dict_table_t)
+ sizeof(dict_index_t) * 2
+ (sizeof(dict_col_t) + sizeof(dict_field_t)) * 10
@@ -6967,7 +6807,7 @@ dict_space_is_empty(
bool found = false;
rw_lock_x_lock(dict_operation_lock);
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
mtr_start(&mtr);
for (rec = dict_startscan_system(&pcur, &mtr, SYS_TABLES);
@@ -6988,7 +6828,7 @@ dict_space_is_empty(
}
mtr_commit(&mtr);
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
rw_lock_x_unlock(dict_operation_lock);
return(!found);
@@ -7008,7 +6848,7 @@ dict_space_get_id(
ulint id = ULINT_UNDEFINED;
rw_lock_x_lock(dict_operation_lock);
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
mtr_start(&mtr);
for (rec = dict_startscan_system(&pcur, &mtr, SYS_TABLESPACES);
@@ -7037,7 +6877,7 @@ dict_space_get_id(
}
mtr_commit(&mtr);
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
rw_lock_x_unlock(dict_operation_lock);
return(id);
diff --git a/storage/innobase/dict/dict0load.cc b/storage/innobase/dict/dict0load.cc
index 02da027f7a4..2c3e9c9e1f5 100644
--- a/storage/innobase/dict/dict0load.cc
+++ b/storage/innobase/dict/dict0load.cc
@@ -223,7 +223,7 @@ dict_get_first_table_name_in_db(
ulint len;
mtr_t mtr;
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
heap = mem_heap_create(1000);
@@ -806,7 +806,7 @@ dict_get_first_path(
char* filepath = NULL;
mem_heap_t* heap = mem_heap_create(1024);
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
mtr_start(&mtr);
@@ -885,7 +885,7 @@ dict_update_filepath(
trx_t* trx;
ut_ad(rw_lock_own(dict_operation_lock, RW_LOCK_X));
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
trx = trx_create();
trx->op_info = "update filepath";
@@ -953,7 +953,7 @@ dict_replace_tablespace_and_filepath(
return(DB_INTERRUPTED););
ut_ad(rw_lock_own(dict_operation_lock, RW_LOCK_X));
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
ut_ad(filepath);
trx = trx_create();
@@ -987,7 +987,7 @@ dict_sys_tables_rec_check(
const byte* field;
ulint len;
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
if (rec_get_deleted_flag(rec, 0)) {
return("delete-marked record in SYS_TABLES");
@@ -1351,7 +1351,7 @@ static ulint dict_check_sys_tables()
DBUG_ENTER("dict_check_sys_tables");
ut_ad(rw_lock_own(dict_operation_lock, RW_LOCK_X));
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
mtr_start(&mtr);
@@ -1488,7 +1488,7 @@ void dict_check_tablespaces_and_store_max_id()
DBUG_ENTER("dict_check_tablespaces_and_store_max_id");
rw_lock_x_lock(dict_operation_lock);
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
/* Initialize the max space_id from sys header */
mtr_start(&mtr);
@@ -1505,7 +1505,7 @@ void dict_check_tablespaces_and_store_max_id()
max_space_id = dict_check_sys_tables();
fil_set_max_space_id_if_bigger(max_space_id);
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
rw_lock_x_unlock(dict_operation_lock);
DBUG_VOID_RETURN;
@@ -1789,7 +1789,7 @@ dict_load_columns(
mtr_t mtr;
ulint n_skipped = 0;
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
mtr_start(&mtr);
@@ -1906,7 +1906,7 @@ dict_load_virtual_one_col(
mtr_t mtr;
ulint skipped = 0;
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
if (v_col->num_base == 0) {
return;
@@ -2139,7 +2139,7 @@ dict_load_fields(
mtr_t mtr;
dberr_t error;
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
mtr_start(&mtr);
@@ -2370,7 +2370,7 @@ dict_load_indexes(
mtr_t mtr;
dberr_t error = DB_SUCCESS;
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
mtr_start(&mtr);
@@ -2564,7 +2564,7 @@ corrupted:
goto corrupted;
} else if (dict_is_sys_table(table->id)
&& (dict_index_is_clust(index)
- || ((table == dict_sys->sys_tables)
+ || ((table == dict_sys.sys_tables)
&& !strcmp("ID_IND", index->name)))) {
/* The index was created in memory already at booting
@@ -2663,7 +2663,7 @@ dict_save_data_dir_path(
dict_table_t* table, /*!< in/out: table */
const char* filepath) /*!< in: filepath of tablespace */
{
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
ut_a(DICT_TF_HAS_DATA_DIR(table->flags));
ut_a(!table->data_dir_path);
@@ -2690,7 +2690,7 @@ dict_save_data_dir_path(
/** Make sure the data_dir_path is saved in dict_table_t if DATA DIRECTORY
was used. Try to read it from the fil_system first, then from SYS_DATAFILES.
@param[in] table Table object
-@param[in] dict_mutex_own true if dict_sys->mutex is owned already */
+@param[in] dict_mutex_own true if dict_sys.mutex is owned already */
void
dict_get_and_save_data_dir_path(
dict_table_t* table,
@@ -2752,7 +2752,7 @@ dict_load_table(
DBUG_ENTER("dict_load_table");
DBUG_PRINT("dict_load_table", ("loading table: '%s'", name));
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
result = dict_table_check_if_in_cache_low(name);
@@ -2888,7 +2888,7 @@ dict_load_table_one(
DBUG_ENTER("dict_load_table_one");
DBUG_PRINT("dict_load_table_one", ("table: %s", name.m_name));
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
heap = mem_heap_create(32000);
@@ -2989,7 +2989,7 @@ err_exit:
<< " failed, the table has"
" corrupted clustered indexes. Turn on"
" 'innodb_force_load_corrupted' to drop it";
- dict_table_remove_from_cache(table);
+ dict_sys.remove(table);
table = NULL;
goto func_exit;
} else {
@@ -3056,7 +3056,7 @@ corrupted:
" foreign key indexes. Turn off"
" 'foreign_key_checks' and try again.";
- dict_table_remove_from_cache(table);
+ dict_sys.remove(table);
table = NULL;
} else {
dict_mem_table_fill_foreign_vcol_set(table);
@@ -3072,7 +3072,7 @@ corrupted:
if (!srv_force_recovery
|| !index
|| !index->is_primary()) {
- dict_table_remove_from_cache(table);
+ dict_sys.remove(table);
table = NULL;
} else if (index->is_corrupted()
&& table->is_readable()) {
@@ -3133,7 +3133,7 @@ dict_load_table_on_id(
dict_table_t* table;
mtr_t mtr;
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
table = NULL;
@@ -3144,7 +3144,7 @@ dict_load_table_on_id(
mtr_start(&mtr);
/*---------------------------------------------------*/
/* Get the secondary index based on ID for table SYS_TABLES */
- sys_tables = dict_sys->sys_tables;
+ sys_tables = dict_sys.sys_tables;
sys_table_ids = dict_table_get_next_index(
dict_table_get_first_index(sys_tables));
ut_ad(!dict_table_is_comp(sys_tables));
@@ -3218,7 +3218,7 @@ dict_load_sys_table(
{
mem_heap_t* heap;
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
heap = mem_heap_create(1000);
@@ -3255,7 +3255,7 @@ dict_load_foreign_cols(
mtr_t mtr;
size_t id_len;
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
id_len = strlen(foreign->id);
@@ -3402,7 +3402,7 @@ dict_load_foreign(
DBUG_PRINT("dict_load_foreign",
("id: '%s', check_recursive: %d", id, check_recursive));
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
id_len = strlen(id);
@@ -3578,7 +3578,7 @@ dict_load_foreigns(
DBUG_ENTER("dict_load_foreigns");
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
sys_foreign = dict_table_get_low("SYS_FOREIGN");
@@ -3737,7 +3737,7 @@ dict_load_table_id_on_index_id(
bool found = false;
mtr_t mtr;
- ut_ad(mutex_own(&(dict_sys->mutex)));
+ ut_ad(mutex_own(&dict_sys.mutex));
/* NOTE that the operation of this function is protected by
the dictionary mutex, and therefore no deadlocks can occur
@@ -3784,10 +3784,10 @@ dict_table_open_on_index_id(
bool dict_locked) /*!< in: dict locked */
{
if (!dict_locked) {
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
}
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
table_id_t table_id;
dict_table_t * table = NULL;
if (dict_load_table_id_on_index_id(index_id, &table_id)) {
@@ -3798,7 +3798,7 @@ dict_table_open_on_index_id(
}
if (!dict_locked) {
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
}
return table;
}
diff --git a/storage/innobase/dict/dict0stats.cc b/storage/innobase/dict/dict0stats.cc
index 9492d9ed711..d557078de49 100644
--- a/storage/innobase/dict/dict0stats.cc
+++ b/storage/innobase/dict/dict0stats.cc
@@ -167,7 +167,7 @@ bool
dict_stats_persistent_storage_check(
/*================================*/
bool caller_has_dict_sys_mutex) /*!< in: true if the caller
- owns dict_sys->mutex */
+ owns dict_sys.mutex */
{
/* definition for the table TABLE_STATS_NAME */
dict_col_meta_t table_stats_columns[] = {
@@ -235,10 +235,10 @@ dict_stats_persistent_storage_check(
dberr_t ret;
if (!caller_has_dict_sys_mutex) {
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
}
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
/* first check table_stats */
ret = dict_table_schema_check(&table_stats_schema, errstr,
@@ -250,7 +250,7 @@ dict_stats_persistent_storage_check(
}
if (!caller_has_dict_sys_mutex) {
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
}
if (ret != DB_SUCCESS && ret != DB_STATS_DO_NOT_EXIST) {
@@ -284,7 +284,7 @@ dict_stats_exec_sql(
bool trx_started = false;
ut_ad(rw_lock_own(dict_operation_lock, RW_LOCK_X));
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
if (!dict_stats_persistent_storage_check(true)) {
pars_info_free(pinfo);
@@ -787,7 +787,7 @@ dict_table_t*
dict_stats_snapshot_create(
dict_table_t* table)
{
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
dict_table_stats_lock(table, RW_S_LATCH);
@@ -806,7 +806,7 @@ dict_stats_snapshot_create(
dict_table_stats_unlock(table, RW_S_LATCH);
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
return(t);
}
@@ -2314,7 +2314,7 @@ dict_stats_save_index_stat(
ut_ad(!trx || trx->internal || trx->mysql_thd);
ut_ad(rw_lock_own(dict_operation_lock, RW_LOCK_X));
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
dict_fs2utf8(index->table->name.m_name, db_utf8, sizeof(db_utf8),
table_utf8, sizeof(table_utf8));
@@ -2450,7 +2450,7 @@ dict_stats_save(
now = ut_time();
rw_lock_x_lock(dict_operation_lock);
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
pinfo = pars_info_create();
@@ -2489,7 +2489,7 @@ dict_stats_save(
ib::error() << "Cannot save table statistics for table "
<< table->name << ": " << ut_strerr(ret);
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
rw_lock_x_unlock(dict_operation_lock);
dict_stats_snapshot_free(table);
@@ -2596,7 +2596,7 @@ dict_stats_save(
end:
trx_free(trx);
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
rw_lock_x_unlock(dict_operation_lock);
dict_stats_snapshot_free(table);
@@ -2968,7 +2968,7 @@ dict_stats_fetch_from_ps(
char db_utf8[MAX_DB_UTF8_LEN];
char table_utf8[MAX_TABLE_UTF8_LEN];
- ut_ad(!mutex_own(&dict_sys->mutex));
+ ut_ad(!mutex_own(&dict_sys.mutex));
/* Initialize all stats to dummy values before fetching because if
the persistent storage contains incomplete stats (e.g. missing stats
@@ -3104,7 +3104,7 @@ dict_stats_update_for_index(
{
DBUG_ENTER("dict_stats_update_for_index");
- ut_ad(!mutex_own(&dict_sys->mutex));
+ ut_ad(!mutex_own(&dict_sys.mutex));
if (dict_stats_is_persistent_enabled(index->table)) {
@@ -3153,7 +3153,7 @@ dict_stats_update(
the persistent statistics
storage */
{
- ut_ad(!mutex_own(&dict_sys->mutex));
+ ut_ad(!mutex_own(&dict_sys.mutex));
if (!table->is_readable()) {
return (dict_stats_report_error(table));
@@ -3386,7 +3386,7 @@ dict_stats_drop_index(
pars_info_t* pinfo;
dberr_t ret;
- ut_ad(!mutex_own(&dict_sys->mutex));
+ ut_ad(!mutex_own(&dict_sys.mutex));
/* skip indexes whose table names do not contain a database name
e.g. if we are dropping an index from SYS_TABLES */
@@ -3407,7 +3407,7 @@ dict_stats_drop_index(
pars_info_add_str_literal(pinfo, "index_name", iname);
rw_lock_x_lock(dict_operation_lock);
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
ret = dict_stats_exec_sql(
pinfo,
@@ -3419,7 +3419,7 @@ dict_stats_drop_index(
"index_name = :index_name;\n"
"END;\n", NULL);
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
rw_lock_x_unlock(dict_operation_lock);
if (ret == DB_STATS_DO_NOT_EXIST) {
@@ -3469,7 +3469,7 @@ dict_stats_delete_from_table_stats(
dberr_t ret;
ut_ad(rw_lock_own(dict_operation_lock, RW_LOCK_X));
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
pinfo = pars_info_create();
@@ -3505,7 +3505,7 @@ dict_stats_delete_from_index_stats(
dberr_t ret;
ut_ad(rw_lock_own(dict_operation_lock, RW_LOCK_X));
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
pinfo = pars_info_create();
@@ -3542,7 +3542,7 @@ dict_stats_drop_table(
dberr_t ret;
ut_ad(rw_lock_own(dict_operation_lock, RW_LOCK_X));
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
/* skip tables that do not contain a database name
e.g. if we are dropping SYS_TABLES */
@@ -3618,7 +3618,7 @@ dict_stats_rename_table_in_table_stats(
dberr_t ret;
ut_ad(rw_lock_own(dict_operation_lock, RW_LOCK_X));
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
pinfo = pars_info_create();
@@ -3662,7 +3662,7 @@ dict_stats_rename_table_in_index_stats(
dberr_t ret;
ut_ad(rw_lock_own(dict_operation_lock, RW_LOCK_X));
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
pinfo = pars_info_create();
@@ -3706,7 +3706,7 @@ dict_stats_rename_table(
dberr_t ret;
ut_ad(!rw_lock_own(dict_operation_lock, RW_LOCK_X));
- ut_ad(!mutex_own(&dict_sys->mutex));
+ ut_ad(!mutex_own(&dict_sys.mutex));
/* skip innodb_table_stats and innodb_index_stats themselves */
if (strcmp(old_name, TABLE_STATS_NAME) == 0
@@ -3724,7 +3724,7 @@ dict_stats_rename_table(
new_table_utf8, sizeof(new_table_utf8));
rw_lock_x_lock(dict_operation_lock);
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
ulint n_attempts = 0;
do {
@@ -3744,11 +3744,11 @@ dict_stats_rename_table(
}
if (ret != DB_SUCCESS) {
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
rw_lock_x_unlock(dict_operation_lock);
os_thread_sleep(200000 /* 0.2 sec */);
rw_lock_x_lock(dict_operation_lock);
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
}
} while ((ret == DB_DEADLOCK
|| ret == DB_DUPLICATE_KEY
@@ -3776,7 +3776,7 @@ dict_stats_rename_table(
TABLE_STATS_NAME_PRINT,
new_db_utf8, new_table_utf8,
old_db_utf8, old_table_utf8);
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
rw_lock_x_unlock(dict_operation_lock);
return(ret);
}
@@ -3800,18 +3800,18 @@ dict_stats_rename_table(
}
if (ret != DB_SUCCESS) {
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
rw_lock_x_unlock(dict_operation_lock);
os_thread_sleep(200000 /* 0.2 sec */);
rw_lock_x_lock(dict_operation_lock);
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
}
} while ((ret == DB_DEADLOCK
|| ret == DB_DUPLICATE_KEY
|| ret == DB_LOCK_WAIT_TIMEOUT)
&& n_attempts < 5);
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
rw_lock_x_unlock(dict_operation_lock);
if (ret != DB_SUCCESS) {
@@ -3854,10 +3854,10 @@ dict_stats_rename_index(
const char* new_index_name) /*!< in: new index name */
{
rw_lock_x_lock(dict_operation_lock);
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
if (!dict_stats_persistent_storage_check(true)) {
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
rw_lock_x_unlock(dict_operation_lock);
return(DB_STATS_DO_NOT_EXIST);
}
@@ -3891,7 +3891,7 @@ dict_stats_rename_index(
"index_name = :old_index_name;\n"
"END;\n", NULL);
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
rw_lock_x_unlock(dict_operation_lock);
return(ret);
@@ -3942,7 +3942,7 @@ test_dict_table_schema_check()
/* prevent any data dictionary modifications while we are checking
the tables' structure */
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
/* check that a valid table is reported as valid */
schema.n_cols = 7;
@@ -4018,7 +4018,7 @@ test_dict_table_schema_check()
test_dict_table_schema_check_end:
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
}
/* @} */
diff --git a/storage/innobase/dict/dict0stats_bg.cc b/storage/innobase/dict/dict0stats_bg.cc
index 603122903ff..9bd4b6c8ce4 100644
--- a/storage/innobase/dict/dict0stats_bg.cc
+++ b/storage/innobase/dict/dict0stats_bg.cc
@@ -156,7 +156,7 @@ void dict_stats_update_if_needed_func(dict_table_t* table)
#endif
{
ut_ad(table->stat_initialized);
- ut_ad(!mutex_own(&dict_sys->mutex));
+ ut_ad(!mutex_own(&dict_sys.mutex));
ulonglong counter = table->stat_modified_counter++;
ulonglong n_rows = dict_table_get_n_rows(table);
@@ -250,7 +250,7 @@ dict_stats_recalc_pool_del(
const dict_table_t* table) /*!< in: table to remove */
{
ut_ad(!srv_read_only_mode);
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
mutex_enter(&recalc_pool_mutex);
@@ -278,7 +278,7 @@ and restore the lock before it exits.
The background stats thread is guaranteed not to start using the specified
table after this function returns and before the caller unlocks the data
dictionary because it sets the BG_STAT_IN_PROGRESS bit in table->stats_bg_flag
-under dict_sys->mutex. */
+under dict_sys.mutex. */
void
dict_stats_wait_bg_to_stop_using_table(
/*===================================*/
@@ -309,10 +309,10 @@ dict_stats_thread_init()
any level would do here)
2) from dict_stats_update_if_needed()
and released without latching anything else in between. We know
- that dict_sys->mutex (SYNC_DICT) is not acquired when
+ that dict_sys.mutex (SYNC_DICT) is not acquired when
dict_stats_update_if_needed() is called and it may be acquired
inside that function (thus a level <=SYNC_DICT would do).
- 3) from row_drop_table_for_mysql() after dict_sys->mutex (SYNC_DICT)
+ 3) from row_drop_table_for_mysql() after dict_sys.mutex (SYNC_DICT)
and dict_operation_lock (SYNC_DICT_OPERATION) have been locked
(thus a level <SYNC_DICT && <SYNC_DICT_OPERATION would do)
So we choose SYNC_STATS_AUTO_RECALC to be about below SYNC_DICT. */
@@ -370,14 +370,14 @@ dict_stats_process_entry_from_recalc_pool()
dict_table_t* table;
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
table = dict_table_open_on_id(table_id, TRUE, DICT_TABLE_OP_NORMAL);
if (table == NULL) {
/* table does not exist, must have been DROPped
after its id was enqueued */
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
return;
}
@@ -385,13 +385,13 @@ dict_stats_process_entry_from_recalc_pool()
if (!fil_table_accessible(table)) {
dict_table_close(table, TRUE, FALSE);
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
return;
}
table->stats_bg_flag |= BG_STAT_IN_PROGRESS;
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
/* ut_time() could be expensive, the current function
is called once every time a table has been changed more than 10% and
@@ -414,13 +414,13 @@ dict_stats_process_entry_from_recalc_pool()
dict_stats_update(table, DICT_STATS_RECALC_PERSISTENT);
}
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
table->stats_bg_flag = BG_STAT_NONE;
dict_table_close(table, TRUE, FALSE);
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
}
#ifdef UNIV_DEBUG
diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc
index f02f304a858..e4fb839a7cc 100644
--- a/storage/innobase/fil/fil0fil.cc
+++ b/storage/innobase/fil/fil0fil.cc
@@ -3180,7 +3180,7 @@ fil_ibd_open(
ut_ad(!fix_dict || rw_lock_own(dict_operation_lock, RW_LOCK_X));
- ut_ad(!fix_dict || mutex_own(&dict_sys->mutex));
+ ut_ad(!fix_dict || mutex_own(&dict_sys.mutex));
ut_ad(!fix_dict || !srv_read_only_mode);
ut_ad(!fix_dict || srv_log_file_size != 0);
ut_ad(fil_type_is_data(purpose));
diff --git a/storage/innobase/fts/fts0config.cc b/storage/innobase/fts/fts0config.cc
index 6b6042dee66..24f06517d07 100644
--- a/storage/innobase/fts/fts0config.cc
+++ b/storage/innobase/fts/fts0config.cc
@@ -120,9 +120,9 @@ fts_config_get_value(
error = fts_eval_sql(trx, graph);
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
que_graph_free(graph);
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
return(error);
}
diff --git a/storage/innobase/fts/fts0fts.cc b/storage/innobase/fts/fts0fts.cc
index 128518d7433..d543a8d2564 100644
--- a/storage/innobase/fts/fts0fts.cc
+++ b/storage/innobase/fts/fts0fts.cc
@@ -473,7 +473,7 @@ fts_load_user_stopword(
trx->op_info = "Load user stopword table into FTS cache";
if (!has_lock) {
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
}
/* Validate the user table existence and in the right
@@ -545,7 +545,7 @@ fts_load_user_stopword(
cleanup:
if (!has_lock) {
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
}
trx_free(trx);
@@ -916,7 +916,7 @@ fts_drop_index(
}
/****************************************************************//**
-Free the query graph but check whether dict_sys->mutex is already
+Free the query graph but check whether dict_sys.mutex is already
held */
void
fts_que_graph_free_check_lock(
@@ -940,15 +940,15 @@ fts_que_graph_free_check_lock(
}
if (!has_dict) {
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
}
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
que_graph_free(graph);
if (!has_dict) {
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
}
}
@@ -7510,7 +7510,7 @@ fts_init_index(
fts_cache_t* cache = table->fts->cache;
bool need_init = false;
- ut_ad(!mutex_own(&dict_sys->mutex));
+ ut_ad(!mutex_own(&dict_sys.mutex));
/* First check cache->get_docs is initialized */
if (!has_cache_lock) {
@@ -7575,10 +7575,10 @@ func_exit:
}
if (need_init) {
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
/* Register the table with the optimize thread. */
fts_optimize_add_table(table);
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
}
return(TRUE);
diff --git a/storage/innobase/fts/fts0opt.cc b/storage/innobase/fts/fts0opt.cc
index f91ebcbf2a6..b3f992f510a 100644
--- a/storage/innobase/fts/fts0opt.cc
+++ b/storage/innobase/fts/fts0opt.cc
@@ -1009,9 +1009,9 @@ fts_table_fetch_doc_ids(
error = fts_eval_sql(trx, graph);
fts_sql_commit(trx);
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
que_graph_free(graph);
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
if (error == DB_SUCCESS) {
ib_vector_sort(doc_ids->doc_ids, fts_update_doc_id_cmp);
@@ -3016,8 +3016,8 @@ fts_optimize_init(void)
std::vector<dict_table_t*> table_vector;
std::vector<dict_table_t*>::iterator it;
- mutex_enter(&dict_sys->mutex);
- for (table = UT_LIST_GET_FIRST(dict_sys->table_LRU);
+ mutex_enter(&dict_sys.mutex);
+ for (table = UT_LIST_GET_FIRST(dict_sys.table_LRU);
table != NULL;
table = UT_LIST_GET_NEXT(table_LRU, table)) {
if (table->fts &&
@@ -3031,12 +3031,12 @@ fts_optimize_init(void)
/* It is better to call dict_table_prevent_eviction()
outside the above loop because it operates on
- dict_sys->table_LRU list.*/
+ dict_sys.table_LRU list.*/
for (it=table_vector.begin();it!=table_vector.end();++it) {
dict_table_prevent_eviction(*it);
}
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
table_vector.clear();
fts_opt_shutdown_event = os_event_create(0);
diff --git a/storage/innobase/fts/fts0sql.cc b/storage/innobase/fts/fts0sql.cc
index 6f66486ed6e..26a51b74fff 100644
--- a/storage/innobase/fts/fts0sql.cc
+++ b/storage/innobase/fts/fts0sql.cc
@@ -175,17 +175,17 @@ fts_parse_sql(
& TABLE_DICT_LOCKED));
if (!dict_locked) {
- ut_ad(!mutex_own(&dict_sys->mutex));
+ ut_ad(!mutex_own(&dict_sys.mutex));
/* The InnoDB SQL parser is not re-entrant. */
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
}
graph = pars_sql(info, str);
ut_a(graph);
if (!dict_locked) {
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
}
ut_free(str);
@@ -205,7 +205,7 @@ fts_parse_sql_no_dict_lock(
char* str;
que_t* graph;
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
str = ut_str3cat(fts_sql_begin, sql, fts_sql_end);
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index 04fdb0ff3b2..167c6589e22 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -5809,12 +5809,12 @@ innobase_build_v_templ(
ut_ad(n_v_col > 0);
if (!locked) {
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
}
if (s_templ->vtempl) {
if (!locked) {
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
}
return;
}
@@ -5921,7 +5921,7 @@ innobase_build_v_templ(
}
if (!locked) {
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
}
s_templ->db_name = table->s->db.str;
@@ -6238,7 +6238,7 @@ no_such_table:
key_used_on_scan = m_primary_key;
if (ib_table->n_v_cols) {
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
if (ib_table->vc_templ == NULL) {
ib_table->vc_templ = UT_NEW_NOKEY(dict_vcol_templ_t());
} else if (ib_table->get_ref_count() == 1) {
@@ -6254,7 +6254,7 @@ no_such_table:
true);
}
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
}
if (!check_index_consistency(table, ib_table)) {
@@ -10264,7 +10264,7 @@ wsrep_append_foreign_key(
foreign->referenced_table : foreign->foreign_table)) {
WSREP_DEBUG("pulling %s table into cache",
(referenced) ? "referenced" : "foreign");
- mutex_enter(&(dict_sys->mutex));
+ mutex_enter(&dict_sys.mutex);
if (referenced) {
foreign->referenced_table =
@@ -10294,7 +10294,7 @@ wsrep_append_foreign_key(
TRUE, FALSE);
}
}
- mutex_exit(&(dict_sys->mutex));
+ mutex_exit(&dict_sys.mutex);
}
if ( !((referenced) ?
@@ -11148,7 +11148,7 @@ err_col:
if (table->is_temporary()) {
m_trx->table_id = table->id
- = dict_sys->get_temporary_table_id();
+ = dict_sys.get_temporary_table_id();
ut_ad(dict_tf_get_rec_format(table->flags)
!= REC_FORMAT_COMPRESSED);
table->space_id = SRV_TMP_SPACE_ID;
@@ -12575,9 +12575,9 @@ create_table_info_t::create_table_update_dict()
DBUG_RETURN(-1);
}
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
fts_optimize_add_table(innobase_table);
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
}
if (const Field* ai = m_form->found_next_number_field) {
@@ -12846,12 +12846,12 @@ ha_innobase::discard_or_import_tablespace(
btr_cur_instant_init(). */
table_id_t id = m_prebuilt->table->id;
ut_ad(id);
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
dict_table_close(m_prebuilt->table, TRUE, FALSE);
- dict_table_remove_from_cache(m_prebuilt->table);
+ dict_sys.remove(m_prebuilt->table);
m_prebuilt->table = dict_table_open_on_id(id, TRUE,
DICT_TABLE_OP_NORMAL);
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
if (!m_prebuilt->table) {
err = DB_TABLE_NOT_FOUND;
} else {
@@ -13982,7 +13982,7 @@ ha_innobase::info_low(
opt = DICT_STATS_RECALC_TRANSIENT;
}
- ut_ad(!mutex_own(&dict_sys->mutex));
+ ut_ad(!mutex_own(&dict_sys.mutex));
ret = dict_stats_update(ib_table, opt);
if (ret != DB_SUCCESS) {
@@ -14911,7 +14911,7 @@ get_foreign_key_info(
dict_table_t* ref_table;
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
ref_table = dict_table_open_on_name(
foreign->referenced_table_name_lookup,
TRUE, FALSE, DICT_ERR_IGNORE_NONE);
@@ -14966,7 +14966,7 @@ ha_innobase::get_foreign_key_list(
m_prebuilt->trx->op_info = "getting list of foreign keys";
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
for (dict_foreign_set::iterator it
= m_prebuilt->table->foreign_set.begin();
@@ -14983,7 +14983,7 @@ ha_innobase::get_foreign_key_list(
}
}
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
m_prebuilt->trx->op_info = "";
@@ -15004,7 +15004,7 @@ ha_innobase::get_parent_foreign_key_list(
m_prebuilt->trx->op_info = "getting list of referencing foreign keys";
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
for (dict_foreign_set::iterator it
= m_prebuilt->table->referenced_set.begin();
@@ -15021,7 +15021,7 @@ ha_innobase::get_parent_foreign_key_list(
}
}
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
m_prebuilt->trx->op_info = "";
@@ -15107,7 +15107,7 @@ ha_innobase::get_cascade_foreign_key_table_list(
cascade_fk_set fk_set;
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
/* Initialize the table_list with prebuilt->table name. */
struct table_list_item item = {m_prebuilt->table,
@@ -15186,7 +15186,7 @@ ha_innobase::get_cascade_foreign_key_table_list(
} while(!table_list.empty());
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
m_prebuilt->trx->op_info = "";
@@ -17377,12 +17377,6 @@ innodb_internal_table_validate(
}
dict_table_close(user_table, FALSE, TRUE);
-
- DBUG_EXECUTE_IF("innodb_evict_autoinc_table",
- mutex_enter(&dict_sys->mutex);
- dict_table_remove_from_cache(user_table, true);
- mutex_exit(&dict_sys->mutex);
- );
}
return(ret);
@@ -20506,9 +20500,9 @@ TABLE* innobase_init_vc_templ(dict_table_t* table)
return NULL;
}
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
innobase_build_v_templ(mysql_table, table, table->vc_templ, NULL, true);
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
return mysql_table;
}
diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc
index 403dae8334d..85561c08d77 100644
--- a/storage/innobase/handler/handler0alter.cc
+++ b/storage/innobase/handler/handler0alter.cc
@@ -511,7 +511,7 @@ inline bool dict_table_t::instant_column(const dict_table_t& table,
DBUG_ASSERT(table.n_cols + table.n_dropped() >= n_cols + n_dropped());
DBUG_ASSERT(!table.persistent_autoinc
|| persistent_autoinc == table.persistent_autoinc);
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
{
const char* end = table.col_names;
@@ -746,7 +746,7 @@ inline void dict_table_t::rollback_instant(
const char* old_v_col_names,
const ulint* col_map)
{
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
ut_ad(rw_lock_own(dict_operation_lock, RW_LOCK_X));
dict_index_t* index = indexes.start;
mtr_t mtr;
@@ -2511,7 +2511,7 @@ innobase_init_foreign(
ulint referenced_num_field) /*!< in: number of referenced
columns */
{
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
if (constraint_name) {
ulint db_len;
@@ -2962,7 +2962,7 @@ innobase_get_foreign_key_info(
db_namep = &db_name[0];
}
#endif
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
referenced_table_name = dict_get_referenced_table(
table->name.m_name,
@@ -2980,7 +2980,7 @@ innobase_get_foreign_key_info(
referenced_table = NULL;);
if (!referenced_table && trx->check_foreigns) {
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
my_error(ER_FK_CANNOT_OPEN_PARENT,
MYF(0), tbl_namep);
@@ -3016,7 +3016,7 @@ innobase_get_foreign_key_info(
/* Check whether there exist such
index in the the index create clause */
if (!referenced_index) {
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
my_error(ER_FK_NO_INDEX_PARENT, MYF(0),
fk_key->name.str
? fk_key->name.str : "",
@@ -3031,7 +3031,7 @@ innobase_get_foreign_key_info(
} else {
/* Not possible to add a foreign key without a
referenced column */
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
my_error(ER_CANNOT_ADD_FOREIGN, MYF(0), tbl_namep);
goto err_exit;
}
@@ -3042,7 +3042,7 @@ innobase_get_foreign_key_info(
num_col, referenced_table_name,
referenced_table, referenced_index,
referenced_column_names, referenced_num_col)) {
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
my_error(
ER_DUP_CONSTRAINT_NAME,
MYF(0),
@@ -3050,7 +3050,7 @@ innobase_get_foreign_key_info(
goto err_exit;
}
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
correct_option = innobase_set_foreign_key_option(
add_fk[num_fk], fk_key);
@@ -3994,7 +3994,7 @@ online_retry_drop_indexes_low(
dict_table_t* table, /*!< in/out: table */
trx_t* trx) /*!< in/out: transaction */
{
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
ut_ad(trx->dict_operation_lock_mode == RW_X_LATCH);
ut_ad(trx_get_dict_operation(trx) == TRX_DICT_OP_INDEX);
@@ -4031,9 +4031,9 @@ online_retry_drop_indexes(
trx_free(trx);
}
- ut_d(mutex_enter(&dict_sys->mutex));
+ ut_d(mutex_enter(&dict_sys.mutex));
ut_d(dict_table_check_for_dup_indexes(table, CHECK_ALL_COMPLETE));
- ut_d(mutex_exit(&dict_sys->mutex));
+ ut_d(mutex_exit(&dict_sys.mutex));
ut_ad(!table->drop_aborted);
}
@@ -4108,7 +4108,7 @@ innobase_check_foreigns_low(
bool drop)
{
dict_foreign_t* foreign;
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
/* Check if any FOREIGN KEY constraints are defined on this
column. */
@@ -4741,7 +4741,7 @@ innobase_update_gis_column_type(
DBUG_ASSERT(trx_get_dict_operation(trx) == TRX_DICT_OP_INDEX);
ut_ad(trx->dict_operation_lock_mode == RW_X_LATCH);
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
ut_ad(rw_lock_own(dict_operation_lock, RW_LOCK_X));
info = pars_info_create();
@@ -6725,8 +6725,8 @@ new_clustered_failed:
before we can use it we need to open the
table. The new_table must be in the data
dictionary cache, because we are still holding
- the dict_sys->mutex. */
- ut_ad(mutex_own(&dict_sys->mutex));
+ the dict_sys.mutex. */
+ ut_ad(mutex_own(&dict_sys.mutex));
temp_table = dict_table_open_on_name(
ctx->new_table->name.m_name, TRUE, FALSE,
DICT_ERR_IGNORE_NONE);
@@ -6946,7 +6946,7 @@ error_handling_drop_uncached:
op_ok:
#endif /* UNIV_DEBUG */
ut_ad(ctx->trx->dict_operation_lock_mode == RW_X_LATCH);
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
ut_ad(rw_lock_own(dict_operation_lock, RW_LOCK_X));
DICT_TF2_FLAG_SET(ctx->new_table, DICT_TF2_FTS);
@@ -7027,10 +7027,10 @@ error_handling:
case DB_SUCCESS:
ut_a(!dict_locked);
- ut_d(mutex_enter(&dict_sys->mutex));
+ ut_d(mutex_enter(&dict_sys.mutex));
ut_d(dict_table_check_for_dup_indexes(
user_table, CHECK_PARTIAL_OK));
- ut_d(mutex_exit(&dict_sys->mutex));
+ ut_d(mutex_exit(&dict_sys.mutex));
DBUG_RETURN(false);
case DB_TABLESPACE_EXISTS:
my_error(ER_TABLESPACE_EXISTS, MYF(0), "(unknown)");
@@ -7234,7 +7234,7 @@ rename_index_try(
{
DBUG_ENTER("rename_index_try");
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
ut_ad(rw_lock_own(dict_operation_lock, RW_LOCK_X));
ut_ad(trx->dict_operation_lock_mode == RW_X_LATCH);
@@ -7294,7 +7294,7 @@ innobase_rename_index_cache(dict_index_t* index, const char* new_name)
{
DBUG_ENTER("innobase_rename_index_cache");
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
ut_ad(rw_lock_own(dict_operation_lock, RW_LOCK_X));
size_t old_name_len = strlen(index->name);
@@ -7445,10 +7445,10 @@ ha_innobase::prepare_inplace_alter_table(
}
#endif /* UNIV_DEBUG */
- ut_d(mutex_enter(&dict_sys->mutex));
+ ut_d(mutex_enter(&dict_sys.mutex));
ut_d(dict_table_check_for_dup_indexes(
m_prebuilt->table, CHECK_ABORTED_OK));
- ut_d(mutex_exit(&dict_sys->mutex));
+ ut_d(mutex_exit(&dict_sys.mutex));
if (!(ha_alter_info->handler_flags & ~INNOBASE_INPLACE_IGNORE)) {
/* Nothing to do */
@@ -8411,10 +8411,10 @@ oom:
KEY* dup_key;
all_done:
case DB_SUCCESS:
- ut_d(mutex_enter(&dict_sys->mutex));
+ ut_d(mutex_enter(&dict_sys.mutex));
ut_d(dict_table_check_for_dup_indexes(
m_prebuilt->table, CHECK_PARTIAL_OK));
- ut_d(mutex_exit(&dict_sys->mutex));
+ ut_d(mutex_exit(&dict_sys.mutex));
/* prebuilt->table->n_ref_count can be anything here,
given that we hold at most a shared lock on the table. */
goto ok_exit;
@@ -8477,7 +8477,7 @@ innobase_online_rebuild_log_free(
{
dict_index_t* clust_index = dict_table_get_first_index(table);
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
ut_ad(rw_lock_own(dict_operation_lock, RW_LOCK_X));
rw_lock_x_lock(&clust_index->lock);
@@ -8752,7 +8752,7 @@ innobase_drop_foreign_try(
DBUG_ASSERT(trx_get_dict_operation(trx) == TRX_DICT_OP_INDEX);
ut_ad(trx->dict_operation_lock_mode == RW_X_LATCH);
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
ut_ad(rw_lock_own(dict_operation_lock, RW_LOCK_X));
/* Drop the constraint from the data dictionary. */
@@ -8811,7 +8811,7 @@ innobase_rename_column_try(
DBUG_ASSERT(trx_get_dict_operation(trx) == TRX_DICT_OP_INDEX);
ut_ad(trx->dict_operation_lock_mode == RW_X_LATCH);
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
ut_ad(rw_lock_own(dict_operation_lock, RW_LOCK_X));
if (new_clustered) {
@@ -9088,7 +9088,7 @@ innobase_rename_or_enlarge_column_try(
DBUG_ASSERT(trx_get_dict_operation(trx) == TRX_DICT_OP_INDEX);
ut_ad(trx->dict_operation_lock_mode == RW_X_LATCH);
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
ut_ad(rw_lock_own(dict_operation_lock, RW_LOCK_X));
ulint n_base;
@@ -9510,7 +9510,7 @@ innobase_update_foreign_cache(
DBUG_ENTER("innobase_update_foreign_cache");
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
user_table = ctx->old_table;
@@ -11173,7 +11173,7 @@ foreign_fail:
}
const_cast<unsigned&>(ctx0->old_n_v_cols) = 0;
}
- dict_table_remove_from_cache(m_prebuilt->table);
+ dict_sys.remove(m_prebuilt->table);
m_prebuilt->table = dict_table_open_on_name(
tb_name, TRUE, TRUE, DICT_ERR_IGNORE_NONE);
diff --git a/storage/innobase/handler/i_s.cc b/storage/innobase/handler/i_s.cc
index 4016b11387e..6369b024a58 100644
--- a/storage/innobase/handler/i_s.cc
+++ b/storage/innobase/handler/i_s.cc
@@ -1647,12 +1647,12 @@ i_s_cmp_per_index_fill_low(
RETURN_IF_INNODB_NOT_STARTED(tables->schema_table_name.str);
/* Create a snapshot of the stats so we do not bump into lock
- order violations with dict_sys->mutex below. */
+ order violations with dict_sys.mutex below. */
mutex_enter(&page_zip_stat_per_index_mutex);
page_zip_stat_per_index_t snap (page_zip_stat_per_index);
mutex_exit(&page_zip_stat_per_index_mutex);
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
page_zip_stat_per_index_t::iterator iter;
ulint i;
@@ -1710,13 +1710,13 @@ i_s_cmp_per_index_fill_low(
contents of INFORMATION_SCHEMA.innodb_cmp_per_index being
inconsistent, but it is an acceptable compromise. */
if (i == 1000) {
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
i = 0;
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
}
}
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
if (reset) {
page_zip_reset_stat_per_index();
@@ -3474,9 +3474,9 @@ i_s_fts_index_table_fill_selected(
}
}
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
que_graph_free(graph);
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
trx_free(trx);
@@ -4861,7 +4861,7 @@ i_s_innodb_buffer_page_fill(
if (page_info->page_type == I_S_PAGE_TYPE_INDEX) {
bool ret = false;
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
const dict_index_t* index =
dict_index_get_if_in_cache_low(
@@ -4886,7 +4886,7 @@ i_s_innodb_buffer_page_fill(
system_charset_info);
}
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
OK(ret);
@@ -5584,7 +5584,7 @@ i_s_innodb_buf_page_lru_fill(
if (page_info->page_type == I_S_PAGE_TYPE_INDEX) {
bool ret = false;
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
const dict_index_t* index =
dict_index_get_if_in_cache_low(
@@ -5609,7 +5609,7 @@ i_s_innodb_buf_page_lru_fill(
system_charset_info);
}
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
OK(ret);
@@ -6042,7 +6042,7 @@ i_s_sys_tables_fill_table(
}
heap = mem_heap_create(1000);
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
mtr_start(&mtr);
rec = dict_startscan_system(&pcur, &mtr, SYS_TABLES);
@@ -6056,7 +6056,7 @@ i_s_sys_tables_fill_table(
err_msg = dict_process_sys_tables_rec_and_mtr_commit(
heap, rec, &table_rec, false, &mtr);
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
if (!err_msg) {
i_s_dict_fill_sys_tables(thd, table_rec,
@@ -6074,13 +6074,13 @@ i_s_sys_tables_fill_table(
mem_heap_empty(heap);
/* Get the next record */
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
mtr_start(&mtr);
rec = dict_getnext_system(&pcur, &mtr);
}
mtr_commit(&mtr);
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
mem_heap_free(heap);
DBUG_RETURN(0);
@@ -6339,7 +6339,7 @@ i_s_sys_tables_fill_table_stats(
heap = mem_heap_create(1000);
rw_lock_s_lock(dict_operation_lock);
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
mtr_start(&mtr);
rec = dict_startscan_system(&pcur, &mtr, SYS_TABLES);
@@ -6354,7 +6354,7 @@ i_s_sys_tables_fill_table_stats(
heap, rec, &table_rec, true, &mtr);
ulint ref_count = table_rec ? table_rec->get_ref_count() : 0;
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
DBUG_EXECUTE_IF("test_sys_tablestats", {
if (strcmp("test/t1", table_rec->name.m_name) == 0 ) {
@@ -6377,14 +6377,14 @@ i_s_sys_tables_fill_table_stats(
/* Get the next record */
rw_lock_s_lock(dict_operation_lock);
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
mtr_start(&mtr);
rec = dict_getnext_system(&pcur, &mtr);
}
mtr_commit(&mtr);
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
rw_lock_s_unlock(dict_operation_lock);
mem_heap_free(heap);
@@ -6625,7 +6625,7 @@ i_s_sys_indexes_fill_table(
}
heap = mem_heap_create(1000);
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
mtr_start(&mtr);
/* Start scan the SYS_INDEXES table */
@@ -6647,7 +6647,7 @@ i_s_sys_indexes_fill_table(
space_id = space_id == 4 ? mach_read_from_4(field)
: ULINT_UNDEFINED;
mtr_commit(&mtr);
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
if (!err_msg) {
if (int err = i_s_dict_fill_sys_indexes(
@@ -6665,13 +6665,13 @@ i_s_sys_indexes_fill_table(
mem_heap_empty(heap);
/* Get the next record */
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
mtr_start(&mtr);
rec = dict_getnext_system(&pcur, &mtr);
}
mtr_commit(&mtr);
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
mem_heap_free(heap);
DBUG_RETURN(0);
@@ -6878,7 +6878,7 @@ i_s_sys_columns_fill_table(
}
heap = mem_heap_create(1000);
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
mtr_start(&mtr);
rec = dict_startscan_system(&pcur, &mtr, SYS_COLUMNS);
@@ -6896,7 +6896,7 @@ i_s_sys_columns_fill_table(
&nth_v_col);
mtr_commit(&mtr);
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
if (!err_msg) {
i_s_dict_fill_sys_columns(thd, table_id, col_name,
@@ -6911,13 +6911,13 @@ i_s_sys_columns_fill_table(
mem_heap_empty(heap);
/* Get the next record */
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
mtr_start(&mtr);
rec = dict_getnext_system(&pcur, &mtr);
}
mtr_commit(&mtr);
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
mem_heap_free(heap);
DBUG_RETURN(0);
@@ -7087,7 +7087,7 @@ i_s_sys_virtual_fill_table(
DBUG_RETURN(0);
}
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
mtr_start(&mtr);
rec = dict_startscan_system(&pcur, &mtr, SYS_VIRTUAL);
@@ -7103,7 +7103,7 @@ i_s_sys_virtual_fill_table(
&base_pos);
mtr_commit(&mtr);
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
if (!err_msg) {
i_s_dict_fill_sys_virtual(thd, table_id, pos, base_pos,
@@ -7115,13 +7115,13 @@ i_s_sys_virtual_fill_table(
}
/* Get the next record */
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
mtr_start(&mtr);
rec = dict_getnext_system(&pcur, &mtr);
}
mtr_commit(&mtr);
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
DBUG_RETURN(0);
}
@@ -7287,7 +7287,7 @@ i_s_sys_fields_fill_table(
}
heap = mem_heap_create(1000);
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
mtr_start(&mtr);
/* will save last index id so that we know whether we move to
@@ -7308,7 +7308,7 @@ i_s_sys_fields_fill_table(
&pos, &index_id, last_id);
mtr_commit(&mtr);
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
if (!err_msg) {
i_s_dict_fill_sys_fields(thd, index_id, &field_rec,
@@ -7323,13 +7323,13 @@ i_s_sys_fields_fill_table(
mem_heap_empty(heap);
/* Get the next record */
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
mtr_start(&mtr);
rec = dict_getnext_system(&pcur, &mtr);
}
mtr_commit(&mtr);
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
mem_heap_free(heap);
DBUG_RETURN(0);
@@ -7519,7 +7519,7 @@ i_s_sys_foreign_fill_table(
}
heap = mem_heap_create(1000);
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
mtr_start(&mtr);
rec = dict_startscan_system(&pcur, &mtr, SYS_FOREIGN);
@@ -7533,7 +7533,7 @@ i_s_sys_foreign_fill_table(
err_msg = dict_process_sys_foreign_rec(heap, rec, &foreign_rec);
mtr_commit(&mtr);
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
if (!err_msg) {
i_s_dict_fill_sys_foreign(thd, &foreign_rec,
@@ -7548,12 +7548,12 @@ i_s_sys_foreign_fill_table(
/* Get the next record */
mtr_start(&mtr);
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
rec = dict_getnext_system(&pcur, &mtr);
}
mtr_commit(&mtr);
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
mem_heap_free(heap);
DBUG_RETURN(0);
@@ -7733,7 +7733,7 @@ i_s_sys_foreign_cols_fill_table(
}
heap = mem_heap_create(1000);
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
mtr_start(&mtr);
rec = dict_startscan_system(&pcur, &mtr, SYS_FOREIGN_COLS);
@@ -7750,7 +7750,7 @@ i_s_sys_foreign_cols_fill_table(
heap, rec, &name, &for_col_name, &ref_col_name, &pos);
mtr_commit(&mtr);
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
if (!err_msg) {
i_s_dict_fill_sys_foreign_cols(
@@ -7765,13 +7765,13 @@ i_s_sys_foreign_cols_fill_table(
mem_heap_empty(heap);
/* Get the next record */
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
mtr_start(&mtr);
rec = dict_getnext_system(&pcur, &mtr);
}
mtr_commit(&mtr);
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
mem_heap_free(heap);
DBUG_RETURN(0);
@@ -8010,9 +8010,9 @@ i_s_dict_fill_sys_tablespaces(
char* filepath = NULL;
if (FSP_FLAGS_HAS_DATA_DIR(cflags)) {
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
filepath = dict_get_first_path(space);
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
}
if (filepath == NULL) {
@@ -8097,7 +8097,7 @@ i_s_sys_tablespaces_fill_table(
}
heap = mem_heap_create(1000);
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
mtr_start(&mtr);
for (rec = dict_startscan_system(&pcur, &mtr, SYS_TABLESPACES);
@@ -8114,7 +8114,7 @@ i_s_sys_tablespaces_fill_table(
heap, rec, &space, &name, &flags);
mtr_commit(&mtr);
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
if (!err_msg) {
i_s_dict_fill_sys_tablespaces(
@@ -8129,12 +8129,12 @@ i_s_sys_tablespaces_fill_table(
mem_heap_empty(heap);
/* Get the next record */
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
mtr_start(&mtr);
}
mtr_commit(&mtr);
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
mem_heap_free(heap);
DBUG_RETURN(0);
@@ -8288,7 +8288,7 @@ i_s_sys_datafiles_fill_table(
}
heap = mem_heap_create(1000);
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
mtr_start(&mtr);
rec = dict_startscan_system(&pcur, &mtr, SYS_DATAFILES);
@@ -8303,7 +8303,7 @@ i_s_sys_datafiles_fill_table(
heap, rec, &space, &path);
mtr_commit(&mtr);
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
if (!err_msg) {
i_s_dict_fill_sys_datafiles(
@@ -8317,13 +8317,13 @@ i_s_sys_datafiles_fill_table(
mem_heap_empty(heap);
/* Get the next record */
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
mtr_start(&mtr);
rec = dict_getnext_system(&pcur, &mtr);
}
mtr_commit(&mtr);
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
mem_heap_free(heap);
DBUG_RETURN(0);
diff --git a/storage/innobase/include/btr0sea.h b/storage/innobase/include/btr0sea.h
index 0c8b152d413..41ca955ad0a 100644
--- a/storage/innobase/include/btr0sea.h
+++ b/storage/innobase/include/btr0sea.h
@@ -43,7 +43,7 @@ void btr_search_sys_resize(ulint hash_size);
void btr_search_sys_free();
/** Disable the adaptive hash search system and empty the index.
-@param need_mutex need to acquire dict_sys->mutex */
+@param need_mutex need to acquire dict_sys.mutex */
void btr_search_disable(bool need_mutex);
/** Enable the adaptive hash search system. */
void btr_search_enable();
diff --git a/storage/innobase/include/dict0boot.ic b/storage/innobase/include/dict0boot.ic
index 845a0a3888d..fdee463a995 100644
--- a/storage/innobase/include/dict0boot.ic
+++ b/storage/innobase/include/dict0boot.ic
@@ -33,18 +33,18 @@ dict_sys_get_new_row_id(void)
{
row_id_t id;
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
- id = dict_sys->row_id;
+ id = dict_sys.row_id;
if (0 == (id % DICT_HDR_ROW_ID_WRITE_MARGIN)) {
dict_hdr_flush_row_id();
}
- dict_sys->row_id++;
+ dict_sys.row_id++;
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
return(id);
}
diff --git a/storage/innobase/include/dict0dict.h b/storage/innobase/include/dict0dict.h
index d2273b65349..9146627b496 100644
--- a/storage/innobase/include/dict0dict.h
+++ b/storage/innobase/include/dict0dict.h
@@ -136,19 +136,14 @@ dict_table_close(
MY_ATTRIBUTE((nonnull));
/*********************************************************************//**
Closes the only open handle to a table and drops a table while assuring
-that dict_sys->mutex is held the whole time. This assures that the table
+that dict_sys.mutex is held the whole time. This assures that the table
is not evicted after the close when the count of open handles goes to zero.
-Because dict_sys->mutex is held, we do not need to call
-dict_table_prevent_eviction(). */
+Because dict_sys.mutex is held, we do not need to call prevent_eviction(). */
void
dict_table_close_and_drop(
/*======================*/
trx_t* trx, /*!< in: data dictionary transaction */
dict_table_t* table); /*!< in/out: table */
-/**********************************************************************//**
-Inits the data dictionary module. */
-void
-dict_init(void);
/*********************************************************************//**
Gets the minimum number of bytes per character.
@@ -361,13 +356,6 @@ dict_table_add_system_columns(
dict_table_t* table, /*!< in/out: table */
mem_heap_t* heap) /*!< in: temporary heap */
MY_ATTRIBUTE((nonnull));
-/** Evict a table definition from the InnoDB data dictionary cache.
-@param[in,out] table cached table definition to be evicted
-@param[in] lru whether this is part of least-recently-used evictiono
-@param[in] keep whether to keep (not free) the object */
-void dict_table_remove_from_cache(dict_table_t* table, bool lru = false,
- bool keep = false)
- MY_ATTRIBUTE((nonnull));
/**********************************************************************//**
Renames a table object.
@return TRUE if success */
@@ -1219,7 +1207,7 @@ dict_field_get_col(
/**********************************************************************//**
Returns an index object if it is found in the dictionary cache.
-Assumes that dict_sys->mutex is already being held.
+Assumes that dict_sys.mutex is already being held.
@return index, NULL if not found */
dict_index_t*
dict_index_get_if_in_cache_low(
@@ -1367,18 +1355,9 @@ dict_index_calc_min_rec_len(
/*========================*/
const dict_index_t* index) /*!< in: index */
MY_ATTRIBUTE((nonnull, warn_unused_result));
-/** Reserve the dictionary system mutex. */
-void
-dict_mutex_enter_for_mysql_func(const char *file, unsigned line);
-#define dict_mutex_enter_for_mysql() \
- dict_mutex_enter_for_mysql_func(__FILE__, __LINE__)
-
-/********************************************************************//**
-Releases the dictionary system mutex for MySQL. */
-void
-dict_mutex_exit_for_mysql(void);
-/*===========================*/
+#define dict_mutex_enter_for_mysql() mutex_enter(&dict_sys.mutex)
+#define dict_mutex_exit_for_mysql() mutex_exit(&dict_sys.mutex)
/** Create a dict_table_t's stats latch or delay for lazy creation.
This function is only called from either single threaded environment
@@ -1459,23 +1438,6 @@ dict_table_is_fts_column(
ulint col_no, /* in: col number to search for */
bool is_virtual)/*!< in: whether it is a virtual column */
MY_ATTRIBUTE((warn_unused_result));
-/**********************************************************************//**
-Prevent table eviction by moving a table to the non-LRU list from the
-LRU list if it is not already there. */
-UNIV_INLINE
-void
-dict_table_prevent_eviction(
-/*========================*/
- dict_table_t* table) /*!< in: table to prevent eviction */
- MY_ATTRIBUTE((nonnull));
-
-/**********************************************************************//**
-Move a table to the non LRU end of the LRU list. */
-void
-dict_table_move_from_lru_to_non_lru(
-/*================================*/
- dict_table_t* table) /*!< in: table to move from LRU to non-LRU */
- MY_ATTRIBUTE((nonnull));
/** Looks for an index with the given id given a table instance.
@param[in] table table instance
@@ -1487,14 +1449,6 @@ dict_table_find_index_on_id(
index_id_t id)
MY_ATTRIBUTE((nonnull(1)));
-/**********************************************************************//**
-Move to the most recently used segment of the LRU list. */
-void
-dict_move_to_mru(
-/*=============*/
- dict_table_t* table) /*!< in: table to move to MRU */
- MY_ATTRIBUTE((nonnull));
-
/** Maximum number of columns in a foreign key constraint. Please Note MySQL
has a much lower limit on the number of columns allowed in a foreign key
constraint */
@@ -1506,13 +1460,10 @@ extern FILE* dict_foreign_err_file;
extern ib_mutex_t dict_foreign_err_mutex; /* mutex protecting the
foreign key error messages */
-/** the dictionary system */
-extern dict_sys_t* dict_sys;
-/** the data dictionary rw-latch protecting dict_sys */
-extern rw_lock_t* dict_operation_lock;
-
-/* Dictionary system struct */
-struct dict_sys_t{
+/** InnoDB data dictionary cache */
+class dict_sys_t
+{
+public:
DictSysMutex mutex; /*!< mutex protecting the data
dictionary; protects also the
disk-based dictionary system tables;
@@ -1530,8 +1481,6 @@ struct dict_sys_t{
on name */
/** hash table of persistent table IDs */
hash_table_t* table_id_hash;
- /** hash table of temporary table IDs */
- hash_table_t* temp_id_hash;
dict_table_t* sys_tables; /*!< SYS_TABLES table */
dict_table_t* sys_columns; /*!< SYS_COLUMNS table */
dict_table_t* sys_indexes; /*!< SYS_INDEXES table */
@@ -1545,6 +1494,13 @@ struct dict_sys_t{
UT_LIST_BASE_NODE_T(dict_table_t)
table_non_LRU; /*!< List of tables that can't be
evicted from the cache */
+private:
+ bool m_initialised;
+ /** the sequence of temporary table IDs */
+ std::atomic<table_id_t> temp_table_id;
+ /** hash table of temporary table IDs */
+ hash_table_t* temp_id_hash;
+public:
/** @return a new temporary table ID */
table_id_t get_temporary_table_id() {
@@ -1586,13 +1542,76 @@ struct dict_sys_t{
return table;
}
- dict_sys_t() : temp_table_id(DICT_HDR_FIRST_ID) {}
+ /**
+ Constructor. Further initialisation happens in create().
+ */
-private:
- /** the sequence of temporary table IDs */
- std::atomic<table_id_t> temp_table_id;
+ dict_sys_t() : m_initialised(false), temp_table_id(DICT_HDR_FIRST_ID) {}
+
+ bool is_initialised() const { return m_initialised; }
+
+ /** Initialise the data dictionary cache. */
+ void create();
+
+ /** Close the data dictionary cache on shutdown. */
+ void close();
+
+ /** Resize the hash tables based on the current buffer pool size. */
+ void resize();
+
+ /** Add a table definition to the data dictionary cache */
+ inline void add(dict_table_t* table);
+ /** Remove a table definition from the data dictionary cache.
+ @param[in,out] table cached table definition to be evicted
+ @param[in] lru whether this is part of least-recently-used evictiono
+ @param[in] keep whether to keep (not free) the object */
+ void remove(dict_table_t* table, bool lru = false, bool keep = false);
+
+#ifdef UNIV_DEBUG
+ /** Find a table */
+ template <bool in_lru> bool find(dict_table_t* table)
+ {
+ ut_ad(table);
+ ut_ad(table->can_be_evicted == in_lru);
+ ut_ad(mutex_own(&mutex));
+ for (const dict_table_t* t = UT_LIST_GET_FIRST(in_lru
+ ? table_LRU : table_non_LRU);
+ t; t = UT_LIST_GET_NEXT(table_LRU, t))
+ {
+ if (t == table) return true;
+ ut_ad(t->can_be_evicted == in_lru);
+ }
+ return false;
+ }
+ /** Find a table */
+ bool find(dict_table_t* table)
+ {
+ return table->can_be_evicted ? find<true>(table) : find<false>(table);
+ }
+#endif
+
+ /** Move a table to the non-LRU list from the LRU list. */
+ void prevent_eviction(dict_table_t* table)
+ {
+ ut_ad(find(table));
+ if (table->can_be_evicted)
+ {
+ table->can_be_evicted = FALSE;
+ UT_LIST_REMOVE(table_LRU, table);
+ UT_LIST_ADD_LAST(table_non_LRU, table);
+ }
+ }
+ /** Acquire a reference to a cached table. */
+ inline void acquire(dict_table_t* table);
};
+/** the data dictionary cache */
+extern dict_sys_t dict_sys;
+/** the data dictionary rw-latch protecting dict_sys */
+extern rw_lock_t* dict_operation_lock;
+
+#define dict_table_prevent_eviction(table) dict_sys.prevent_eviction(table)
+
/** dummy index for ROW_FORMAT=REDUNDANT supremum and infimum records */
extern dict_index_t* dict_ind_redundant;
@@ -1676,16 +1695,6 @@ dict_fs2utf8(
size_t table_utf8_size)/*!< in: table_utf8 size */
MY_ATTRIBUTE((nonnull));
-/** Resize the hash tables besed on the current buffer pool size. */
-void
-dict_resize();
-
-/**********************************************************************//**
-Closes the data dictionary module. */
-void
-dict_close(void);
-/*============*/
-
/**********************************************************************//**
Check whether the table is corrupted.
@return nonzero for corrupted table, zero for valid tables */
diff --git a/storage/innobase/include/dict0dict.ic b/storage/innobase/include/dict0dict.ic
index 30bda5f6971..54ec551455d 100644
--- a/storage/innobase/include/dict0dict.ic
+++ b/storage/innobase/include/dict0dict.ic
@@ -717,7 +717,7 @@ dict_table_x_lock_indexes(
{
dict_index_t* index;
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
/* Loop through each index of the table and lock them */
for (index = dict_table_get_first_index(table);
@@ -758,7 +758,7 @@ dict_table_x_unlock_indexes(
{
dict_index_t* index;
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
for (index = dict_table_get_first_index(table);
index != NULL;
@@ -1178,21 +1178,6 @@ dict_max_v_field_len_store_undo(
return(max_log_len);
}
-/**********************************************************************//**
-Prevent table eviction by moving a table to the non-LRU list from the
-LRU list if it is not already there. */
-UNIV_INLINE
-void
-dict_table_prevent_eviction(
-/*========================*/
- dict_table_t* table) /*!< in: table to prevent eviction */
-{
- ut_ad(mutex_own(&dict_sys->mutex));
- if (table->can_be_evicted) {
- dict_table_move_from_lru_to_non_lru(table);
- }
-}
-
/********************************************************************//**
Check whether the table is corrupted.
@return nonzero for corrupted table, zero for valid tables */
@@ -1236,7 +1221,7 @@ inline
void
dict_table_t::acquire()
{
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
n_ref_count++;
}
diff --git a/storage/innobase/include/dict0load.h b/storage/innobase/include/dict0load.h
index 670f4646f9d..b67b14be410 100644
--- a/storage/innobase/include/dict0load.h
+++ b/storage/innobase/include/dict0load.h
@@ -90,7 +90,7 @@ dict_get_first_path(
/** Make sure the data_file_name is saved in dict_table_t if needed.
Try to read it from the fil_system first, then from SYS_DATAFILES.
@param[in] table Table object
-@param[in] dict_mutex_own true if dict_sys->mutex is owned already */
+@param[in] dict_mutex_own true if dict_sys.mutex is owned already */
void
dict_get_and_save_data_dir_path(
dict_table_t* table,
diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h
index 2e8b8d72c93..cee16102b2e 100644
--- a/storage/innobase/include/dict0mem.h
+++ b/storage/innobase/include/dict0mem.h
@@ -954,7 +954,7 @@ struct dict_index_t {
Transitions from ONLINE_INDEX_COMPLETE (to
ONLINE_INDEX_CREATION) are protected
by dict_operation_lock and
- dict_sys->mutex. Other changes are
+ dict_sys.mutex. Other changes are
protected by index->lock. */
unsigned uncommitted:1;
/*!< a flag that is set for secondary indexes
@@ -2051,7 +2051,7 @@ public:
/** The state of the background stats thread wrt this table.
See BG_STAT_NONE, BG_STAT_IN_PROGRESS and BG_STAT_SHOULD_QUIT.
- Writes are covered by dict_sys->mutex. Dirty reads are possible. */
+ Writes are covered by dict_sys.mutex. Dirty reads are possible. */
#define BG_SCRUB_IN_PROGRESS ((byte)(1 << 2))
/*!< BG_SCRUB_IN_PROGRESS is set in
@@ -2067,7 +2067,7 @@ public:
/** The state of the background stats thread wrt this table.
See BG_STAT_NONE, BG_STAT_IN_PROGRESS and BG_STAT_SHOULD_QUIT.
- Writes are covered by dict_sys->mutex. Dirty reads are possible. */
+ Writes are covered by dict_sys.mutex. Dirty reads are possible. */
byte stats_bg_flag;
bool stats_error_printed;
diff --git a/storage/innobase/include/dict0priv.ic b/storage/innobase/include/dict0priv.ic
index 6d7fbf07394..6ce678b6c3a 100644
--- a/storage/innobase/include/dict0priv.ic
+++ b/storage/innobase/include/dict0priv.ic
@@ -39,7 +39,7 @@ dict_table_get_low(
dict_table_t* table;
ut_ad(table_name);
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
table = dict_table_check_if_in_cache_low(table_name);
@@ -79,12 +79,12 @@ dict_table_check_if_in_cache_low(
("table: '%s'", table_name));
ut_ad(table_name);
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
/* Look for the table name in the hash table */
table_fold = ut_fold_string(table_name);
- HASH_SEARCH(name_hash, dict_sys->table_hash, table_fold,
+ HASH_SEARCH(name_hash, dict_sys.table_hash, table_fold,
dict_table_t*, table, ut_ad(table->cached),
!strcmp(table->name.m_name, table_name));
DBUG_RETURN(table);
diff --git a/storage/innobase/include/dict0stats.ic b/storage/innobase/include/dict0stats.ic
index 4edc7860363..6f4b5f1b70a 100644
--- a/storage/innobase/include/dict0stats.ic
+++ b/storage/innobase/include/dict0stats.ic
@@ -148,7 +148,7 @@ dict_stats_init(
/*============*/
dict_table_t* table) /*!< in/out: table */
{
- ut_ad(!mutex_own(&dict_sys->mutex));
+ ut_ad(!mutex_own(&dict_sys.mutex));
if (table->stat_initialized) {
return;
@@ -174,7 +174,7 @@ dict_stats_deinit(
/*==============*/
dict_table_t* table) /*!< in/out: table */
{
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
ut_a(table->get_ref_count() == 0);
diff --git a/storage/innobase/include/dict0stats_bg.h b/storage/innobase/include/dict0stats_bg.h
index 8387e3265b2..15ab68d5cec 100644
--- a/storage/innobase/include/dict0stats_bg.h
+++ b/storage/innobase/include/dict0stats_bg.h
@@ -72,7 +72,7 @@ dict_stats_stop_bg(
dict_table_t* table) /*!< in/out: table */
{
ut_ad(!srv_read_only_mode);
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
if (!(table->stats_bg_flag & BG_STAT_IN_PROGRESS)) {
return(true);
@@ -90,7 +90,7 @@ and restore the lock before it exits.
The background stats thread is guaranteed not to start using the specified
table after this function returns and before the caller unlocks the data
dictionary because it sets the BG_STAT_IN_PROGRESS bit in table->stats_bg_flag
-under dict_sys->mutex. */
+under dict_sys.mutex. */
void
dict_stats_wait_bg_to_stop_using_table(
/*===================================*/
diff --git a/storage/innobase/include/dict0types.h b/storage/innobase/include/dict0types.h
index 80b918b2df0..ee6fa77eb13 100644
--- a/storage/innobase/include/dict0types.h
+++ b/storage/innobase/include/dict0types.h
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2013, 2017, MariaDB Corporation.
+Copyright (c) 2013, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -30,7 +30,6 @@ Created 1/8/1996 Heikki Tuuri
#include <ut0mutex.h>
#include <rem0types.h>
-struct dict_sys_t;
struct dict_col_t;
struct dict_field_t;
struct dict_index_t;
diff --git a/storage/innobase/include/fts0fts.h b/storage/innobase/include/fts0fts.h
index 9a10375759c..bea58476e8b 100644
--- a/storage/innobase/include/fts0fts.h
+++ b/storage/innobase/include/fts0fts.h
@@ -326,7 +326,7 @@ enum fts_status {
sync-ed after crash recovery */
TABLE_DICT_LOCKED = 16 /*!< Set if the table has
- dict_sys->mutex */
+ dict_sys.mutex */
};
typedef enum fts_status fts_status_t;
@@ -409,9 +409,9 @@ extern char* fts_internal_tbl_name2;
#define fts_que_graph_free(graph) \
do { \
- mutex_enter(&dict_sys->mutex); \
+ mutex_enter(&dict_sys.mutex); \
que_graph_free(graph); \
- mutex_exit(&dict_sys->mutex); \
+ mutex_exit(&dict_sys.mutex); \
} while (0)
/******************************************************************//**
@@ -804,7 +804,7 @@ fts_sync_table(
bool has_dict);
/****************************************************************//**
-Free the query graph but check whether dict_sys->mutex is already
+Free the query graph but check whether dict_sys.mutex is already
held */
void
fts_que_graph_free_check_lock(
diff --git a/storage/innobase/include/log0log.ic b/storage/innobase/include/log0log.ic
index 60e6958d592..a3de6356ad8 100644
--- a/storage/innobase/include/log0log.ic
+++ b/storage/innobase/include/log0log.ic
@@ -483,7 +483,7 @@ log_free_check(void)
#ifdef UNIV_DEBUG
static const latch_level_t latches[] = {
- SYNC_DICT, /* dict_sys->mutex during
+ SYNC_DICT, /* dict_sys.mutex during
commit_try_rebuild() */
SYNC_DICT_OPERATION, /* dict_operation_lock X-latch during
commit_try_rebuild() */
diff --git a/storage/innobase/include/que0que.h b/storage/innobase/include/que0que.h
index 9912960e3b4..08f5fb9221a 100644
--- a/storage/innobase/include/que0que.h
+++ b/storage/innobase/include/que0que.h
@@ -297,9 +297,9 @@ que_eval_sql(
/*=========*/
pars_info_t* info, /*!< in: info struct, or NULL */
const char* sql, /*!< in: SQL string */
- ibool reserve_dict_mutex,
- /*!< in: if TRUE, acquire/release
- dict_sys->mutex around call to pars_sql. */
+ bool reserve_dict_mutex,
+ /*!< in: whether to acquire/release
+ dict_sys.mutex around call to pars_sql. */
trx_t* trx); /*!< in: trx */
/**********************************************************************//**
diff --git a/storage/innobase/pars/pars0pars.cc b/storage/innobase/pars/pars0pars.cc
index 363ca69a09b..b57f0cc10c7 100644
--- a/storage/innobase/pars/pars0pars.cc
+++ b/storage/innobase/pars/pars0pars.cc
@@ -2118,7 +2118,7 @@ pars_sql(
heap = mem_heap_create(16000);
/* Currently, the parser is not reentrant: */
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
pars_sym_tab_global = sym_tab_create(heap);
diff --git a/storage/innobase/pars/pars0sym.cc b/storage/innobase/pars/pars0sym.cc
index 8249af53b39..8c46d230752 100644
--- a/storage/innobase/pars/pars0sym.cc
+++ b/storage/innobase/pars/pars0sym.cc
@@ -67,7 +67,7 @@ sym_tab_free_private(
sym_node_t* sym;
func_node_t* func;
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
for (sym = UT_LIST_GET_FIRST(sym_tab->sym_list);
sym != NULL;
diff --git a/storage/innobase/que/que0que.cc b/storage/innobase/que/que0que.cc
index ceb48c4b298..f5d843bc8f7 100644
--- a/storage/innobase/que/que0que.cc
+++ b/storage/innobase/que/que0que.cc
@@ -1188,9 +1188,9 @@ que_eval_sql(
/*=========*/
pars_info_t* info, /*!< in: info struct, or NULL */
const char* sql, /*!< in: SQL string */
- ibool reserve_dict_mutex,
- /*!< in: if TRUE, acquire/release
- dict_sys->mutex around call to pars_sql. */
+ bool reserve_dict_mutex,
+ /*!< in: whether to acquire/release
+ dict_sys.mutex around call to pars_sql. */
trx_t* trx) /*!< in: trx */
{
que_thr_t* thr;
@@ -1202,13 +1202,13 @@ que_eval_sql(
ut_a(trx->error_state == DB_SUCCESS);
if (reserve_dict_mutex) {
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
}
graph = pars_sql(info, sql);
if (reserve_dict_mutex) {
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
}
graph->trx = trx;
@@ -1221,13 +1221,13 @@ que_eval_sql(
que_run_threads(thr);
if (reserve_dict_mutex) {
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
}
que_graph_free(graph);
if (reserve_dict_mutex) {
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
}
DBUG_RETURN(trx->error_state);
diff --git a/storage/innobase/row/row0import.cc b/storage/innobase/row/row0import.cc
index 9ef737828a0..5455c969c7a 100644
--- a/storage/innobase/row/row0import.cc
+++ b/storage/innobase/row/row0import.cc
@@ -2279,7 +2279,7 @@ row_import_adjust_root_pages_of_secondary_indexes(
}
/*****************************************************************//**
-Ensure that dict_sys->row_id exceeds SELECT MAX(DB_ROW_ID). */
+Ensure that dict_sys.row_id exceeds SELECT MAX(DB_ROW_ID). */
MY_ATTRIBUTE((nonnull)) static
void
row_import_set_sys_max_row_id(
@@ -2331,14 +2331,14 @@ row_import_set_sys_max_row_id(
/* Update the system row id if the imported index row id is
greater than the max system row id. */
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
- if (row_id >= dict_sys->row_id) {
- dict_sys->row_id = row_id + 1;
+ if (row_id >= dict_sys.row_id) {
+ dict_sys.row_id = row_id + 1;
dict_hdr_flush_row_id();
}
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
}
}
@@ -4011,7 +4011,7 @@ row_import_for_mysql(
/* Open the tablespace so that we can access via the buffer pool.
We set the 2nd param (fix_dict = true) here because we already
- have an x-lock on dict_operation_lock and dict_sys->mutex.
+ have an x-lock on dict_operation_lock and dict_sys.mutex.
The tablespace is initially opened as a temporary one, because
we will not be writing any redo log for it before we have invoked
fil_space_t::set_imported() to declare it a persistent tablespace. */
diff --git a/storage/innobase/row/row0ins.cc b/storage/innobase/row/row0ins.cc
index adb154c8446..c4b6883156c 100644
--- a/storage/innobase/row/row0ins.cc
+++ b/storage/innobase/row/row0ins.cc
@@ -3039,9 +3039,9 @@ row_ins_sec_index_entry_low(
if (!index->is_committed()) {
ut_ad(!thr_get_trx(thr)
->dict_operation_lock_mode);
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
dict_set_corrupted_index_cache_only(index);
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
/* Do not return any error to the
caller. The duplicate will be reported
by ALTER TABLE or CREATE UNIQUE INDEX.
diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc
index 469a25e6836..83c8316b523 100644
--- a/storage/innobase/row/row0merge.cc
+++ b/storage/innobase/row/row0merge.cc
@@ -3755,7 +3755,7 @@ row_merge_drop_index_dict(
pars_info_t* info;
ut_ad(!srv_read_only_mode);
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
ut_ad(trx->dict_operation_lock_mode == RW_X_LATCH);
ut_ad(trx_get_dict_operation(trx) == TRX_DICT_OP_INDEX);
ut_ad(rw_lock_own(dict_operation_lock, RW_LOCK_X));
@@ -3818,7 +3818,7 @@ row_merge_drop_indexes_dict(
pars_info_t* info;
ut_ad(!srv_read_only_mode);
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
ut_ad(trx->dict_operation_lock_mode == RW_X_LATCH);
ut_ad(trx_get_dict_operation(trx) == TRX_DICT_OP_INDEX);
ut_ad(rw_lock_own(dict_operation_lock, RW_LOCK_X));
@@ -3868,7 +3868,7 @@ row_merge_drop_indexes(
dict_index_t* next_index;
ut_ad(!srv_read_only_mode);
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
ut_ad(trx->dict_operation_lock_mode == RW_X_LATCH);
ut_ad(trx_get_dict_operation(trx) == TRX_DICT_OP_INDEX);
ut_ad(rw_lock_own(dict_operation_lock, RW_LOCK_X));
@@ -3952,7 +3952,7 @@ row_merge_drop_indexes(
rw_lock_x_unlock(dict_index_get_lock(index));
DEBUG_SYNC_C("merge_drop_index_after_abort");
- /* covered by dict_sys->mutex */
+ /* covered by dict_sys.mutex */
MONITOR_INC(MONITOR_BACKGROUND_DROP_INDEX);
/* fall through */
case ONLINE_INDEX_ABORTED:
@@ -4015,7 +4015,7 @@ row_merge_drop_indexes(
break;
case ONLINE_INDEX_ABORTED:
case ONLINE_INDEX_ABORTED_DROPPED:
- /* covered by dict_sys->mutex */
+ /* covered by dict_sys.mutex */
MONITOR_DEC(MONITOR_BACKGROUND_DROP_INDEX);
}
@@ -4320,7 +4320,7 @@ row_merge_rename_tables_dict(
ut_ad(!srv_read_only_mode);
ut_ad(old_table != new_table);
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
ut_a(trx->dict_operation_lock_mode == RW_X_LATCH);
ut_ad(trx_get_dict_operation(trx) == TRX_DICT_OP_TABLE
|| trx_get_dict_operation(trx) == TRX_DICT_OP_INDEX);
diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc
index afbcdfe4423..1ddae8d4fc3 100644
--- a/storage/innobase/row/row0mysql.cc
+++ b/storage/innobase/row/row0mysql.cc
@@ -2328,7 +2328,7 @@ row_mysql_lock_data_dictionary_func(
rw_lock_x_lock_inline(dict_operation_lock, 0, file, line);
trx->dict_operation_lock_mode = RW_X_LATCH;
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
}
/*********************************************************************//**
@@ -2345,7 +2345,7 @@ row_mysql_unlock_data_dictionary(
/* Serialize data dictionary operations with dictionary mutex:
no deadlocks can occur then in these operations */
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
rw_lock_x_unlock(dict_operation_lock);
trx->dict_operation_lock_mode = 0;
@@ -2371,7 +2371,7 @@ row_create_table_for_mysql(
dberr_t err;
ut_ad(rw_lock_own(dict_operation_lock, RW_LOCK_X));
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
ut_ad(trx->dict_operation_lock_mode == RW_X_LATCH);
DBUG_EXECUTE_IF(
@@ -2512,7 +2512,7 @@ row_create_index_for_mysql(
dict_table_t* table = index->table;
ut_ad(rw_lock_own(dict_operation_lock, RW_LOCK_X));
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
for (i = 0; i < index->n_def; i++) {
/* Check that prefix_len and actual length
@@ -2738,7 +2738,7 @@ row_mysql_drop_garbage_tables()
mtr.start();
btr_pcur_open_at_index_side(
- true, dict_table_get_first_index(dict_sys->sys_tables),
+ true, dict_table_get_first_index(dict_sys.sys_tables),
BTR_SEARCH_LEAF, &pcur, true, 0, &mtr);
for (;;) {
@@ -3281,7 +3281,7 @@ row_drop_table_from_cache(
is going to be destroyed below. */
trx->mod_tables.erase(table);
- dict_table_remove_from_cache(table);
+ dict_sys.remove(table);
if (dict_load_table(tablename, true, DICT_ERR_IGNORE_NONE)) {
ib::error() << "Not able to remove table "
@@ -3342,7 +3342,7 @@ row_drop_table_for_mysql(
nonatomic = true;
}
- ut_ad(mutex_own(&dict_sys->mutex));
+ ut_ad(mutex_own(&dict_sys.mutex));
ut_ad(rw_lock_own(dict_operation_lock, RW_LOCK_X));
table = dict_table_open_on_name(
@@ -3374,7 +3374,7 @@ row_drop_table_for_mysql(
is going to be destroyed below. */
trx->mod_tables.erase(table);
table->release();
- dict_table_remove_from_cache(table);
+ dict_sys.remove(table);
err = DB_SUCCESS;
goto funct_exit_all_freed;
}
@@ -4017,8 +4017,8 @@ loop:
/* The dict_table_t object must not be accessed before
dict_table_open() or after dict_table_close(). But this is OK
- if we are holding, the dict_sys->mutex. */
- ut_ad(mutex_own(&dict_sys->mutex));
+ if we are holding, the dict_sys.mutex. */
+ ut_ad(mutex_own(&dict_sys.mutex));
/* Disable statistics on the found table. */
if (!dict_stats_stop_bg(table)) {
diff --git a/storage/innobase/row/row0uins.cc b/storage/innobase/row/row0uins.cc
index 0fdb740db04..be88f0caeb3 100644
--- a/storage/innobase/row/row0uins.cc
+++ b/storage/innobase/row/row0uins.cc
@@ -395,11 +395,11 @@ static bool row_undo_ins_parse_undo_rec(undo_node_t* node, bool dict_locked)
node->table = dict_table_open_on_id(table_id, dict_locked,
DICT_TABLE_OP_NORMAL);
} else if (!dict_locked) {
- mutex_enter(&dict_sys->mutex);
- node->table = dict_sys->get_temporary_table(table_id);
- mutex_exit(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
+ node->table = dict_sys.get_temporary_table(table_id);
+ mutex_exit(&dict_sys.mutex);
} else {
- node->table = dict_sys->get_temporary_table(table_id);
+ node->table = dict_sys.get_temporary_table(table_id);
}
if (!node->table) {
@@ -583,11 +583,11 @@ row_undo_ins(
if (node->table->id == DICT_INDEXES_ID) {
ut_ad(!node->table->is_temporary());
if (!dict_locked) {
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
}
err = row_undo_ins_remove_clust_rec(node);
if (!dict_locked) {
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
}
} else {
err = row_undo_ins_remove_clust_rec(node);
@@ -603,7 +603,7 @@ row_undo_ins(
/* Do not attempt to update statistics when
executing ROLLBACK in the InnoDB SQL
interpreter, because in that case we would
- already be holding dict_sys->mutex, which
+ already be holding dict_sys.mutex, which
would be acquired when updating statistics. */
if (!dict_locked) {
dict_stats_update_if_needed(
diff --git a/storage/innobase/row/row0umod.cc b/storage/innobase/row/row0umod.cc
index 7ff64929080..9c8d3d3d313 100644
--- a/storage/innobase/row/row0umod.cc
+++ b/storage/innobase/row/row0umod.cc
@@ -910,9 +910,9 @@ row_undo_mod_sec_flag_corrupted(
on the data dictionary during normal rollback,
we can only mark the index corrupted in the
data dictionary cache. TODO: fix this somehow.*/
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
dict_set_corrupted_index_cache_only(index);
- mutex_exit(&dict_sys->mutex);
+ mutex_exit(&dict_sys.mutex);
break;
default:
ut_ad(0);
@@ -1228,11 +1228,11 @@ static bool row_undo_mod_parse_undo_rec(undo_node_t* node, bool dict_locked)
node->table = dict_table_open_on_id(table_id, dict_locked,
DICT_TABLE_OP_NORMAL);
} else if (!dict_locked) {
- mutex_enter(&dict_sys->mutex);
- node->table = dict_sys->get_temporary_table(table_id);
- mutex_exit(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
+ node->table = dict_sys.get_temporary_table(table_id);
+ mutex_exit(&dict_sys.mutex);
} else {
- node->table = dict_sys->get_temporary_table(table_id);
+ node->table = dict_sys.get_temporary_table(table_id);
}
if (!node->table) {
@@ -1402,7 +1402,7 @@ rollback_clust:
/* Do not attempt to update statistics when
executing ROLLBACK in the InnoDB SQL
interpreter, because in that case we would
- already be holding dict_sys->mutex, which
+ already be holding dict_sys.mutex, which
would be acquired when updating statistics. */
if (update_statistics && !dict_locked) {
dict_stats_update_if_needed(
diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc
index 2337dfaada2..c794731306e 100644
--- a/storage/innobase/srv/srv0start.cc
+++ b/storage/innobase/srv/srv0start.cc
@@ -2400,36 +2400,6 @@ skip_monitors:
return(DB_SUCCESS);
}
-#if 0
-/********************************************************************
-Sync all FTS cache before shutdown */
-static
-void
-srv_fts_close(void)
-/*===============*/
-{
- dict_table_t* table;
-
- for (table = UT_LIST_GET_FIRST(dict_sys->table_LRU);
- table; table = UT_LIST_GET_NEXT(table_LRU, table)) {
- fts_t* fts = table->fts;
-
- if (fts != NULL) {
- fts_sync_table(table);
- }
- }
-
- for (table = UT_LIST_GET_FIRST(dict_sys->table_non_LRU);
- table; table = UT_LIST_GET_NEXT(table_LRU, table)) {
- fts_t* fts = table->fts;
-
- if (fts != NULL) {
- fts_sync_table(table);
- }
- }
-}
-#endif
-
/** Shut down background threads that can generate undo log. */
void srv_shutdown_bg_undo_sources()
{
@@ -2487,7 +2457,7 @@ void innodb_shutdown()
}
ut_ad(dict_stats_event || !srv_was_started || srv_read_only_mode);
- ut_ad(dict_sys || !srv_was_started);
+ ut_ad(dict_sys.is_initialised() || !srv_was_started);
ut_ad(trx_sys.is_initialised() || !srv_was_started);
ut_ad(buf_dblwr || !srv_was_started || srv_read_only_mode
|| srv_force_recovery >= SRV_FORCE_NO_TRX_UNDO);
@@ -2516,7 +2486,7 @@ void innodb_shutdown()
and closing the data dictionary. */
#ifdef BTR_CUR_HASH_ADAPT
- if (dict_sys) {
+ if (dict_sys.is_initialised()) {
btr_search_disable(true);
}
#endif /* BTR_CUR_HASH_ADAPT */
@@ -2537,7 +2507,7 @@ void innodb_shutdown()
mutex_free(&srv_misc_tmpfile_mutex);
}
- dict_close();
+ dict_sys.close();
btr_search_sys_free();
/* 3. Free all InnoDB's own mutexes and the os_fast_mutexes inside
diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc
index 7ef6b88a9a9..157e9a342c9 100644
--- a/storage/innobase/trx/trx0trx.cc
+++ b/storage/innobase/trx/trx0trx.cc
@@ -580,10 +580,10 @@ trx_resurrect_table_locks(
if (dict_table_t* table = dict_table_open_on_id(
*i, FALSE, DICT_TABLE_OP_LOAD_TABLESPACE)) {
if (!table->is_readable()) {
- mutex_enter(&dict_sys->mutex);
+ mutex_enter(&dict_sys.mutex);
dict_table_close(table, TRUE, FALSE);
- dict_table_remove_from_cache(table);
- mutex_exit(&dict_sys->mutex);
+ dict_sys.remove(table);
+ mutex_exit(&dict_sys.mutex);
continue;
}
@@ -1279,7 +1279,7 @@ void trx_t::evict_table(table_id_t table_id)
ut_ad(UT_LIST_GET_LEN(table->locks) <= 1);
const bool locked = UT_LIST_GET_LEN(table->locks);
ut_ad(!locked || UT_LIST_GET_FIRST(table->locks)->trx == this);
- dict_table_remove_from_cache(table, true, locked);
+ dict_sys.remove(table, true, locked);
if (locked) {
UT_LIST_ADD_FIRST(lock.evicted_tables, table);
}