Skip to content
Permalink
Browse files
MDEV-21174: Remove some mlog_write_initial_log_record_fast()
Pass buf_block_t* to more functions that write redo log.

page_zip_write_node_ptr(), page_zip_write_blob_ptr(),
page_zip_compress_write_log_no_data():
Take buf_block_t* as parameter, and do not tolerate mtr=NULL.

page_zip_compress(): Do not tolerate mtr=NULL.

page_zip_dir_insert(): Take page_cur_t* as parameter.

mlog_write_initial_log_record(): Remove. This function was unused.

RecIterator::remove(): Remove the redundant page_zip parameter.

PageConverter::m_page_zip_ptr: Remove.
  • Loading branch information
dr-m committed Dec 13, 2019
1 parent 2b5a269 commit 745fd4b
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 153 deletions.
@@ -780,7 +780,7 @@ inline void btr_node_ptr_set_child_page_no(buf_block_t *block,
REC_NODE_PTR_SIZE);

if (UNIV_LIKELY_NULL(block->page.zip.data))
page_zip_write_node_ptr(&block->page.zip, rec, offs, page_no, mtr);
page_zip_write_node_ptr(block, rec, offs, page_no, mtr);
else
mtr->write<4>(*block, rec + offs - REC_NODE_PTR_SIZE, page_no);
}
@@ -7153,8 +7153,7 @@ btr_cur_set_ownership_of_extern_field(

if (UNIV_LIKELY_NULL(block->page.zip.data)) {
mach_write_to_1(data + local_len + BTR_EXTERN_LEN, byte_val);
page_zip_write_blob_ptr(&block->page.zip, rec, index, offsets,
i, mtr);
page_zip_write_blob_ptr(block, rec, index, offsets, i, mtr);
} else {
mtr->write<1,mtr_t::OPT>(*block,
data + local_len + BTR_EXTERN_LEN,
@@ -7826,7 +7825,7 @@ btr_store_big_rec_extern_fields(
/* We compress a page when finish bulk insert.*/
if (UNIV_LIKELY(op != BTR_STORE_INSERT_BULK)) {
page_zip_write_blob_ptr(
page_zip, rec, index, offsets,
rec_block, rec, index, offsets,
field_no, &mtr);
}

@@ -8103,8 +8102,7 @@ btr_free_externally_stored_field(
mach_write_to_4(field_ref + BTR_EXTERN_PAGE_NO,
next_page_no);
memset(field_ref + BTR_EXTERN_LEN, 0, 4);
page_zip_write_blob_ptr(&block->page.zip,
rec, index,
page_zip_write_blob_ptr(block, rec, index,
offsets, i, &mtr);
} else {
mtr.write<4>(*block,
@@ -133,12 +133,11 @@ page_zip_set_alloc(
@retval false on failure; block->page.zip will be left intact. */
bool
page_zip_compress(
buf_block_t* block, /*!< in/out: buffer block */
dict_index_t* index, /*!< in: index of the B-tree
node */
ulint level, /*!< in: commpression level */
mtr_t* mtr); /*!< in/out: mini-transaction,
or NULL */
buf_block_t* block, /*!< in/out: buffer block */
dict_index_t* index, /*!< in: index of the B-tree node */
ulint level, /*!< in: commpression level */
mtr_t* mtr) /*!< in/out: mini-transaction */
MY_ATTRIBUTE((nonnull));

/**********************************************************************//**
Write the index information for the compressed page.
@@ -278,14 +277,14 @@ The information must already have been updated on the uncompressed page. */
void
page_zip_write_blob_ptr(
/*====================*/
page_zip_des_t* page_zip,/*!< in/out: compressed page */
buf_block_t* block, /*!< in/out: ROW_FORMAT=COMPRESSED page */
const byte* rec, /*!< in/out: record whose data is being
written */
dict_index_t* index, /*!< in: index of the page */
const ulint* offsets,/*!< in: rec_get_offsets(rec, index) */
ulint n, /*!< in: column index */
mtr_t* mtr); /*!< in: mini-transaction handle,
or NULL if no logging is needed */
mtr_t* mtr) /*!< in/out: mini-transaction */
MY_ATTRIBUTE((nonnull));

/***********************************************************//**
Parses a log record of writing the node pointer of a record.
@@ -303,11 +302,12 @@ Write the node pointer of a record on a non-leaf compressed page. */
void
page_zip_write_node_ptr(
/*====================*/
page_zip_des_t* page_zip,/*!< in/out: compressed page */
buf_block_t* block, /*!< in/out: compressed page */
byte* rec, /*!< in/out: record */
ulint size, /*!< in: data size of rec */
ulint ptr, /*!< in: node pointer */
mtr_t* mtr); /*!< in: mini-transaction, or NULL */
mtr_t* mtr) /*!< in/out: mini-transaction */
MY_ATTRIBUTE((nonnull));

/** Write the DB_TRX_ID,DB_ROLL_PTR into a clustered index leaf page record.
@param[in,out] page_zip compressed page
@@ -370,8 +370,7 @@ Insert a record to the dense page directory. */
void
page_zip_dir_insert(
/*================*/
page_zip_des_t* page_zip,/*!< in/out: compressed page */
const byte* prev_rec,/*!< in: record after which to insert */
page_cur_t* cursor, /*!< in/out: page cursor */
const byte* free_rec,/*!< in: record from which rec was
allocated, or NULL */
byte* rec); /*!< in: record to insert */
@@ -411,22 +410,6 @@ page_zip_parse_write_header(
page_t* page, /*!< in/out: uncompressed page */
page_zip_des_t* page_zip);/*!< in/out: compressed page */

/**********************************************************************//**
Write data to the uncompressed header portion of a page. The data must
already have been written to the uncompressed page.
However, the data portion of the uncompressed page may differ from
the compressed page when a record is being inserted in
page_cur_insert_rec_low(). */
UNIV_INLINE
void
page_zip_write_header(
/*==================*/
page_zip_des_t* page_zip,/*!< in/out: compressed page */
const byte* str, /*!< in: address on the uncompressed page */
ulint length, /*!< in: length of the data */
mtr_t* mtr) /*!< in: mini-transaction, or NULL */
MY_ATTRIBUTE((nonnull(1,2)));

/**********************************************************************//**
Reorganize and compress a page. This is a low-level operation for
compressed pages, to be used when page_zip_compress() fails.
@@ -499,9 +482,10 @@ void
page_zip_compress_write_log_no_data(
/*================================*/
ulint level, /*!< in: compression level */
const page_t* page, /*!< in: page that is compressed */
buf_block_t* block, /*!< in: ROW_FORMAT=COMPRESSED index page */
dict_index_t* index, /*!< in: index */
mtr_t* mtr); /*!< in: mtr */
mtr_t* mtr) /*!< in: mtr */
MY_ATTRIBUTE((nonnull));

/**********************************************************************//**
Reset the counters used for filling
@@ -369,14 +369,15 @@ void
page_zip_compress_write_log_no_data(
/*================================*/
ulint level, /*!< in: compression level */
const page_t* page, /*!< in: page that is compressed */
buf_block_t* block, /*!< in: ROW_FORMAT=COMPRESSED index page */
dict_index_t* index, /*!< in: index */
mtr_t* mtr) /*!< in: mtr */
{
byte* log_ptr = mlog_open_and_write_index(
mtr, page, index, MLOG_ZIP_PAGE_COMPRESS_NO_DATA, 1);

if (log_ptr) {
if (byte* log_ptr = mlog_open(mtr, 11 + 1)) {
log_ptr = mlog_write_initial_log_record_low(
MLOG_ZIP_PAGE_COMPRESS_NO_DATA,
block->page.id.space(), block->page.id.page_no(),
log_ptr, mtr);
mach_write_to_1(log_ptr, level);
mlog_close(mtr, log_ptr + 1);
}
@@ -1704,7 +1704,7 @@ recv_parse_or_apply_log_rec_body(
break;
}
if (page &&
!page_zip_compress(block, index, *ptr, NULL)) {
!page_zip_compress(block, index, *ptr, mtr)) {
ut_error;
}
ptr++;
@@ -50,38 +50,7 @@ mlog_catenate_string(
}

/********************************************************//**
Writes the initial part of a log record consisting of one-byte item
type and four-byte space and page numbers. Also pushes info
to the mtr memo that a buffer page has been modified. */
void
mlog_write_initial_log_record(
/*==========================*/
const byte* ptr, /*!< in: pointer to (inside) a buffer
frame holding the file page where
modification is made */
mlog_id_t type, /*!< in: log item type: MLOG_1BYTE, ... */
mtr_t* mtr) /*!< in: mini-transaction handle */
{
byte* log_ptr;

ut_ad(type <= MLOG_BIGGEST_TYPE);
ut_ad(type > MLOG_8BYTES);

log_ptr = mlog_open(mtr, 11);

/* If no logging is requested, we may return now */
if (log_ptr == NULL) {

return;
}

log_ptr = mlog_write_initial_log_record_fast(ptr, type, log_ptr, mtr);

mlog_close(mtr, log_ptr);
}

/********************************************************//**
Parses an initial log record written by mlog_write_initial_log_record.
Parses an initial log record written by mlog_write_initial_log_record_low().
@return parsed record end, NULL if not a complete record */
const byte*
mlog_parse_initial_log_record(
@@ -1772,14 +1772,20 @@ page_cur_insert_rec_zip(
ut_ad(pos > 0);

if (!log_compressed) {
if (page_zip_compress(
page_cur_get_block(cursor),
index, level, NULL)) {
const mtr_log_t log_mode = mtr->set_log_mode(
MTR_LOG_NONE);
const bool ok = page_zip_compress(
page_cur_get_block(cursor),
index, level, mtr);
mtr->set_log_mode(log_mode);
if (ok) {
page_cur_insert_rec_write_log(
insert_rec, rec_size,
cursor->rec, index, mtr);
page_zip_compress_write_log_no_data(
level, page, index, mtr);
level,
page_cur_get_block(cursor),
index, mtr);

rec_offs_make_valid(
insert_rec, index,
@@ -1991,7 +1997,7 @@ page_cur_insert_rec_zip(
UNIV_MEM_ASSERT_RW(rec_get_start(insert_rec, offsets),
rec_offs_size(offsets));

page_zip_dir_insert(page_zip, cursor->rec, free_rec, insert_rec);
page_zip_dir_insert(cursor, free_rec, insert_rec);

/* 6. Update the last insertion info in page header */

0 comments on commit 745fd4b

Please sign in to comment.