Commit 462cb666 authored by Marko Mäkelä's avatar Marko Mäkelä

Cleanup: Replace lock_mode_string() with a table lookup

parent e71e6133
......@@ -72,7 +72,19 @@ ib_lock_t::type_mode_string() const
{
std::ostringstream sout;
sout << type_string();
sout << " | " << lock_mode_string(mode());
static_assert(LOCK_MODE_MASK == 7, "compatibility");
static_assert(LOCK_IS == 0, "compatibility");
static_assert(LOCK_IX == 1, "compatibility");
static_assert(LOCK_S == 2, "compatibility");
static_assert(LOCK_X == 3, "compatibility");
static_assert(LOCK_AUTO_INC == 4, "compatibility");
static_assert(LOCK_NONE == 5, "compatibility");
static_assert(LOCK_NONE_UNSET == 7, "compatibility");
const char * const modes[8] = {
"IS", "IX", "S", "X", "AUTO_INC", "NONE", "?", "NONE_UNSET"
};
sout << " | LOCK_" << modes[mode()];
if (is_record_not_gap()) {
sout << " | LOCK_REC_NOT_GAP";
......
......@@ -46,35 +46,9 @@ enum lock_mode {
in an exclusive mode */
LOCK_NONE, /* this is used elsewhere to note consistent read */
LOCK_NUM = LOCK_NONE, /* number of lock modes */
LOCK_NONE_UNSET = 255
LOCK_NONE_UNSET = 7
};
/** Convert the given enum value into string.
@param[in] mode the lock mode
@return human readable string of the given enum value */
inline
const char* lock_mode_string(enum lock_mode mode)
{
switch (mode) {
case LOCK_IS:
return("LOCK_IS");
case LOCK_IX:
return("LOCK_IX");
case LOCK_S:
return("LOCK_S");
case LOCK_X:
return("LOCK_X");
case LOCK_AUTO_INC:
return("LOCK_AUTO_INC");
case LOCK_NONE:
return("LOCK_NONE");
case LOCK_NONE_UNSET:
return("LOCK_NONE_UNSET");
default:
ut_error;
}
}
/** A table lock */
struct lock_table_t {
dict_table_t* table; /*!< database table in dictionary
......@@ -121,7 +95,7 @@ operator<<(std::ostream& out, const lock_rec_t& lock)
return(lock.print(out));
}
#define LOCK_MODE_MASK 0xFUL /*!< mask used to extract mode from the
#define LOCK_MODE_MASK 0x7 /*!< mask used to extract mode from the
type_mode field in a lock */
/** Lock types */
/* @{ */
......
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