/*******************************************************************//** Stores info of an undo log record during a purge. @return pointer to the storage cell */ static trx_undo_inf_t* trx_purge_arr_store_info( /*=====================*/ trx_id_t trx_no, /*!< in: transaction number */ undo_no_t undo_no)/*!< in: undo number */ { trx_undo_inf_t* cell; trx_undo_arr_t* arr; ulint i; arr = purge_sys->arr; for (i = 0;; i++) { cell = trx_undo_arr_get_nth_info(arr, i); if (!(cell->in_use)) { /* Not in use, we may store here */ cell->undo_no = undo_no; cell->trx_no = trx_no; cell->in_use = TRUE; arr->n_used++; return(cell); } } }
/*******************************************************************//** Gets the biggest pair of a trx number and an undo number in a purge array. */ static void trx_purge_arr_get_biggest( /*======================*/ trx_undo_arr_t* arr, /*!< in: purge array */ trx_id_t* trx_no, /*!< out: transaction number: ut_dulint_zero if array is empty */ undo_no_t* undo_no)/*!< out: undo number */ { trx_undo_inf_t* cell; trx_id_t pair_trx_no; undo_no_t pair_undo_no; int trx_cmp; ulint n_used; ulint i; ulint n; n = 0; n_used = arr->n_used; pair_trx_no = ut_dulint_zero; pair_undo_no = ut_dulint_zero; for (i = 0;; i++) { cell = trx_undo_arr_get_nth_info(arr, i); if (cell->in_use) { n++; trx_cmp = ut_dulint_cmp(cell->trx_no, pair_trx_no); if ((trx_cmp > 0) || ((trx_cmp == 0) && (ut_dulint_cmp(cell->undo_no, pair_undo_no) >= 0))) { pair_trx_no = cell->trx_no; pair_undo_no = cell->undo_no; } } if (n == n_used) { *trx_no = pair_trx_no; *undo_no = pair_undo_no; return; } } }
/*******************************************************************//** Gets the biggest pair of a trx number and an undo number in a purge array. */ static void trx_purge_arr_get_biggest( /*======================*/ trx_undo_arr_t* arr, /*!< in: purge array */ trx_id_t* trx_no, /*!< out: transaction number: 0 if array is empty */ undo_no_t* undo_no)/*!< out: undo number */ { trx_undo_inf_t* cell; trx_id_t pair_trx_no; undo_no_t pair_undo_no; ulint i; ulint n; n = arr->n_used; pair_trx_no = 0; pair_undo_no = 0; if (n) { for (i = 0;; i++) { cell = trx_undo_arr_get_nth_info(arr, i); if (!cell->in_use) { continue; } if ((cell->trx_no > pair_trx_no) || ((cell->trx_no == pair_trx_no) && cell->undo_no >= pair_undo_no)) { pair_trx_no = cell->trx_no; pair_undo_no = cell->undo_no; } if (!--n) { break; } } } *trx_no = pair_trx_no; *undo_no = pair_undo_no; }