Commit 3b573c07 authored by Marko Mäkelä's avatar Marko Mäkelä

Clean up mtr_t::commit() further

memo_block_unfix(), memo_latch_release(): Merge to ReleaseLatches.

memo_slot_release(), ReleaseAll: Clean up the formatting.
parent abd45cdc
...@@ -30,9 +30,7 @@ Created 11/26/1995 Heikki Tuuri ...@@ -30,9 +30,7 @@ Created 11/26/1995 Heikki Tuuri
#include "buf0flu.h" #include "buf0flu.h"
#include "page0types.h" #include "page0types.h"
#include "mtr0log.h" #include "mtr0log.h"
#include "log0log.h"
#include "row0trunc.h" #include "row0trunc.h"
#include "log0recv.h" #include "log0recv.h"
/** Iterate over a memo block in reverse. */ /** Iterate over a memo block in reverse. */
...@@ -204,142 +202,83 @@ struct FindPage ...@@ -204,142 +202,83 @@ struct FindPage
/** Release latches and decrement the buffer fix count. /** Release latches and decrement the buffer fix count.
@param slot memo slot */ @param slot memo slot */
static static void memo_slot_release(mtr_memo_slot_t *slot)
void
memo_slot_release(mtr_memo_slot_t* slot)
{ {
switch (slot->type) { switch (slot->type) {
case MTR_MEMO_BUF_FIX: #ifdef UNIV_DEBUG
case MTR_MEMO_PAGE_S_FIX: default:
case MTR_MEMO_PAGE_SX_FIX: ut_ad(!"invalid type");
case MTR_MEMO_PAGE_X_FIX: {
buf_block_t* block;
block = reinterpret_cast<buf_block_t*>(slot->object);
buf_block_unfix(block);
buf_page_release_latch(block, slot->type);
break; break;
} case MTR_MEMO_MODIFY:
break;
#endif /* UNIV_DEBUG */
case MTR_MEMO_S_LOCK: case MTR_MEMO_S_LOCK:
rw_lock_s_unlock(reinterpret_cast<rw_lock_t*>(slot->object)); rw_lock_s_unlock(reinterpret_cast<rw_lock_t*>(slot->object));
break; break;
case MTR_MEMO_SX_LOCK: case MTR_MEMO_SX_LOCK:
rw_lock_sx_unlock(reinterpret_cast<rw_lock_t*>(slot->object)); rw_lock_sx_unlock(reinterpret_cast<rw_lock_t*>(slot->object));
break; break;
case MTR_MEMO_X_LOCK: case MTR_MEMO_X_LOCK:
rw_lock_x_unlock(reinterpret_cast<rw_lock_t*>(slot->object)); rw_lock_x_unlock(reinterpret_cast<rw_lock_t*>(slot->object));
break; break;
#ifdef UNIV_DEBUG
default:
ut_ad(slot->type == MTR_MEMO_MODIFY);
#endif /* UNIV_DEBUG */
}
slot->object = NULL;
}
/** Unfix a page, do not release the latches on the page.
@param slot memo slot */
static
void
memo_block_unfix(mtr_memo_slot_t* slot)
{
switch (slot->type) {
case MTR_MEMO_BUF_FIX: case MTR_MEMO_BUF_FIX:
case MTR_MEMO_PAGE_S_FIX: case MTR_MEMO_PAGE_S_FIX:
case MTR_MEMO_PAGE_SX_FIX:
case MTR_MEMO_PAGE_X_FIX: case MTR_MEMO_PAGE_X_FIX:
case MTR_MEMO_PAGE_SX_FIX: { buf_block_t *block= reinterpret_cast<buf_block_t*>(slot->object);
buf_block_unfix(reinterpret_cast<buf_block_t*>(slot->object)); buf_block_unfix(block);
buf_page_release_latch(block, slot->type);
break; break;
} }
slot->object= NULL;
}
case MTR_MEMO_S_LOCK: /** Release the latches acquired by the mini-transaction. */
case MTR_MEMO_X_LOCK: struct ReleaseLatches {
case MTR_MEMO_SX_LOCK: /** @return true always. */
break; bool operator()(mtr_memo_slot_t *slot) const
{
if (!slot->object)
return true;
switch (slot->type) {
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
default: default:
#endif /* UNIV_DEBUG */ ut_ad(!"invalid type");
break; break;
} case MTR_MEMO_MODIFY:
}
/** Release latches represented by a slot.
@param slot memo slot */
static
void
memo_latch_release(mtr_memo_slot_t* slot)
{
switch (slot->type) {
case MTR_MEMO_BUF_FIX:
case MTR_MEMO_PAGE_S_FIX:
case MTR_MEMO_PAGE_SX_FIX:
case MTR_MEMO_PAGE_X_FIX: {
buf_block_t* block;
block = reinterpret_cast<buf_block_t*>(slot->object);
memo_block_unfix(slot);
buf_page_release_latch(block, slot->type);
slot->object = NULL;
break; break;
} #endif /* UNIV_DEBUG */
case MTR_MEMO_S_LOCK: case MTR_MEMO_S_LOCK:
rw_lock_s_unlock(reinterpret_cast<rw_lock_t*>(slot->object)); rw_lock_s_unlock(reinterpret_cast<rw_lock_t*>(slot->object));
slot->object = NULL;
break; break;
case MTR_MEMO_X_LOCK: case MTR_MEMO_X_LOCK:
rw_lock_x_unlock(reinterpret_cast<rw_lock_t*>(slot->object)); rw_lock_x_unlock(reinterpret_cast<rw_lock_t*>(slot->object));
slot->object = NULL;
break; break;
case MTR_MEMO_SX_LOCK: case MTR_MEMO_SX_LOCK:
rw_lock_sx_unlock(reinterpret_cast<rw_lock_t*>(slot->object)); rw_lock_sx_unlock(reinterpret_cast<rw_lock_t*>(slot->object));
slot->object = NULL;
break; break;
case MTR_MEMO_BUF_FIX:
#ifdef UNIV_DEBUG case MTR_MEMO_PAGE_S_FIX:
default: case MTR_MEMO_PAGE_SX_FIX:
ut_ad(slot->type == MTR_MEMO_MODIFY); case MTR_MEMO_PAGE_X_FIX:
buf_block_t *block= reinterpret_cast<buf_block_t*>(slot->object);
slot->object = NULL; buf_block_unfix(block);
#endif /* UNIV_DEBUG */ buf_page_release_latch(block, slot->type);
} break;
}
/** Release the latches acquired by the mini-transaction. */
struct ReleaseLatches {
/** @return true always. */
bool operator()(mtr_memo_slot_t* slot) const
{
if (slot->object != NULL) {
memo_latch_release(slot);
} }
slot->object= NULL;
return(true); return true;
} }
}; };
/** Release the latches and blocks acquired by the mini-transaction. */ /** Release the latches and blocks acquired by the mini-transaction. */
struct ReleaseAll { struct ReleaseAll {
/** @return true always. */ /** @return true always. */
bool operator()(mtr_memo_slot_t* slot) const bool operator()(mtr_memo_slot_t *slot) const
{ {
if (slot->object != NULL) { if (slot->object)
memo_slot_release(slot); memo_slot_release(slot);
} return true;
return(true);
} }
}; };
...@@ -349,7 +288,7 @@ struct DebugCheck { ...@@ -349,7 +288,7 @@ struct DebugCheck {
/** @return true always. */ /** @return true always. */
bool operator()(const mtr_memo_slot_t* slot) const bool operator()(const mtr_memo_slot_t* slot) const
{ {
ut_a(slot->object == NULL); ut_ad(!slot->object);
return(true); return(true);
} }
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment