diff --git a/storage/innobase/include/trx0trx.h b/storage/innobase/include/trx0trx.h index b97cf6f1f3e..9d1c574e04d 100644 --- a/storage/innobase/include/trx0trx.h +++ b/storage/innobase/include/trx0trx.h @@ -328,16 +328,6 @@ is estimated as the number of altered rows + the number of locked rows. @return transaction weight */ #define TRX_WEIGHT(t) ((t)->undo_no + UT_LIST_GET_LEN((t)->lock.trx_locks)) -/*******************************************************************//** -Compares the "weight" (or size) of two transactions. Transactions that -have edited non-transactional tables are considered heavier than ones -that have not. -@return true if weight(a) >= weight(b) */ -bool -trx_weight_ge( -/*==========*/ - const trx_t* a, /*!< in: the transaction to be compared */ - const trx_t* b); /*!< in: the transaction to be compared */ /* Maximum length of a string that can be returned by trx_get_que_state_str(). */ #define TRX_QUE_STATE_STR_MAX_LEN 12 /* "ROLLING BACK" */ diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc index 1eaa562329f..97f1a670c6c 100644 --- a/storage/innobase/lock/lock0lock.cc +++ b/storage/innobase/lock/lock0lock.cc @@ -6093,6 +6093,17 @@ DeadlockChecker::notify(const lock_t* lock) const DBUG_PRINT("ib_lock", ("deadlock detected")); } +/** Compare the "weight" (or size) of two transactions. Transactions that +have edited non-transactional tables are considered heavier than ones +that have not. +@return whether a is heavier than b */ +inline bool trx_weight_ge(const trx_t *a, const trx_t *b) +{ + bool a_notrans= a->mysql_thd && thd_has_edited_nontrans_tables(a->mysql_thd); + bool b_notrans= b->mysql_thd && thd_has_edited_nontrans_tables(b->mysql_thd); + return a_notrans != b_notrans ? a_notrans : TRX_WEIGHT(a) >= TRX_WEIGHT(b); +} + /** Select the victim transaction that should be rolledback. @return victim transaction */ const trx_t* diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc index fb535991210..1d4452041c3 100644 --- a/storage/innobase/trx/trx0trx.cc +++ b/storage/innobase/trx/trx0trx.cc @@ -1902,41 +1902,6 @@ trx_print( n_rec_locks, n_trx_locks, heap_size); } -/*******************************************************************//** -Compares the "weight" (or size) of two transactions. Transactions that -have edited non-transactional tables are considered heavier than ones -that have not. -@return TRUE if weight(a) >= weight(b) */ -bool -trx_weight_ge( -/*==========*/ - const trx_t* a, /*!< in: transaction to be compared */ - const trx_t* b) /*!< in: transaction to be compared */ -{ - ibool a_notrans_edit; - ibool b_notrans_edit; - - /* If mysql_thd is NULL for a transaction we assume that it has - not edited non-transactional tables. */ - - a_notrans_edit = a->mysql_thd != NULL - && thd_has_edited_nontrans_tables(a->mysql_thd); - - b_notrans_edit = b->mysql_thd != NULL - && thd_has_edited_nontrans_tables(b->mysql_thd); - - if (a_notrans_edit != b_notrans_edit) { - - return(a_notrans_edit); - } - - /* Either both had edited non-transactional tables or both had - not, we fall back to comparing the number of altered/locked - rows. */ - - return(TRX_WEIGHT(a) >= TRX_WEIGHT(b)); -} - /** Prepare a transaction. @return log sequence number that makes the XA PREPARE durable @retval 0 if no changes needed to be made durable */