Skip to content

Commit

Permalink
Cleanup: Declare trx_weight_ge() inline
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-m committed Jan 5, 2021
1 parent bd52f1a commit 8a4ca33
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 45 deletions.
10 changes: 0 additions & 10 deletions storage/innobase/include/trx0trx.h
Original file line number Diff line number Diff line change
Expand Up @@ -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" */
Expand Down
11 changes: 11 additions & 0 deletions storage/innobase/lock/lock0lock.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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*
Expand Down
35 changes: 0 additions & 35 deletions storage/innobase/trx/trx0trx.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit 8a4ca33

Please sign in to comment.