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( ...@@ -321,26 +321,24 @@ btr_root_fseg_adjust_on_import(
fseg_header_t* seg_header, /*!< in/out: segment header */ fseg_header_t* seg_header, /*!< in/out: segment header */
page_zip_des_t* page_zip, /*!< in/out: compressed page, page_zip_des_t* page_zip, /*!< in/out: compressed page,
or NULL */ or NULL */
ulint space, /*!< in: tablespace identifier */ ulint space) /*!< in: tablespace identifier */
mtr_t* mtr) /*!< in/out: mini-transaction */
{ {
ulint offset = mach_read_from_2(seg_header + FSEG_HDR_OFFSET); ulint offset = mach_read_from_2(seg_header + FSEG_HDR_OFFSET);
if (offset < FIL_PAGE_DATA 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, space);
mach_write_to_4(seg_header + FSEG_HDR_SPACE, space); if (UNIV_LIKELY_NULL(page_zip)) {
page_zip_write_header(page_zip, seg_header + FSEG_HDR_SPACE, memcpy(page_zip->data + page_offset(seg_header), seg_header,
4, mtr); 4);
} else {
mlog_write_ulint(seg_header + FSEG_HDR_SPACE,
space, MLOG_4BYTES, mtr);
} }
return(TRUE); return true;
} }
/**************************************************************//** /**************************************************************//**
...@@ -400,10 +398,10 @@ btr_root_adjust_on_import( ...@@ -400,10 +398,10 @@ btr_root_adjust_on_import(
if (err == DB_SUCCESS if (err == DB_SUCCESS
&& (!btr_root_fseg_adjust_on_import( && (!btr_root_fseg_adjust_on_import(
FIL_PAGE_DATA + PAGE_BTR_SEG_LEAF FIL_PAGE_DATA + PAGE_BTR_SEG_LEAF
+ page, page_zip, space_id, &mtr) + page, page_zip, space_id)
|| !btr_root_fseg_adjust_on_import( || !btr_root_fseg_adjust_on_import(
FIL_PAGE_DATA + PAGE_BTR_SEG_TOP FIL_PAGE_DATA + PAGE_BTR_SEG_TOP
+ page, page_zip, space_id, &mtr))) { + page, page_zip, space_id))) {
err = DB_CORRUPTION; err = DB_CORRUPTION;
} }
......
...@@ -894,11 +894,14 @@ dict_create_index_tree_step( ...@@ -894,11 +894,14 @@ dict_create_index_tree_step(
err = DB_OUT_OF_FILE_SPACE; ); err = DB_OUT_OF_FILE_SPACE; );
} }
page_rec_write_field( ulint len;
btr_pcur_get_rec(&pcur), DICT_FLD__SYS_INDEXES__PAGE_NO, byte* data = rec_get_nth_field_old(btr_pcur_get_rec(&pcur),
node->page_no, &mtr); DICT_FLD__SYS_INDEXES__PAGE_NO,
&len);
btr_pcur_close(&pcur); 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); mtr_commit(&mtr);
......
...@@ -832,17 +832,6 @@ page_rec_find_owner_rec( ...@@ -832,17 +832,6 @@ page_rec_find_owner_rec(
/*====================*/ /*====================*/
rec_t* rec); /*!< in: the physical record */ 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 Returns the maximum combined size of records which can be inserted on top
of record heap. of record heap.
......
...@@ -919,27 +919,6 @@ page_get_free_space_of_empty( ...@@ -919,27 +919,6 @@ page_get_free_space_of_empty(
- 2 * PAGE_DIR_SLOT_SIZE)); - 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 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 / 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 ...@@ -1034,12 +1034,12 @@ CreateIndex::operator()(mtr_t* mtr, btr_pcur_t* pcur) const
root_page_no = FIL_NULL;); root_page_no = FIL_NULL;);
if (root_page_no != FIL_NULL) { if (root_page_no != FIL_NULL) {
ulint len;
rec_t* rec = btr_pcur_get_rec(pcur); byte* data = rec_get_nth_field_old(
btr_pcur_get_rec(pcur),
page_rec_write_field( DICT_FLD__SYS_INDEXES__PAGE_NO, &len);
rec, DICT_FLD__SYS_INDEXES__PAGE_NO, ut_ad(len == 4);
root_page_no, mtr); mlog_write_ulint(data, root_page_no, MLOG_4BYTES, mtr);
/* We will need to commit and restart the /* We will need to commit and restart the
mini-transaction in order to avoid deadlocks. 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