diff options
Diffstat (limited to 'storage/innobase/include/trx0undo.ic')
-rw-r--r-- | storage/innobase/include/trx0undo.ic | 181 |
1 files changed, 23 insertions, 158 deletions
diff --git a/storage/innobase/include/trx0undo.ic b/storage/innobase/include/trx0undo.ic index 2e26e6547c3..19697c6054c 100644 --- a/storage/innobase/include/trx0undo.ic +++ b/storage/innobase/include/trx0undo.ic @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2013, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, MariaDB Corporation. +Copyright (c) 2017, 2018, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -40,9 +40,7 @@ trx_undo_build_roll_ptr( ulint offset) /*!< in: offset of the undo entry within page */ { roll_ptr_t roll_ptr; -#if DATA_ROLL_PTR_LEN != 7 -# error "DATA_ROLL_PTR_LEN != 7" -#endif + compile_time_assert(DATA_ROLL_PTR_LEN == 7); ut_ad(is_insert == 0 || is_insert == 1); ut_ad(rseg_id < TRX_SYS_N_RSEGS); ut_ad(offset < 65536); @@ -67,12 +65,7 @@ trx_undo_decode_roll_ptr( ulint* offset) /*!< out: offset of the undo entry within page */ { -#if DATA_ROLL_PTR_LEN != 7 -# error "DATA_ROLL_PTR_LEN != 7" -#endif -#if TRUE != 1 -# error "TRUE != 1" -#endif + compile_time_assert(DATA_ROLL_PTR_LEN == 7); ut_ad(roll_ptr < (1ULL << 56)); *offset = (ulint) roll_ptr & 0xFFFF; roll_ptr >>= 16; @@ -92,14 +85,9 @@ trx_undo_roll_ptr_is_insert( /*========================*/ roll_ptr_t roll_ptr) /*!< in: roll pointer */ { -#if DATA_ROLL_PTR_LEN != 7 -# error "DATA_ROLL_PTR_LEN != 7" -#endif -#if TRUE != 1 -# error "TRUE != 1" -#endif - ut_ad(roll_ptr < (1ULL << 56)); - return((ibool) (roll_ptr >> 55)); + compile_time_assert(DATA_ROLL_PTR_LEN == 7); + ut_ad(roll_ptr < (1ULL << (ROLL_PTR_INSERT_FLAG_POS + 1))); + return((ibool) (roll_ptr >> ROLL_PTR_INSERT_FLAG_POS)); } /***********************************************************************//** @@ -111,10 +99,8 @@ trx_undo_trx_id_is_insert( /*======================*/ const byte* trx_id) /*!< in: DB_TRX_ID, followed by DB_ROLL_PTR */ { -#if DATA_TRX_ID + 1 != DATA_ROLL_PTR -# error -#endif - return(static_cast<bool>(trx_id[DATA_TRX_ID_LEN] >> 7)); + compile_time_assert(DATA_TRX_ID + 1 == DATA_ROLL_PTR); + return bool(trx_id[DATA_TRX_ID_LEN] >> 7); } /*****************************************************************//** @@ -129,9 +115,7 @@ trx_write_roll_ptr( written */ roll_ptr_t roll_ptr) /*!< in: roll ptr */ { -#if DATA_ROLL_PTR_LEN != 7 -# error "DATA_ROLL_PTR_LEN != 7" -#endif + compile_time_assert(DATA_ROLL_PTR_LEN == 7); mach_write_to_7(ptr, roll_ptr); } @@ -146,9 +130,7 @@ trx_read_roll_ptr( /*==============*/ const byte* ptr) /*!< in: pointer to memory from where to read */ { -#if DATA_ROLL_PTR_LEN != 7 -# error "DATA_ROLL_PTR_LEN != 7" -#endif + compile_time_assert(DATA_ROLL_PTR_LEN == 7); return(mach_read_from_7(ptr)); } @@ -184,89 +166,24 @@ trx_undo_page_get_s_latched(const page_id_t page_id, mtr_t* mtr) return(buf_block_get_frame(block)); } -/******************************************************************//** -Returns the start offset of the undo log records of the specified undo -log on the page. -@return start offset */ -UNIV_INLINE -ulint -trx_undo_page_get_start( -/*====================*/ - page_t* undo_page,/*!< in: undo log page */ - ulint page_no,/*!< in: undo log header page number */ - ulint offset) /*!< in: undo log header offset on page */ -{ - ulint start; - - if (page_no == page_get_page_no(undo_page)) { - - start = mach_read_from_2(offset + undo_page - + TRX_UNDO_LOG_START); - } else { - start = TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_HDR_SIZE; - } - - return(start); -} - -/******************************************************************//** -Returns the end offset of the undo log records of the specified undo -log on the page. +/** Determine the end offset of undo log records of an undo log page. +@param[in] undo_page undo log page +@param[in] page_no undo log header page number +@param[in] offset undo log header offset @return end offset */ -UNIV_INLINE -ulint -trx_undo_page_get_end( -/*==================*/ - page_t* undo_page,/*!< in: undo log page */ - ulint page_no,/*!< in: undo log header page number */ - ulint offset) /*!< in: undo log header offset on page */ +inline +uint16_t +trx_undo_page_get_end(const page_t* undo_page, ulint page_no, ulint offset) { - trx_ulogf_t* log_hdr; - ulint end; - if (page_no == page_get_page_no(undo_page)) { - - log_hdr = undo_page + offset; - - end = mach_read_from_2(log_hdr + TRX_UNDO_NEXT_LOG); - - if (end == 0) { - end = mach_read_from_2(undo_page + TRX_UNDO_PAGE_HDR - + TRX_UNDO_PAGE_FREE); + if (uint16_t end = mach_read_from_2(TRX_UNDO_NEXT_LOG + + offset + undo_page)) { + return end; } - } else { - end = mach_read_from_2(undo_page + TRX_UNDO_PAGE_HDR - + TRX_UNDO_PAGE_FREE); - } - - return(end); -} - -/******************************************************************//** -Returns the previous undo record on the page in the specified log, or -NULL if none exists. -@return pointer to record, NULL if none */ -UNIV_INLINE -trx_undo_rec_t* -trx_undo_page_get_prev_rec( -/*=======================*/ - trx_undo_rec_t* rec, /*!< in: undo log record */ - ulint page_no,/*!< in: undo log header page number */ - ulint offset) /*!< in: undo log header offset on page */ -{ - page_t* undo_page; - ulint start; - - undo_page = (page_t*) ut_align_down(rec, UNIV_PAGE_SIZE); - - start = trx_undo_page_get_start(undo_page, page_no, offset); - - if (start + undo_page == rec) { - - return(NULL); } - return(undo_page + mach_read_from_2(rec - 2)); + return mach_read_from_2(TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_FREE + + undo_page); } /******************************************************************//** @@ -285,7 +202,7 @@ trx_undo_page_get_next_rec( ulint end; ulint next; - undo_page = (page_t*) ut_align_down(rec, UNIV_PAGE_SIZE); + undo_page = (page_t*) ut_align_down(rec, srv_page_size); end = trx_undo_page_get_end(undo_page, page_no, offset); @@ -298,55 +215,3 @@ trx_undo_page_get_next_rec( return(undo_page + next); } - -/******************************************************************//** -Returns the last undo record on the page in the specified undo log, or -NULL if none exists. -@return pointer to record, NULL if none */ -UNIV_INLINE -trx_undo_rec_t* -trx_undo_page_get_last_rec( -/*=======================*/ - page_t* undo_page,/*!< in: undo log page */ - ulint page_no,/*!< in: undo log header page number */ - ulint offset) /*!< in: undo log header offset on page */ -{ - ulint start; - ulint end; - - start = trx_undo_page_get_start(undo_page, page_no, offset); - end = trx_undo_page_get_end(undo_page, page_no, offset); - - if (start == end) { - - return(NULL); - } - - return(undo_page + mach_read_from_2(undo_page + end - 2)); -} - -/******************************************************************//** -Returns the first undo record on the page in the specified undo log, or -NULL if none exists. -@return pointer to record, NULL if none */ -UNIV_INLINE -trx_undo_rec_t* -trx_undo_page_get_first_rec( -/*========================*/ - page_t* undo_page,/*!< in: undo log page */ - ulint page_no,/*!< in: undo log header page number */ - ulint offset) /*!< in: undo log header offset on page */ -{ - ulint start; - ulint end; - - start = trx_undo_page_get_start(undo_page, page_no, offset); - end = trx_undo_page_get_end(undo_page, page_no, offset); - - if (start == end) { - - return(NULL); - } - - return(undo_page + start); -} |