From 786b004972e635eb23f631661ba9927562ee2f3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 15 Nov 2019 14:55:38 +0200 Subject: [PATCH] Cleanup: More use of mtr_memo_type_t --- storage/innobase/btr/btr0cur.cc | 8 +++++--- storage/innobase/include/btr0btr.ic | 2 +- storage/innobase/include/mtr0mtr.h | 10 +++++----- storage/innobase/include/mtr0types.h | 3 +-- storage/innobase/mtr/mtr0mtr.cc | 6 ++++-- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/storage/innobase/btr/btr0cur.cc b/storage/innobase/btr/btr0cur.cc index 59f436605fc..20c5d0f7f3c 100644 --- a/storage/innobase/btr/btr0cur.cc +++ b/storage/innobase/btr/btr0cur.cc @@ -2345,7 +2345,9 @@ need_opposite_intention: ? RW_X_LATCH : RW_SX_LATCH, false, mtr); btr_assert_not_corrupted(child_block, index); } else { - ut_ad(mtr_memo_contains(mtr, block, upper_rw_latch)); + ut_ad(mtr_memo_contains(mtr, block, + static_cast + (upper_rw_latch))); btr_assert_not_corrupted(block, index); if (s_latch_by_caller) { @@ -2671,8 +2673,8 @@ btr_cur_open_at_index_side_func( ut_ad(latch_mode == BTR_SEARCH_TREE); ut_ad(s_latch_by_caller); ut_ad(upper_rw_latch == RW_S_LATCH); - - ut_ad(mtr_memo_contains(mtr, block, upper_rw_latch)); + ut_ad(mtr_memo_contains(mtr, block, + MTR_MEMO_PAGE_S_FIX)); if (s_latch_by_caller) { /* to exclude modifying tree operations diff --git a/storage/innobase/include/btr0btr.ic b/storage/innobase/include/btr0btr.ic index bc990f728e6..e06127efaa3 100644 --- a/storage/innobase/include/btr0btr.ic +++ b/storage/innobase/include/btr0btr.ic @@ -185,7 +185,7 @@ btr_leaf_page_release( ut_ad(!mtr_memo_contains(mtr, block, MTR_MEMO_MODIFY)); - ulint mode; + mtr_memo_type_t mode; switch (latch_mode) { case BTR_SEARCH_LEAF: mode = MTR_MEMO_PAGE_S_FIX; diff --git a/storage/innobase/include/mtr0mtr.h b/storage/innobase/include/mtr0mtr.h index f364730b21f..ee1e3eadd71 100644 --- a/storage/innobase/include/mtr0mtr.h +++ b/storage/innobase/include/mtr0mtr.h @@ -119,8 +119,8 @@ struct mtr_memo_slot_t { /** pointer to the object */ void* object; - /** type of the stored object (MTR_MEMO_S_LOCK, ...) */ - ulint type; + /** type of the stored object */ + mtr_memo_type_t type; }; /** Mini-transaction handle and buffer */ @@ -301,7 +301,7 @@ struct mtr_t { /** Release an object in the memo stack. @param object object - @param type object type: MTR_MEMO_S_LOCK, ... + @param type object type @return bool if lock released */ bool memo_release(const void* object, ulint type); /** Release a page latch. @@ -354,13 +354,13 @@ struct mtr_t { #ifdef UNIV_DEBUG /** Check if memo contains the given item. @param memo memo stack - @param object, object to search + @param object object to search @param type type of object @return true if contains */ static bool memo_contains( const mtr_buf_t* memo, const void* object, - ulint type) + mtr_memo_type_t type) MY_ATTRIBUTE((warn_unused_result)); /** Check if memo contains the given item. diff --git a/storage/innobase/include/mtr0types.h b/storage/innobase/include/mtr0types.h index bf7484b2337..7b5fd457d9f 100644 --- a/storage/innobase/include/mtr0types.h +++ b/storage/innobase/include/mtr0types.h @@ -255,8 +255,7 @@ mach_write_to_8(checkpoint_lsn). */ #define SIZE_OF_MLOG_CHECKPOINT 9 #ifndef UNIV_INNOCHECKSUM -/** Types for the mlock objects to store in the mtr memo; NOTE that the -first 3 values must be RW_S_LATCH, RW_X_LATCH, RW_NO_LATCH */ +/** Types for the mlock objects to store in the mtr_t::m_memo */ enum mtr_memo_type_t { MTR_MEMO_PAGE_S_FIX = RW_S_LATCH, diff --git a/storage/innobase/mtr/mtr0mtr.cc b/storage/innobase/mtr/mtr0mtr.cc index 9918d0bbc21..65fff8bb8e9 100644 --- a/storage/innobase/mtr/mtr0mtr.cc +++ b/storage/innobase/mtr/mtr0mtr.cc @@ -126,7 +126,7 @@ struct Find { mtr_memo_slot_t*m_slot; /** Type of the object to look for */ - ulint m_type; + const ulint m_type; /** The object instance to look for */ const void* m_object; @@ -728,7 +728,7 @@ bool mtr_t::memo_contains( const mtr_buf_t* memo, const void* object, - ulint type) + mtr_memo_type_t type) { Iterate iteration(Find(object, type)); if (memo->for_each_block_in_reverse(iteration)) { @@ -745,6 +745,8 @@ mtr_t::memo_contains( case MTR_MEMO_S_LOCK: ut_ad(rw_lock_own((rw_lock_t*) object, RW_LOCK_S)); break; + default: + break; } return(true);