Commit 33f74e8f authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-21024: Clean up IMPORT TABLESPACE

page_rec_write_field(): Remove.

dict_create_index_tree_step(): If the SYS_INDEXES.PAGE does not change,
do not update it in the data dictionary. Typically, all index page numbers
would be unchanged before and after IMPORT TABLESPACE, except if some
secondary indexes were created after loading some data.

btr_root_fseg_adjust_on_import(): Remove the redundant mtr_t* parameter.
Redo logging is disabled during the page adjustments that IMPORT TABLESPACE
is performing.
parent dfdd9621
......@@ -321,26 +321,24 @@ btr_root_fseg_adjust_on_import(
fseg_header_t* seg_header, /*!< in/out: segment header */
page_zip_des_t* page_zip, /*!< in/out: compressed page,
or NULL */
ulint space, /*!< in: tablespace identifier */
mtr_t* mtr) /*!< in/out: mini-transaction */
ulint space) /*!< in: tablespace identifier */
{
ulint offset = mach_read_from_2(seg_header + FSEG_HDR_OFFSET);
if (offset < FIL_PAGE_DATA
|| offset > UNIV_PAGE_SIZE - FIL_PAGE_DATA_END) {
|| offset > srv_page_size - FIL_PAGE_DATA_END) {
return false;
}
return(FALSE);
seg_header += FSEG_HDR_SPACE;
} else if (page_zip) {
mach_write_to_4(seg_header + FSEG_HDR_SPACE, space);
page_zip_write_header(page_zip, seg_header + FSEG_HDR_SPACE,
4, mtr);
} else {
mlog_write_ulint(seg_header + FSEG_HDR_SPACE,
space, MLOG_4BYTES, mtr);
mach_write_to_4(seg_header, space);
if (UNIV_LIKELY_NULL(page_zip)) {
memcpy(page_zip->data + page_offset(seg_header), seg_header,
4);
}
return(TRUE);
return true;
}
/**************************************************************//**
......@@ -400,10 +398,10 @@ btr_root_adjust_on_import(
if (err == DB_SUCCESS
&& (!btr_root_fseg_adjust_on_import(
FIL_PAGE_DATA + PAGE_BTR_SEG_LEAF
+ page, page_zip, space_id, &mtr)
+ page, page_zip, space_id)
|| !btr_root_fseg_adjust_on_import(
FIL_PAGE_DATA + PAGE_BTR_SEG_TOP
+ page, page_zip, space_id, &mtr))) {
+ page, page_zip, space_id))) {
err = DB_CORRUPTION;
}
......
......@@ -894,11 +894,14 @@ dict_create_index_tree_step(
err = DB_OUT_OF_FILE_SPACE; );
}
page_rec_write_field(
btr_pcur_get_rec(&pcur), DICT_FLD__SYS_INDEXES__PAGE_NO,
node->page_no, &mtr);
btr_pcur_close(&pcur);
ulint len;
byte* data = rec_get_nth_field_old(btr_pcur_get_rec(&pcur),
DICT_FLD__SYS_INDEXES__PAGE_NO,
&len);
ut_ad(len == 4);
if (mach_read_from_4(data) != node->page_no) {
mlog_write_ulint(data, node->page_no, MLOG_4BYTES, &mtr);
}
mtr_commit(&mtr);
......
......@@ -832,17 +832,6 @@ page_rec_find_owner_rec(
/*====================*/
rec_t* rec); /*!< in: the physical record */
/***********************************************************************//**
Write a 32-bit field in a data dictionary record. */
UNIV_INLINE
void
page_rec_write_field(
/*=================*/
rec_t* rec, /*!< in/out: record to update */
ulint i, /*!< in: index of the field to update */
ulint val, /*!< in: value to write */
mtr_t* mtr) /*!< in/out: mini-transaction */
MY_ATTRIBUTE((nonnull));
/************************************************************//**
Returns the maximum combined size of records which can be inserted on top
of record heap.
......
......@@ -919,27 +919,6 @@ page_get_free_space_of_empty(
- 2 * PAGE_DIR_SLOT_SIZE));
}
/***********************************************************************//**
Write a 32-bit field in a data dictionary record. */
UNIV_INLINE
void
page_rec_write_field(
/*=================*/
rec_t* rec, /*!< in/out: record to update */
ulint i, /*!< in: index of the field to update */
ulint val, /*!< in: value to write */
mtr_t* mtr) /*!< in/out: mini-transaction */
{
byte* data;
ulint len;
data = rec_get_nth_field_old(rec, i, &len);
ut_ad(len == 4);
mlog_write_ulint(data, val, MLOG_4BYTES, mtr);
}
/************************************************************//**
Each user record on a page, and also the deleted user records in the heap
takes its size plus the fraction of the dir cell size /
......
......@@ -1034,12 +1034,12 @@ CreateIndex::operator()(mtr_t* mtr, btr_pcur_t* pcur) const
root_page_no = FIL_NULL;);
if (root_page_no != FIL_NULL) {
rec_t* rec = btr_pcur_get_rec(pcur);
page_rec_write_field(
rec, DICT_FLD__SYS_INDEXES__PAGE_NO,
root_page_no, mtr);
ulint len;
byte* data = rec_get_nth_field_old(
btr_pcur_get_rec(pcur),
DICT_FLD__SYS_INDEXES__PAGE_NO, &len);
ut_ad(len == 4);
mlog_write_ulint(data, root_page_no, MLOG_4BYTES, mtr);
/* We will need to commit and restart the
mini-transaction in order to avoid deadlocks.
......
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