Commit 0ead8d95 authored by Marko Mäkelä's avatar Marko Mäkelä

Clean up some undo page accessor functions

trx_undo_page_get_prev_rec(), trx_undo_page_get_last_rec(),
trx_undo_page_get_first_rec(), trx_undo_page_get_start():
Move to the only caller, trx0undo.cc.

Add some const qualifiers.
parent 648e8c12
......@@ -122,17 +122,6 @@ UNIV_INLINE
page_t*
trx_undo_page_get_s_latched(const page_id_t& page_id, mtr_t* mtr);
/******************************************************************//**
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 */
/******************************************************************//**
Returns the next undo log record on the page in the specified log, or
NULL if none exists.
......@@ -144,28 +133,6 @@ trx_undo_page_get_next_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 */
/******************************************************************//**
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 */
/******************************************************************//**
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 */
/***********************************************************************//**
Gets the previous record in an undo log.
@return undo log record, the page s-latched, NULL if none */
......
/*****************************************************************************
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
......@@ -184,51 +184,19 @@ 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;
uint16_t 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);
end = mach_read_from_2(offset + TRX_UNDO_NEXT_LOG + undo_page);
if (end == 0) {
end = mach_read_from_2(undo_page + TRX_UNDO_PAGE_HDR
......@@ -242,33 +210,6 @@ trx_undo_page_get_end(
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));
}
/******************************************************************//**
Returns the next undo log record on the page in the specified log, or
NULL if none exists.
......@@ -298,55 +239,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);
}
......@@ -117,6 +117,53 @@ trx_undo_mem_create(
ulint page_no,/*!< in: undo log header page number */
ulint offset);/*!< in: undo log header byte offset on page */
/** Determine the start 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 start offset */
static
uint16_t
trx_undo_page_get_start(const page_t* undo_page, ulint page_no, ulint offset)
{
return page_no == page_get_page_no(undo_page)
? mach_read_from_2(offset + TRX_UNDO_LOG_START + undo_page)
: TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_HDR_SIZE;
}
/** Get the first undo log record on a page.
@param[in] page undo log page
@param[in] page_no undo log header page number
@param[in] offset undo log header page offset
@return pointer to first record
@retval NULL if none exists */
static
trx_undo_rec_t*
trx_undo_page_get_first_rec(page_t* page, ulint page_no, ulint offset)
{
ulint start = trx_undo_page_get_start(page, page_no, offset);
return start == trx_undo_page_get_end(page, page_no, offset)
? NULL
: page + start;
}
/** Get the last undo log record on a page.
@param[in] page undo log page
@param[in] page_no undo log header page number
@param[in] offset undo log header page offset
@return pointer to last record
@retval NULL if none exists */
static
trx_undo_rec_t*
trx_undo_page_get_last_rec(page_t* page, ulint page_no, ulint offset)
{
ulint end = trx_undo_page_get_end(page, page_no, offset);
return trx_undo_page_get_start(page, page_no, offset) == end
? NULL
: page + mach_read_from_2(page + end - 2);
}
/***********************************************************************//**
Gets the previous record in an undo log from the previous page.
@return undo log record, the page s-latched, NULL if none */
......@@ -159,6 +206,31 @@ trx_undo_get_prev_rec_from_prev_page(
return(trx_undo_page_get_last_rec(prev_page, page_no, offset));
}
/** Get the previous undo log record.
@param[in] rec undo log record
@param[in] page_no undo log header page number
@param[in] offset undo log header page offset
@return pointer to record
@retval NULL if none */
static
trx_undo_rec_t*
trx_undo_page_get_prev_rec(trx_undo_rec_t* rec, ulint page_no, ulint offset)
{
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));
}
/***********************************************************************//**
Gets the previous record in an undo log.
@return undo log record, the page s-latched, NULL if none */
......
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