diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2021-03-01 15:14:25 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2021-03-01 15:14:25 +0200 |
commit | 89227a7c330d265dac425ab5f52e914e73f21891 (patch) | |
tree | f4f0bc9694df57d5a48acf4240778922e0b66e13 | |
parent | 727a2f963b4bdcea34a1aa823cd02a29d72fbb03 (diff) | |
download | mariadb-git-89227a7c330d265dac425ab5f52e914e73f21891.tar.gz |
Cleanup: Remove some lock accessor functions
-rw-r--r-- | storage/innobase/include/lock0lock.h | 23 | ||||
-rw-r--r-- | storage/innobase/lock/lock0lock.cc | 54 | ||||
-rw-r--r-- | storage/innobase/trx/trx0i_s.cc | 30 |
3 files changed, 20 insertions, 87 deletions
diff --git a/storage/innobase/include/lock0lock.h b/storage/innobase/include/lock0lock.h index b4bc8adab47..2d178f8cbc9 100644 --- a/storage/innobase/include/lock0lock.h +++ b/storage/innobase/include/lock0lock.h @@ -481,29 +481,6 @@ lock_number_of_tables_locked( const trx_lock_t* trx_lock) /*!< in: transaction locks */ MY_ATTRIBUTE((warn_unused_result)); -/*******************************************************************//** -Gets the id of the table on which the lock is. -@return id of the table */ -table_id_t -lock_get_table_id( -/*==============*/ - const lock_t* lock); /*!< in: lock */ - -/** Determine which table a lock is associated with. -@param[in] lock the lock -@return name of the table */ -const table_name_t& -lock_get_table_name( - const lock_t* lock); - -/*******************************************************************//** -For a record lock, gets the index on which the lock is. -@return index */ -const dict_index_t* -lock_rec_get_index( -/*===============*/ - const lock_t* lock); /*!< in: lock */ - /** Check if there are any locks on a table. @return true if table has either table or record locks. */ bool lock_table_has_locks(dict_table_t *table); diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc index 6fb21740655..b85d0fae876 100644 --- a/storage/innobase/lock/lock0lock.cc +++ b/storage/innobase/lock/lock0lock.cc @@ -5358,60 +5358,6 @@ static void lock_release_autoinc_locks(trx_t *trx, bool owns_wait_mutex) } } -/*******************************************************************//** -Gets the table on which the lock is. -@return table */ -UNIV_INLINE -dict_table_t* -lock_get_table( -/*===========*/ - const lock_t* lock) /*!< in: lock */ -{ - if (lock->is_table()) - return lock->un_member.tab_lock.table; - - ut_ad(lock->index->is_primary() || !dict_index_is_online_ddl(lock->index)); - return lock->index->table; -} - -/*******************************************************************//** -Gets the id of the table on which the lock is. -@return id of the table */ -table_id_t -lock_get_table_id( -/*==============*/ - const lock_t* lock) /*!< in: lock */ -{ - dict_table_t* table = lock_get_table(lock); - ut_ad(!table->is_temporary()); - return(table->id); -} - -/** Determine which table a lock is associated with. -@param[in] lock the lock -@return name of the table */ -const table_name_t& -lock_get_table_name( - const lock_t* lock) -{ - return(lock_get_table(lock)->name); -} - -/*******************************************************************//** -For a record lock, gets the index on which the lock is. -@return index */ -const dict_index_t* -lock_rec_get_index( -/*===============*/ - const lock_t* lock) /*!< in: lock */ -{ - ut_ad(!lock->is_table()); - ut_ad(dict_index_is_clust(lock->index) || - !dict_index_is_online_ddl(lock->index)); - - return lock->index; -} - /** Cancel a waiting lock request and release possibly waiting transactions */ static void lock_cancel_waiting_and_release(lock_t *lock) { diff --git a/storage/innobase/trx/trx0i_s.cc b/storage/innobase/trx/trx0i_s.cc index 1754bafd599..17b7f6c4701 100644 --- a/storage/innobase/trx/trx0i_s.cc +++ b/storage/innobase/trx/trx0i_s.cc @@ -618,7 +618,6 @@ fill_lock_data( const buf_block_t* block; const page_t* page; const rec_t* rec; - const dict_index_t* index; ulint n_fields; mem_heap_t* heap; rec_offs offsets_onstack[REC_OFFS_NORMAL_SIZE]; @@ -647,7 +646,8 @@ fill_lock_data( rec = page_find_rec_with_heap_no(page, heap_no); - index = lock_rec_get_index(lock); + const dict_index_t* index = lock->index; + ut_ad(index->is_primary() || !dict_index_is_online_ddl(index)); n_fields = dict_index_get_n_unique(index); @@ -689,6 +689,15 @@ fill_lock_data( return(TRUE); } +/** @return the table of a lock */ +static const dict_table_t *lock_get_table(const lock_t &lock) +{ + if (lock.is_table()) + return lock.un_member.tab_lock.table; + ut_ad(lock.index->is_primary() || !dict_index_is_online_ddl(lock.index)); + return lock.index->table; +} + /*******************************************************************//** Fills i_s_locks_row_t object. Returns its first argument. If memory can not be allocated then FALSE is returned. @@ -703,9 +712,8 @@ static bool fill_locks_row( volatile strings */ { row->lock_trx_id = lock->trx->id; - const bool is_table = lock->is_table(); const bool is_gap_lock = lock->is_gap(); - ut_ad(!is_gap_lock || !is_table); + ut_ad(!is_gap_lock || !lock->is_table()); switch (lock->mode()) { case LOCK_S: row->lock_mode = uint8_t(1 + is_gap_lock); @@ -727,8 +735,10 @@ static bool fill_locks_row( row->lock_mode = 0; } + const dict_table_t* table= lock_get_table(*lock); + row->lock_table = ha_storage_put_str_memlim( - cache->storage, lock_get_table_name(lock).m_name, + cache->storage, table->name.m_name, MAX_ALLOWED_FOR_STORAGE(cache)); /* memory could not be allocated */ @@ -737,9 +747,9 @@ static bool fill_locks_row( return false; } - if (!is_table) { + if (!lock->is_table()) { row->lock_index = ha_storage_put_str_memlim( - cache->storage, lock_rec_get_index(lock)->name, + cache->storage, lock->index->name, MAX_ALLOWED_FOR_STORAGE(cache)); /* memory could not be allocated */ @@ -765,7 +775,7 @@ static bool fill_locks_row( row->lock_data = NULL; } - row->lock_table_id = lock_get_table_id(lock); + row->lock_table_id = table->id; row->hash_chain.value = row; ut_ad(i_s_locks_row_validate(row)); @@ -832,7 +842,7 @@ fold_lock( it fails. */ ut_a(heap_no == 0xFFFF); - ret = (ulint) lock_get_table_id(lock); + ret = (ulint) lock_get_table(*lock)->id; } return(ret); @@ -869,7 +879,7 @@ locks_row_eq_lock( ut_a(heap_no == 0xFFFF); return(row->lock_trx_id == lock->trx->id - && row->lock_table_id == lock_get_table_id(lock)); + && row->lock_table_id == lock_get_table(*lock)->id); } #endif } |