Commit 8a4ca339 authored by Marko Mäkelä's avatar Marko Mäkelä

Cleanup: Declare trx_weight_ge() inline

parent bd52f1a2
......@@ -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" */
......
......@@ -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*
......
......@@ -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 */
......
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