summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2019-12-05 15:04:06 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2019-12-05 15:04:06 +0200
commit95243f4168bf34ab566d5f85d86acbebac488613 (patch)
tree6d967d8ba6e1c7825a2412d121b65b8e1ed6a5e4
parent1c8a6843be07c5a4d1024e9e324c633616eab774 (diff)
downloadmariadb-git-95243f4168bf34ab566d5f85d86acbebac488613.tar.gz
Cleanup: more inline functions; formatting
-rw-r--r--storage/innobase/dict/dict0dict.cc25
-rw-r--r--storage/innobase/fts/fts0opt.cc35
-rw-r--r--storage/innobase/include/dict0dict.h18
-rw-r--r--storage/innobase/include/row0purge.h47
-rw-r--r--storage/innobase/include/trx0purge.h4
-rw-r--r--storage/innobase/include/trx0rec.h11
-rw-r--r--storage/innobase/row/row0mysql.cc6
-rw-r--r--storage/innobase/row/row0vers.cc2
-rw-r--r--storage/innobase/trx/trx0purge.cc18
-rw-r--r--storage/innobase/trx/trx0rec.cc9
10 files changed, 83 insertions, 92 deletions
diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc
index 2d8f78ba2db..76125bc4e95 100644
--- a/storage/innobase/dict/dict0dict.cc
+++ b/storage/innobase/dict/dict0dict.cc
@@ -207,17 +207,6 @@ dict_remove_db_name(
return(s + 1);
}
-/** Get the database name length in a table name.
-@param[in] name table name in the form of dbname '/' tablename
-@return database name length */
-ulint dict_get_db_name_len(const char* name)
-{
- if (const char* s= strchr(name, '/'))
- return ulint(s - name);
-
- return 0;
-}
-
/** Open a persistent table.
@param[in] table_id persistent table identifier
@param[in] ignore_err errors to ignore
@@ -733,30 +722,30 @@ dict_index_get_nth_field_pos(
}
/** Parse the table file name into table name and database name.
-@param[in] tbl_name InnoDB table name
+@param[in] name InnoDB table name
@param[in,out] mysql_db_name database name buffer
@param[in,out] mysql_tbl_name table name buffer
@param[out] db_name_len database name length
@param[out] tbl_name_len table name length
@return true if the table name is parse properly. */
-bool dict_parse_tbl_name(const char *tbl_name,
+bool dict_parse_tbl_name(const table_name_t& name,
char (&mysql_db_name)[NAME_LEN + 1],
char (&mysql_tbl_name)[NAME_LEN + 1],
size_t *db_name_len, size_t *tbl_name_len)
{
- const size_t db_len= dict_get_db_name_len(tbl_name);
+ const size_t db_len= name.dblen();
char db_buf[MAX_DATABASE_NAME_LEN + 1];
char tbl_buf[MAX_TABLE_NAME_LEN + 1];
ut_ad(db_len > 0);
ut_ad(db_len <= MAX_DATABASE_NAME_LEN);
- memcpy(db_buf, tbl_name, db_len);
+ memcpy(db_buf, name.m_name, db_len);
db_buf[db_len]= 0;
- size_t tbl_len= strlen(tbl_name) - db_len - 1;
- memcpy(tbl_buf, tbl_name + db_len + 1, tbl_len);
- tbl_buf[tbl_len]= 0;
+ size_t tbl_len= strlen(name.m_name + db_len);
+ memcpy(tbl_buf, name.m_name + db_len + 1, tbl_len);
+ tbl_len--;
*db_name_len= db_len;
*tbl_name_len= tbl_len;
diff --git a/storage/innobase/fts/fts0opt.cc b/storage/innobase/fts/fts0opt.cc
index 75c60505de9..ab4ba8f852e 100644
--- a/storage/innobase/fts/fts0opt.cc
+++ b/storage/innobase/fts/fts0opt.cc
@@ -45,8 +45,8 @@ static tpool::timer* timer;
static tpool::task_group task_group(1);
static tpool::task task(fts_optimize_callback,0, &task_group);
-/** FTS optimize thread */
-THD* fts_opt_thd;
+/** FTS optimize thread, for MDL acquisition */
+static THD *fts_opt_thd;
/** The FTS vector to store fts_slot_t */
static ib_vector_t* fts_slots;
@@ -2789,22 +2789,20 @@ static bool fts_is_sync_needed()
}
/** Sync fts cache of a table
-@param[in,out] table table to be synced
-@param[in] fts_opt_thread fts optimize thread
-@param[in] process_message processing messages from fts_optimize_wq */
-static void fts_optimize_sync_table(dict_table_t* table,
- THD* fts_opt_thread,
- bool process_message=false)
+@param[in,out] table table to be synced
+@param[in] process_message processing messages from fts_optimize_wq */
+static void fts_optimize_sync_table(dict_table_t *table,
+ bool process_message= false)
{
- MDL_ticket* mdl_ticket = NULL;
- dict_table_t* sync_table = dict_acquire_mdl_shared<true>(
- table, fts_opt_thread, &mdl_ticket);
+ MDL_ticket* mdl_ticket= nullptr;
+ dict_table_t *sync_table= dict_acquire_mdl_shared<true>(table, fts_opt_thd,
+ &mdl_ticket);
if (!sync_table)
return;
- if (sync_table->fts && sync_table->fts->cache
- && fil_table_accessible(sync_table))
+ if (sync_table->fts && sync_table->fts->cache &&
+ fil_table_accessible(sync_table))
{
fts_sync_table(sync_table, false);
if (process_message)
@@ -2818,8 +2816,7 @@ static void fts_optimize_sync_table(dict_table_t* table,
DBUG_EXECUTE_IF("ib_optimize_wq_hang", os_thread_sleep(6000000););
if (mdl_ticket)
- dict_table_close(sync_table, false, false,
- fts_opt_thread, mdl_ticket);
+ dict_table_close(sync_table, false, false, fts_opt_thd, mdl_ticket);
}
/**********************************************************************//**
@@ -2911,7 +2908,7 @@ static void fts_optimize_callback(void *)
fts_optimize_sync_table(
static_cast<dict_table_t*>(msg->ptr),
- fts_opt_thd, true);
+ true);
break;
default:
@@ -2931,8 +2928,7 @@ static void fts_optimize_callback(void *)
ib_vector_get(fts_slots, i));
if (slot->table) {
- fts_optimize_sync_table(
- slot->table, fts_opt_thd);
+ fts_optimize_sync_table(slot->table);
}
}
}
@@ -2970,8 +2966,7 @@ fts_optimize_init(void)
heap_alloc = ib_heap_allocator_create(heap);
fts_slots = ib_vector_create(heap_alloc, sizeof(fts_slot_t), 4);
- fts_opt_thd = innobase_create_background_thd(
- "InnoDB fts optimize thread");
+ fts_opt_thd = innobase_create_background_thd("InnoDB FTS optimizer");
/* Add fts tables to fts_slots which could be skipped
during dict_load_table_one() because fts_optimize_thread
wasn't even started. */
diff --git a/storage/innobase/include/dict0dict.h b/storage/innobase/include/dict0dict.h
index 5fdc9ccfe0a..de0bc180307 100644
--- a/storage/innobase/include/dict0dict.h
+++ b/storage/innobase/include/dict0dict.h
@@ -41,11 +41,19 @@ extern bool innodb_index_stats_not_found;
/** the first table or index ID for other than hard-coded system tables */
constexpr uint8_t DICT_HDR_FIRST_ID= 10;
+
/** Get the database name length in a table name.
-@param[in] name table name in the form of dbname '/' tablename
+@param name filename-safe encoded table name "dbname/tablename"
@return database name length */
-ulint dict_get_db_name_len(const char* name)
- MY_ATTRIBUTE((nonnull, warn_unused_result));
+inline size_t dict_get_db_name_len(const char *name)
+{
+ /* table_name_t::dblen() would assert that '/' is contained */
+ if (const char* s= strchr(name, '/'))
+ return size_t(s - name);
+
+ return 0;
+}
+
/*********************************************************************//**
Open a table from its database and table name, this is currently used by
@@ -119,13 +127,13 @@ enum dict_table_op_t {
/** Parse the table file name into table name and database name.
-@param[in] tbl_name InnoDB table name
+@param[in] name InnoDB table name
@param[in,out] mysql_db_name database name buffer
@param[in,out] mysql_tbl_name table name buffer
@param[out] db_name_len database name length
@param[out] tbl_name_len table name length
@return true if the table name is parse properly. */
-bool dict_parse_tbl_name(const char *tbl_name,
+bool dict_parse_tbl_name(const table_name_t &name,
char (&mysql_db_name)[NAME_LEN + 1],
char (&mysql_tbl_name)[NAME_LEN + 1],
size_t *db_name_len, size_t *tbl_name_len)
diff --git a/storage/innobase/include/row0purge.h b/storage/innobase/include/row0purge.h
index fb21d6ca8a5..88da48ead1d 100644
--- a/storage/innobase/include/row0purge.h
+++ b/storage/innobase/include/row0purge.h
@@ -196,28 +196,29 @@ public:
def_trx_id = limit;
}
- /** Start processing an undo log record. */
- void start()
- {
- ut_ad(in_progress);
- DBUG_ASSERT(common.type == QUE_NODE_PURGE);
-
- row = NULL;
- ref = NULL;
- index = NULL;
- update = NULL;
- found_clust = FALSE;
- rec_type = ULINT_UNDEFINED;
- cmpl_info = ULINT_UNDEFINED;
- if (!purge_thd)
- purge_thd = current_thd;
- }
+ /** Start processing an undo log record. */
+ void start()
+ {
+ ut_ad(in_progress);
+ DBUG_ASSERT(common.type == QUE_NODE_PURGE);
+
+ row= nullptr;
+ ref= nullptr;
+ index= nullptr;
+ update= nullptr;
+ found_clust= FALSE;
+ rec_type= ULINT_UNDEFINED;
+ cmpl_info= ULINT_UNDEFINED;
+ if (!purge_thd)
+ purge_thd= current_thd;
+ }
+
/** Close the existing table and release the MDL for it. */
void close_table()
{
last_table_id= 0;
- if (table == NULL)
+ if (!table)
{
ut_ad(!mdl_ticket);
return;
@@ -225,10 +226,11 @@ public:
innobase_reset_background_thd(purge_thd);
dict_table_close(table, false, false, purge_thd, mdl_ticket);
- table= NULL;
- mdl_ticket= NULL;
+ table= nullptr;
+ mdl_ticket= nullptr;
}
+
/** Retail mdl for the table id.
@param[in] table_id table id to be processed
@return true if retain mdl */
@@ -237,7 +239,7 @@ public:
ut_ad(table_id);
if (last_table_id == table_id && mdl_hold_recs < 100)
{
- ut_ad(table != NULL);
+ ut_ad(table);
mdl_hold_recs++;
return true;
}
@@ -247,6 +249,7 @@ public:
return false;
}
+
/** Reset the state at end
@return the query graph parent */
que_node_t* end()
@@ -254,8 +257,8 @@ public:
DBUG_ASSERT(common.type == QUE_NODE_PURGE);
close_table();
undo_recs.clear();
- ut_d(in_progress = false);
- purge_thd = NULL;
+ ut_d(in_progress= false);
+ purge_thd= nullptr;
mem_heap_empty(heap);
return common.parent;
}
diff --git a/storage/innobase/include/trx0purge.h b/storage/innobase/include/trx0purge.h
index 0d2820c3270..ceecb369337 100644
--- a/storage/innobase/include/trx0purge.h
+++ b/storage/innobase/include/trx0purge.h
@@ -213,7 +213,7 @@ public:
} truncate;
/** Heap for reading the undo log records */
- mem_heap_t* m_heap;
+ mem_heap_t* heap;
/**
Constructor.
@@ -221,7 +221,7 @@ public:
uninitialised. Real initialisation happens in create().
*/
- purge_sys_t(): m_enabled(false), m_heap(NULL) {}
+ purge_sys_t(): m_enabled(false), heap(nullptr) {}
/** Create the instance */
void create();
diff --git a/storage/innobase/include/trx0rec.h b/storage/innobase/include/trx0rec.h
index c4b9cf70131..159f7331daf 100644
--- a/storage/innobase/include/trx0rec.h
+++ b/storage/innobase/include/trx0rec.h
@@ -327,10 +327,15 @@ record */
/** The search tuple corresponding to TRX_UNDO_INSERT_METADATA */
extern const dtuple_t trx_undo_metadata;
-/** Get the table id from the undo log record
-@param[in] undo_rec Undo log record
+/** Read the table id from an undo log record.
+@param[in] rec Undo log record
@return table id stored as a part of undo log record */
-table_id_t trx_undo_rec_get_table_id(const trx_undo_rec_t *undo_rec);
+inline table_id_t trx_undo_rec_get_table_id(const trx_undo_rec_t *rec)
+{
+ rec+= 3;
+ mach_read_next_much_compressed(&rec);
+ return mach_read_next_much_compressed(&rec);
+}
#include "trx0rec.ic"
diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc
index a7d9a6c4975..fecb6203f2b 100644
--- a/storage/innobase/row/row0mysql.cc
+++ b/storage/innobase/row/row0mysql.cc
@@ -3506,9 +3506,9 @@ row_drop_table_for_mysql(
defer:
/* Rename #sql2 to #sql-ib if table has open ref count
while dropping the table. This scenario can happen
- when purge thread is waiting for dict_sys->mutex to
- close the table. But drop table table acquires
- dict_sys->mutex. */
+ when purge thread is waiting for dict_sys.mutex so
+ that it could close the table. But drop table acquires
+ dict_sys.mutex. */
if (!is_temp_name
|| strstr(table->name.m_name, "/#sql2")) {
heap = mem_heap_create(FN_REFLEN);
diff --git a/storage/innobase/row/row0vers.cc b/storage/innobase/row/row0vers.cc
index 847a8c10ef1..8057d14b281 100644
--- a/storage/innobase/row/row0vers.cc
+++ b/storage/innobase/row/row0vers.cc
@@ -466,7 +466,7 @@ row_vers_build_clust_v_col(
&record,
&vcol_storage);
- ut_ad(maria_table != NULL);
+ ut_ad(maria_table);
for (ulint i = 0; i < dict_index_get_n_fields(index); i++) {
const dict_field_t* ind_field = dict_index_get_nth_field(
diff --git a/storage/innobase/trx/trx0purge.cc b/storage/innobase/trx/trx0purge.cc
index e5c09b4756a..f71e3b69a38 100644
--- a/storage/innobase/trx/trx0purge.cc
+++ b/storage/innobase/trx/trx0purge.cc
@@ -160,7 +160,7 @@ purge_graph_build()
void purge_sys_t::create()
{
ut_ad(this == &purge_sys);
- ut_ad(!m_heap);
+ ut_ad(!heap);
ut_ad(!enabled());
m_paused= 0;
query= purge_graph_build();
@@ -174,14 +174,14 @@ void purge_sys_t::create()
mutex_create(LATCH_ID_PURGE_SYS_PQ, &pq_mutex);
truncate.current= NULL;
truncate.last= NULL;
- m_heap= mem_heap_create(4096);
+ heap= mem_heap_create(4096);
}
/** Close the purge subsystem on shutdown. */
void purge_sys_t::close()
{
ut_ad(this == &purge_sys);
- if (!m_heap)
+ if (!heap)
return;
ut_ad(!enabled());
@@ -193,8 +193,8 @@ void purge_sys_t::close()
trx_free(trx);
rw_lock_free(&latch);
mutex_free(&pq_mutex);
- mem_heap_free(m_heap);
- m_heap= NULL;
+ mem_heap_free(heap);
+ heap= nullptr;
}
/*================ UNDO LOG HISTORY LIST =============================*/
@@ -1136,9 +1136,8 @@ trx_purge_attach_undo_recs(ulint n_purge_threads)
i = 0;
const ulint batch_size = srv_purge_batch_size;
- mem_heap_t* heap = purge_sys.m_heap;
std::map<table_id_t, purge_node_t*> table_id_map;
- mem_heap_empty(heap);
+ mem_heap_empty(purge_sys.heap);
while (UNIV_LIKELY(srv_undo_sources) || !srv_fast_shutdown) {
purge_node_t* node;
@@ -1151,7 +1150,7 @@ trx_purge_attach_undo_recs(ulint n_purge_threads)
ut_a(que_node_get_type(node) == QUE_NODE_PURGE);
purge_rec = static_cast<trx_purge_rec_t*>(
- mem_heap_zalloc(heap, sizeof(*purge_rec)));
+ mem_heap_zalloc(purge_sys.heap, sizeof(*purge_rec)));
/* Track the max {trx_id, undo_no} for truncating the
UNDO logs once we have purged the records. */
@@ -1162,7 +1161,8 @@ trx_purge_attach_undo_recs(ulint n_purge_threads)
/* Fetch the next record, and advance the purge_sys.tail. */
purge_rec->undo_rec = trx_purge_fetch_next_rec(
- &purge_rec->roll_ptr, &n_pages_handled, heap);
+ &purge_rec->roll_ptr, &n_pages_handled,
+ purge_sys.heap);
if (purge_rec->undo_rec == NULL) {
break;
diff --git a/storage/innobase/trx/trx0rec.cc b/storage/innobase/trx/trx0rec.cc
index 2628d4841fc..04ee4428a91 100644
--- a/storage/innobase/trx/trx0rec.cc
+++ b/storage/innobase/trx/trx0rec.cc
@@ -2589,12 +2589,3 @@ trx_undo_read_v_cols(
ut_ad(ptr == end_ptr);
}
-
-/** Get the table id from the undo log record.
-@return table id stored as a part of undo log record */
-table_id_t trx_undo_rec_get_table_id(const trx_undo_rec_t* undo_rec)
-{
- const byte* ptr = undo_rec + 3;
- mach_read_next_much_compressed(&ptr);
- return mach_read_next_much_compressed(&ptr);
-}