From f02f1eda7efe336500c5f68fdfb091e54926a304 Mon Sep 17 00:00:00 2001 From: Eugene Kosov Date: Fri, 16 Feb 2018 22:15:51 +0300 Subject: [PATCH] review fixes --- storage/innobase/fut/fut0lst.cc | 2 +- storage/innobase/include/btr0btr.h | 23 ++++++++++++++++---- storage/innobase/include/btr0btr.ic | 26 ---------------------- storage/innobase/include/buf0buf.h | 5 +++-- storage/innobase/include/lock0lock.h | 2 +- storage/innobase/lock/lock0lock.cc | 32 ++++++++++++++-------------- 6 files changed, 40 insertions(+), 50 deletions(-) diff --git a/storage/innobase/fut/fut0lst.cc b/storage/innobase/fut/fut0lst.cc index fa09986e88fdf..3e77165ac319f 100644 --- a/storage/innobase/fut/fut0lst.cc +++ b/storage/innobase/fut/fut0lst.cc @@ -49,7 +49,7 @@ flst_add_to_empty( ut_ad(mtr_memo_contains_page_flagged(mtr, node, MTR_MEMO_PAGE_X_FIX | MTR_MEMO_PAGE_SX_FIX)); - ut_ad(!flst_get_len(base)); + ut_a(!flst_get_len(base)); buf_ptr_get_fsp_addr(node, &space, &node_addr); diff --git a/storage/innobase/include/btr0btr.h b/storage/innobase/include/btr0btr.h index b9e4df97c0f69..336ee68ee5917 100644 --- a/storage/innobase/include/btr0btr.h +++ b/storage/innobase/include/btr0btr.h @@ -37,6 +37,12 @@ Created 6/2/1994 Heikki Tuuri #include "btr0types.h" #include "gis0type.h" +#define BTR_MAX_NODE_LEVEL 50 /*!< Maximum B-tree page level + (not really a hard limit). + Used in debug assertions + in btr_page_set_level and + btr_page_get_level */ + /** Maximum record size which can be stored on a page, without using the special big record storage structure */ #define BTR_PAGE_MAX_REC_SIZE (UNIV_PAGE_SIZE / 2 - 200) @@ -285,13 +291,22 @@ btr_page_get_index_id( MY_ATTRIBUTE((warn_unused_result)); /********************************************************//** Gets the node level field in an index page. +@param[in] page index page @return level, leaf level == 0 */ UNIV_INLINE ulint -btr_page_get_level( -/*===================*/ - const page_t* page) /*!< in: index page */ - MY_ATTRIBUTE((warn_unused_result)); +btr_page_get_level(const page_t* page) +{ + ulint level; + + ut_ad(page); + + level = mach_read_from_2(page + PAGE_HEADER + PAGE_LEVEL); + + ut_ad(level <= BTR_MAX_NODE_LEVEL); + + return(level); +} MY_ATTRIBUTE((warn_unused_result)) /********************************************************//** Gets the next index page number. @return next page number */ diff --git a/storage/innobase/include/btr0btr.ic b/storage/innobase/include/btr0btr.ic index f5c22e081c8c8..d24458beace21 100644 --- a/storage/innobase/include/btr0btr.ic +++ b/storage/innobase/include/btr0btr.ic @@ -29,12 +29,6 @@ Created 6/2/1994 Heikki Tuuri #include "mtr0log.h" #include "page0zip.h" -#define BTR_MAX_NODE_LEVEL 50 /*!< Maximum B-tree page level - (not really a hard limit). - Used in debug assertions - in btr_page_set_level and - btr_page_get_level */ - /** Gets a buffer page and declares its latching order level. @param[in] page_id page id @param[in] mode latch mode @@ -143,26 +137,6 @@ btr_page_get_index_id( return(mach_read_from_8(page + PAGE_HEADER + PAGE_INDEX_ID)); } -/********************************************************//** -Gets the node level field in an index page. -@return level, leaf level == 0 */ -UNIV_INLINE -ulint -btr_page_get_level( -/*===================*/ - const page_t* page) /*!< in: index page */ -{ - ulint level; - - ut_ad(page); - - level = mach_read_from_2(page + PAGE_HEADER + PAGE_LEVEL); - - ut_ad(level <= BTR_MAX_NODE_LEVEL); - - return(level); -} - /********************************************************//** Sets the node level field in an index page. */ UNIV_INLINE diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h index 57f8daa1d735c..c456a86c9aeb2 100644 --- a/storage/innobase/include/buf0buf.h +++ b/storage/innobase/include/buf0buf.h @@ -2351,8 +2351,9 @@ Use these instead of accessing buf_pool->mutex directly. */ /** Get appropriate page_hash_lock. */ -inline rw_lock_t* -buf_page_hash_lock_get(const buf_pool_t* buf_pool, page_id_t page_id) +UNIV_INLINE +rw_lock_t* +buf_page_hash_lock_get(const buf_pool_t* buf_pool, const page_id_t& page_id) { return hash_get_lock(buf_pool->page_hash, page_id.fold()); } diff --git a/storage/innobase/include/lock0lock.h b/storage/innobase/include/lock0lock.h index 9c0099484964d..0e8c6a75f281c 100644 --- a/storage/innobase/include/lock0lock.h +++ b/storage/innobase/include/lock0lock.h @@ -555,7 +555,7 @@ lock_rec_find_set_bit( /*********************************************************************//** Checks if a lock request lock1 has to wait for request lock2. -@return true if lock1 has to wait for lock2 to be removed */ +@return whether lock1 has to wait for lock2 to be removed */ bool lock_has_to_wait( /*=============*/ diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc index a5102f3caf952..f48cd3aba182e 100644 --- a/storage/innobase/lock/lock0lock.cc +++ b/storage/innobase/lock/lock0lock.cc @@ -765,7 +765,7 @@ lock_rec_has_to_wait( || lock_mode_compatible( static_cast(LOCK_MODE_MASK & type_mode), lock_get_mode(lock2))) { - return(false); + return false; } /* We have somewhat complex rules when gap type record locks @@ -779,7 +779,7 @@ lock_rec_has_to_wait( different users can have conflicting lock types on gaps. */ - return(false); + return false; } if (!(type_mode & LOCK_INSERT_INTENTION) && lock_rec_get_gap(lock2)) { @@ -787,7 +787,7 @@ lock_rec_has_to_wait( /* Record lock (LOCK_ORDINARY or LOCK_REC_NOT_GAP does not need to wait for a gap type lock */ - return(false); + return false; } if ((type_mode & LOCK_GAP) && lock_rec_get_rec_not_gap(lock2)) { @@ -795,7 +795,7 @@ lock_rec_has_to_wait( /* Lock on gap does not need to wait for a LOCK_REC_NOT_GAP type lock */ - return(false); + return false; } if (lock_rec_get_insert_intention(lock2)) { @@ -811,7 +811,7 @@ lock_rec_has_to_wait( Also, insert intention locks do not disturb each other. */ - return(false); + return false; } if ((type_mode & LOCK_GAP || lock_rec_get_gap(lock2)) @@ -836,7 +836,7 @@ lock_rec_has_to_wait( transaction and retry it. But it can save some unnecessary rollbacks and retries. */ - return(false); + return false; } #ifdef WITH_WSREP @@ -881,7 +881,7 @@ lock_rec_has_to_wait( lock2->trx->mysql_thd); if (for_locking) { - return FALSE; + return false; } } } else { @@ -905,12 +905,12 @@ lock_rec_has_to_wait( << wsrep_thd_query( lock2->trx->mysql_thd); } - return FALSE; + return false; } } #endif /* WITH_WSREP */ - return(true); + return true; } /*********************************************************************//** @@ -930,24 +930,24 @@ lock_has_to_wait( if (lock1->trx == lock2->trx || lock_mode_compatible(lock_get_mode(lock1), lock_get_mode(lock2))) { - return(false); + return false; } if (lock_get_type_low(lock1) != LOCK_REC) { - return(true); + return true; } ut_ad(lock_get_type_low(lock2) == LOCK_REC); if (lock1->type_mode & (LOCK_PREDICATE | LOCK_PRDT_PAGE)) { - return(lock_prdt_has_to_wait(lock1->trx, lock1->type_mode, + return lock_prdt_has_to_wait(lock1->trx, lock1->type_mode, lock_get_prdt_from_lock(lock1), - lock2)); + lock2); } - return(lock_rec_has_to_wait( - false, lock1->trx, lock1->type_mode, lock2, - lock_rec_get_nth_bit(lock1, PAGE_HEAP_NO_SUPREMUM))); + return lock_rec_has_to_wait( + false, lock1->trx, lock1->type_mode, lock2, + lock_rec_get_nth_bit(lock1, PAGE_HEAP_NO_SUPREMUM)); } /*============== RECORD LOCK BASIC FUNCTIONS ============================*/