Commit f29cfa1d authored by Marko Mäkelä's avatar Marko Mäkelä

Remove dead code for MLOG_UNDO_HDR_DISCARD

The redo log record MLOG_UNDO_HDR_DISCARD is never written, and
the function trx_undo_discard_latest_update_undo() is never called
outside crash recovery.

Starting with MariaDB 10.2.2, crash recovery from an older InnoDB
version is refused. Therefore, we can safely remove the code for
parsing this long-unused redo log record type.

The use of MLOG_UNDO_HDR_DISCARD was removed by Heikki Tuuri,
the original designer and author of InnoDB, more than 13 years ago:

  commit 3caab0f3
  Author: unknown <heikki@hundin.mysql.fi>
  Date:   Thu Mar 18 14:57:22 2004 +0200

    trx0undo.h, trx0undo.c, trx0trx.c:
      Update an obsolete comment about trx commit: we can no longer call
      trx_undo_update_cleanup_by_discard(), and actually, the idea to
      call it was erroneous, it cannot work
parent 02ba15a9
...@@ -109,9 +109,6 @@ enum mlog_id_t { ...@@ -109,9 +109,6 @@ enum mlog_id_t {
/** initialize a page in an undo log */ /** initialize a page in an undo log */
MLOG_UNDO_INIT = 22, MLOG_UNDO_INIT = 22,
/** discard an update undo log header */
MLOG_UNDO_HDR_DISCARD = 23,
/** reuse an insert undo log header */ /** reuse an insert undo log header */
MLOG_UNDO_HDR_REUSE = 24, MLOG_UNDO_HDR_REUSE = 24,
......
...@@ -357,16 +357,6 @@ trx_undo_parse_page_header( ...@@ -357,16 +357,6 @@ trx_undo_parse_page_header(
const byte* end_ptr, const byte* end_ptr,
page_t* page, page_t* page,
mtr_t* mtr); mtr_t* mtr);
/***********************************************************//**
Parses the redo log entry of an undo log page header discard.
@return end of log record or NULL */
byte*
trx_undo_parse_discard_latest(
/*==========================*/
byte* ptr, /*!< in: buffer */
byte* end_ptr,/*!< in: buffer end */
page_t* page, /*!< in: page or NULL */
mtr_t* mtr); /*!< in: mtr or NULL */
/************************************************************************ /************************************************************************
Frees an undo log memory copy. */ Frees an undo log memory copy. */
void void
......
...@@ -1334,10 +1334,6 @@ recv_parse_or_apply_log_rec_body( ...@@ -1334,10 +1334,6 @@ recv_parse_or_apply_log_rec_body(
/* Allow anything in page_type when creating a page. */ /* Allow anything in page_type when creating a page. */
ptr = trx_undo_parse_page_init(ptr, end_ptr, page, mtr); ptr = trx_undo_parse_page_init(ptr, end_ptr, page, mtr);
break; break;
case MLOG_UNDO_HDR_DISCARD:
ut_ad(!page || page_type == FIL_PAGE_UNDO_LOG);
ptr = trx_undo_parse_discard_latest(ptr, end_ptr, page, mtr);
break;
case MLOG_UNDO_HDR_CREATE: case MLOG_UNDO_HDR_CREATE:
case MLOG_UNDO_HDR_REUSE: case MLOG_UNDO_HDR_REUSE:
ut_ad(!page || page_type == FIL_PAGE_UNDO_LOG); ut_ad(!page || page_type == FIL_PAGE_UNDO_LOG);
...@@ -3564,9 +3560,6 @@ get_mlog_string(mlog_id_t type) ...@@ -3564,9 +3560,6 @@ get_mlog_string(mlog_id_t type)
case MLOG_UNDO_INIT: case MLOG_UNDO_INIT:
return("MLOG_UNDO_INIT"); return("MLOG_UNDO_INIT");
case MLOG_UNDO_HDR_DISCARD:
return("MLOG_UNDO_HDR_DISCARD");
case MLOG_UNDO_HDR_REUSE: case MLOG_UNDO_HDR_REUSE:
return("MLOG_UNDO_HDR_REUSE"); return("MLOG_UNDO_HDR_REUSE");
......
...@@ -132,15 +132,6 @@ trx_undo_insert_header_reuse( ...@@ -132,15 +132,6 @@ trx_undo_insert_header_reuse(
header page, x-latched */ header page, x-latched */
trx_id_t trx_id, /*!< in: transaction id */ trx_id_t trx_id, /*!< in: transaction id */
mtr_t* mtr); /*!< in: mtr */ mtr_t* mtr); /*!< in: mtr */
/**********************************************************************//**
If an update undo log can be discarded immediately, this function frees the
space, resetting the page to the proper state for caching. */
static
void
trx_undo_discard_latest_update_undo(
/*================================*/
page_t* undo_page, /*!< in: header page of an undo log of size 1 */
mtr_t* mtr); /*!< in: mtr */
/***********************************************************************//** /***********************************************************************//**
Gets the previous record in an undo log from the previous page. Gets the previous record in an undo log from the previous page.
...@@ -783,80 +774,6 @@ trx_undo_insert_header_reuse( ...@@ -783,80 +774,6 @@ trx_undo_insert_header_reuse(
return(free); return(free);
} }
/**********************************************************************//**
Writes the redo log entry of an update undo log header discard. */
UNIV_INLINE
void
trx_undo_discard_latest_log(
/*========================*/
page_t* undo_page, /*!< in: undo log header page */
mtr_t* mtr) /*!< in: mtr */
{
mlog_write_initial_log_record(undo_page, MLOG_UNDO_HDR_DISCARD, mtr);
}
/***********************************************************//**
Parses the redo log entry of an undo log page header discard.
@return end of log record or NULL */
byte*
trx_undo_parse_discard_latest(
/*==========================*/
byte* ptr, /*!< in: buffer */
byte* end_ptr MY_ATTRIBUTE((unused)), /*!< in: buffer end */
page_t* page, /*!< in: page or NULL */
mtr_t* mtr) /*!< in: mtr or NULL */
{
ut_ad(end_ptr);
if (page) {
trx_undo_discard_latest_update_undo(page, mtr);
}
return(ptr);
}
/**********************************************************************//**
If an update undo log can be discarded immediately, this function frees the
space, resetting the page to the proper state for caching. */
static
void
trx_undo_discard_latest_update_undo(
/*================================*/
page_t* undo_page, /*!< in: header page of an undo log of size 1 */
mtr_t* mtr) /*!< in: mtr */
{
trx_usegf_t* seg_hdr;
trx_upagef_t* page_hdr;
trx_ulogf_t* log_hdr;
trx_ulogf_t* prev_log_hdr;
ulint free;
ulint prev_hdr_offset;
seg_hdr = undo_page + TRX_UNDO_SEG_HDR;
page_hdr = undo_page + TRX_UNDO_PAGE_HDR;
free = mach_read_from_2(seg_hdr + TRX_UNDO_LAST_LOG);
log_hdr = undo_page + free;
prev_hdr_offset = mach_read_from_2(log_hdr + TRX_UNDO_PREV_LOG);
if (prev_hdr_offset != 0) {
prev_log_hdr = undo_page + prev_hdr_offset;
mach_write_to_2(page_hdr + TRX_UNDO_PAGE_START,
mach_read_from_2(prev_log_hdr
+ TRX_UNDO_LOG_START));
mach_write_to_2(prev_log_hdr + TRX_UNDO_NEXT_LOG, 0);
}
mach_write_to_2(page_hdr + TRX_UNDO_PAGE_FREE, free);
mach_write_to_2(seg_hdr + TRX_UNDO_STATE, TRX_UNDO_CACHED);
mach_write_to_2(seg_hdr + TRX_UNDO_LAST_LOG, prev_hdr_offset);
trx_undo_discard_latest_log(undo_page, mtr);
}
/** Allocate an undo log page. /** Allocate an undo log page.
@param[in,out] trx transaction @param[in,out] trx transaction
@param[in,out] undo undo log @param[in,out] undo undo log
......
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