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

MDEV-12353 preparation: Do not write MLOG_REC_MIN_MARK

btr_set_min_rec_mark(): Write MLOG_1BYTE instead of
MLOG_REC_MIN_MARK or MLOG_COMP_REC_MIN_MARK.

On ROW_FORMAT=COMPRESSED pages, the minimum record flag is not stored
at all. The flag is computed for the uncompressed page by
page_zip_decompress(). Hence, nothing needs to be logged for
ROW_FORMAT=COMPRESSED tables for this operation.

To facilitate crash-upgrade and hot backup from older versions,
we will retain the code to parse and apply the old log record types
MLOG_REC_MIN_MARK and MLOG_COMP_REC_MIN_MARK.
parent 8ebd91c1
......@@ -3262,24 +3262,6 @@ void btr_level_list_remove(const buf_block_t& block, const dict_index_t& index,
}
}
/****************************************************************//**
Writes the redo log record for setting an index record as the predefined
minimum record. */
UNIV_INLINE
void
btr_set_min_rec_mark_log(
/*=====================*/
rec_t* rec, /*!< in: record */
mlog_id_t type, /*!< in: MLOG_COMP_REC_MIN_MARK or
MLOG_REC_MIN_MARK */
mtr_t* mtr) /*!< in: mtr */
{
mlog_write_initial_log_record(rec, type, mtr);
/* Write rec offset as a 2-byte ulint */
mlog_catenate_ulint(mtr, page_offset(rec), MLOG_2BYTES);
}
/****************************************************************//**
Parses the redo log record for setting an index record as the predefined
minimum record.
......@@ -3290,7 +3272,7 @@ btr_parse_set_min_rec_mark(
const byte* ptr, /*!< in: buffer */
const byte* end_ptr,/*!< in: buffer end */
ulint comp, /*!< in: nonzero=compact page format */
page_t* page, /*!< in: page or NULL */
buf_block_t* block, /*!< in: page or NULL */
mtr_t* mtr) /*!< in: mtr or NULL */
{
rec_t* rec;
......@@ -3300,39 +3282,17 @@ btr_parse_set_min_rec_mark(
return(NULL);
}
if (page) {
ut_a(!page_is_comp(page) == !comp);
if (block) {
ut_a(!page_is_comp(block->frame) == !comp);
rec = page + mach_read_from_2(ptr);
rec = block->frame + mach_read_from_2(ptr);
btr_set_min_rec_mark(rec, mtr);
btr_set_min_rec_mark(rec, *block, mtr);
}
return(ptr + 2);
}
/** Sets a record as the predefined minimum record. */
void btr_set_min_rec_mark(rec_t* rec, mtr_t* mtr)
{
const bool comp = page_rec_is_comp(rec);
ut_ad(rec == page_rec_get_next_const(page_get_infimum_rec(
page_align(rec))));
ut_ad(!(rec_get_info_bits(page_rec_get_next(rec), comp)
& REC_INFO_MIN_REC_FLAG));
size_t info_bits = rec_get_info_bits(rec, comp);
if (comp) {
rec_set_info_bits_new(rec, info_bits | REC_INFO_MIN_REC_FLAG);
btr_set_min_rec_mark_log(rec, MLOG_COMP_REC_MIN_MARK, mtr);
} else {
rec_set_info_bits_old(rec, info_bits | REC_INFO_MIN_REC_FLAG);
btr_set_min_rec_mark_log(rec, MLOG_REC_MIN_MARK, mtr);
}
}
/*************************************************************//**
If page is the only on its level, this function moves its records to the
father page, thus reducing the tree height.
......@@ -4258,7 +4218,7 @@ btr_discard_page(
because everything will take place within a single
mini-transaction and because writing to the redo log
is an atomic operation (performed by mtr_commit()). */
btr_set_min_rec_mark(node_ptr, mtr);
btr_set_min_rec_mark(node_ptr, *block, mtr);
}
if (dict_index_is_spatial(index)) {
......
......@@ -6069,7 +6069,7 @@ btr_cur_pessimistic_delete(
offsets, mtr);
if (min_mark_next_rec) {
btr_set_min_rec_mark(next_rec, mtr);
btr_set_min_rec_mark(next_rec, *block, mtr);
}
#ifdef UNIV_ZIP_DEBUG
......
......@@ -446,7 +446,7 @@ rtr_update_mbr_field(
if (!ins_suc) {
ut_ad(rec_info & REC_INFO_MIN_REC_FLAG);
btr_set_min_rec_mark(next_rec, mtr);
btr_set_min_rec_mark(next_rec, *block, mtr);
}
/* If there's more than 1 rec left in the page, delete
......@@ -468,7 +468,7 @@ rtr_update_mbr_field(
mark the new leftmost node pointer as
the predefined minimum record */
rec_t* next_rec = page_rec_get_next(cur2_rec);
btr_set_min_rec_mark(next_rec, mtr);
btr_set_min_rec_mark(next_rec, *block, mtr);
}
ut_ad(del_page_no
......@@ -572,7 +572,7 @@ rtr_update_mbr_field(
mark the new leftmost node pointer as
the predefined minimum record */
rec_t* next_rec = page_rec_get_next(cur2_rec);
btr_set_min_rec_mark(next_rec, mtr);
btr_set_min_rec_mark(next_rec, *block, mtr);
}
ut_ad(cur2_pno == del_page_no && cur2_rec != insert_rec);
......
......@@ -523,8 +523,26 @@ btr_insert_on_non_leaf_level_func(
#define btr_insert_on_non_leaf_level(f,i,l,t,m) \
btr_insert_on_non_leaf_level_func(f,i,l,t,__FILE__,__LINE__,m)
/** Sets a record as the predefined minimum record. */
void btr_set_min_rec_mark(rec_t* rec, mtr_t* mtr) MY_ATTRIBUTE((nonnull));
/** Set a record as the predefined minimum record.
@param[in,out] rec leftmost record on a leftmost non-leaf page
@param[in,out] block buffer pool block
@param[in,out] mtr mini-transaction */
inline void btr_set_min_rec_mark(rec_t *rec, const buf_block_t &block,
mtr_t *mtr)
{
ut_ad(block.frame == page_align(rec));
ut_ad(!page_is_leaf(block.frame));
ut_ad(!page_has_prev(block.frame));
rec-= page_rec_is_comp(rec) ? REC_NEW_INFO_BITS : REC_OLD_INFO_BITS;
if (block.page.zip.data)
/* This flag is computed from other contents on a ROW_FORMAT=COMPRESSED
page. We are not modifying the compressed page frame at all. */
*rec|= REC_INFO_MIN_REC_FLAG;
else
mlog_write_ulint(rec, *rec | REC_INFO_MIN_REC_FLAG, MLOG_1BYTE, mtr);
}
/** Seek to the parent page of a B-tree page.
@param[in,out] index b-tree
......@@ -581,15 +599,15 @@ btr_discard_page(
Parses the redo log record for setting an index record as the predefined
minimum record.
@return end of log record or NULL */
ATTRIBUTE_COLD MY_ATTRIBUTE((nonnull(1,2), warn_unused_result))
const byte*
btr_parse_set_min_rec_mark(
/*=======================*/
const byte* ptr, /*!< in: buffer */
const byte* end_ptr,/*!< in: buffer end */
ulint comp, /*!< in: nonzero=compact page format */
page_t* page, /*!< in: page or NULL */
mtr_t* mtr) /*!< in: mtr or NULL */
MY_ATTRIBUTE((nonnull(1,2), warn_unused_result));
buf_block_t* block, /*!< in: page or NULL */
mtr_t* mtr); /*!< in: mtr or NULL */
/***********************************************************//**
Parses a redo log record of reorganizing a page.
@return end of log record or NULL */
......
......@@ -1630,7 +1630,7 @@ recv_parse_or_apply_log_rec_body(
ut_a(type == MLOG_COMP_REC_MIN_MARK || !page_zip);
ptr = btr_parse_set_min_rec_mark(
ptr, end_ptr, type == MLOG_COMP_REC_MIN_MARK,
page, mtr);
block, mtr);
break;
case MLOG_REC_DELETE: case MLOG_COMP_REC_DELETE:
ut_ad(!page || fil_page_type_is_index(page_type));
......
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