mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
MDEV-17750: Remove unnecessary rec_get_offsets() in IMPORT TABLESPACE
row_import_set_sys_max_row_id(): Change the return type to void, and access the first column (DB_ROW_ID) directly.
This commit is contained in:
@ -479,12 +479,6 @@ ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE;
|
|||||||
ERROR HY000: Index for table 't1' is corrupt; try to repair it
|
ERROR HY000: Index for table 't1' is corrupt; try to repair it
|
||||||
SET SESSION debug_dbug=@saved_debug_dbug;
|
SET SESSION debug_dbug=@saved_debug_dbug;
|
||||||
restore: t1 .ibd and .cfg files
|
restore: t1 .ibd and .cfg files
|
||||||
SET SESSION debug_dbug="+d,ib_import_set_max_rowid_failure";
|
|
||||||
ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE;
|
|
||||||
ERROR HY000: Index for table 't1' is corrupt; try to repair it
|
|
||||||
SET SESSION debug_dbug=@saved_debug_dbug;
|
|
||||||
unlink: t1.ibd
|
|
||||||
unlink: t1.cfg
|
|
||||||
DROP TABLE test_wl5522.t1;
|
DROP TABLE test_wl5522.t1;
|
||||||
CREATE TABLE test_wl5522.t1 (
|
CREATE TABLE test_wl5522.t1 (
|
||||||
c1 BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
c1 BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
@ -1017,20 +1017,6 @@ do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
|
|||||||
ib_restore_tablespaces("test_wl5522", "t1");
|
ib_restore_tablespaces("test_wl5522", "t1");
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Test failure after importing the cluster index
|
|
||||||
SET SESSION debug_dbug="+d,ib_import_set_max_rowid_failure";
|
|
||||||
|
|
||||||
--error ER_NOT_KEYFILE
|
|
||||||
ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE;
|
|
||||||
|
|
||||||
SET SESSION debug_dbug=@saved_debug_dbug;
|
|
||||||
|
|
||||||
# Left over from the failed IMPORT
|
|
||||||
perl;
|
|
||||||
do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
|
|
||||||
ib_unlink_tablespace("test_wl5522", "t1");
|
|
||||||
EOF
|
|
||||||
|
|
||||||
DROP TABLE test_wl5522.t1;
|
DROP TABLE test_wl5522.t1;
|
||||||
|
|
||||||
--disable_query_log
|
--disable_query_log
|
||||||
|
@ -107,12 +107,6 @@ ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE;
|
|||||||
ERROR HY000: Index for table 't1' is corrupt; try to repair it
|
ERROR HY000: Index for table 't1' is corrupt; try to repair it
|
||||||
SET SESSION debug_dbug=@saved_debug_dbug;
|
SET SESSION debug_dbug=@saved_debug_dbug;
|
||||||
restore: t1 .ibd and .cfg files
|
restore: t1 .ibd and .cfg files
|
||||||
SET SESSION debug_dbug="+d,ib_import_set_max_rowid_failure";
|
|
||||||
ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE;
|
|
||||||
ERROR HY000: Index for table 't1' is corrupt; try to repair it
|
|
||||||
SET SESSION debug_dbug=@saved_debug_dbug;
|
|
||||||
unlink: t1.ibd
|
|
||||||
unlink: t1.cfg
|
|
||||||
DROP TABLE test_wl5522.t1;
|
DROP TABLE test_wl5522.t1;
|
||||||
CREATE TABLE test_wl5522.t1 (
|
CREATE TABLE test_wl5522.t1 (
|
||||||
c1 BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
c1 BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
@ -282,20 +282,6 @@ do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl";
|
|||||||
ib_restore_tablespaces("test_wl5522", "t1");
|
ib_restore_tablespaces("test_wl5522", "t1");
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Test failure after importing the cluster index
|
|
||||||
SET SESSION debug_dbug="+d,ib_import_set_max_rowid_failure";
|
|
||||||
|
|
||||||
--error ER_NOT_KEYFILE
|
|
||||||
ALTER TABLE test_wl5522.t1 IMPORT TABLESPACE;
|
|
||||||
|
|
||||||
SET SESSION debug_dbug=@saved_debug_dbug;
|
|
||||||
|
|
||||||
# Left over from the failed IMPORT
|
|
||||||
perl;
|
|
||||||
do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl";
|
|
||||||
ib_unlink_tablespace("test_wl5522", "t1");
|
|
||||||
EOF
|
|
||||||
|
|
||||||
DROP TABLE test_wl5522.t1;
|
DROP TABLE test_wl5522.t1;
|
||||||
|
|
||||||
--disable_query_log
|
--disable_query_log
|
||||||
|
@ -2227,17 +2227,15 @@ row_import_adjust_root_pages_of_secondary_indexes(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************//**
|
/*****************************************************************//**
|
||||||
Ensure that dict_sys->row_id exceeds SELECT MAX(DB_ROW_ID).
|
Ensure that dict_sys->row_id exceeds SELECT MAX(DB_ROW_ID). */
|
||||||
@return error code */
|
MY_ATTRIBUTE((nonnull)) static
|
||||||
static MY_ATTRIBUTE((nonnull, warn_unused_result))
|
void
|
||||||
dberr_t
|
|
||||||
row_import_set_sys_max_row_id(
|
row_import_set_sys_max_row_id(
|
||||||
/*==========================*/
|
/*==========================*/
|
||||||
row_prebuilt_t* prebuilt, /*!< in/out: prebuilt from
|
row_prebuilt_t* prebuilt, /*!< in/out: prebuilt from
|
||||||
handler */
|
handler */
|
||||||
const dict_table_t* table) /*!< in: table to import */
|
const dict_table_t* table) /*!< in: table to import */
|
||||||
{
|
{
|
||||||
dberr_t err;
|
|
||||||
const rec_t* rec;
|
const rec_t* rec;
|
||||||
mtr_t mtr;
|
mtr_t mtr;
|
||||||
btr_pcur_t pcur;
|
btr_pcur_t pcur;
|
||||||
@ -2245,7 +2243,8 @@ row_import_set_sys_max_row_id(
|
|||||||
dict_index_t* index;
|
dict_index_t* index;
|
||||||
|
|
||||||
index = dict_table_get_first_index(table);
|
index = dict_table_get_first_index(table);
|
||||||
ut_a(dict_index_is_clust(index));
|
ut_ad(index->is_primary());
|
||||||
|
ut_ad(dict_index_is_auto_gen_clust(index));
|
||||||
|
|
||||||
mtr_start(&mtr);
|
mtr_start(&mtr);
|
||||||
|
|
||||||
@ -2266,57 +2265,17 @@ row_import_set_sys_max_row_id(
|
|||||||
/* Check for empty table. */
|
/* Check for empty table. */
|
||||||
if (page_rec_is_infimum(rec)) {
|
if (page_rec_is_infimum(rec)) {
|
||||||
/* The table is empty. */
|
/* The table is empty. */
|
||||||
err = DB_SUCCESS;
|
|
||||||
} else if (rec_is_metadata(rec, *index)) {
|
} else if (rec_is_metadata(rec, *index)) {
|
||||||
/* The clustered index contains the metadata record only,
|
/* The clustered index contains the metadata record only,
|
||||||
that is, the table is empty. */
|
that is, the table is empty. */
|
||||||
err = DB_SUCCESS;
|
|
||||||
} else {
|
} else {
|
||||||
ulint len;
|
row_id = mach_read_from_6(rec);
|
||||||
const byte* field;
|
|
||||||
mem_heap_t* heap = NULL;
|
|
||||||
ulint offsets_[1 + REC_OFFS_HEADER_SIZE];
|
|
||||||
ulint* offsets;
|
|
||||||
|
|
||||||
rec_offs_init(offsets_);
|
|
||||||
|
|
||||||
offsets = rec_get_offsets(
|
|
||||||
rec, index, offsets_, true, ULINT_UNDEFINED, &heap);
|
|
||||||
|
|
||||||
field = rec_get_nth_field(
|
|
||||||
rec, offsets,
|
|
||||||
dict_index_get_sys_col_pos(index, DATA_ROW_ID),
|
|
||||||
&len);
|
|
||||||
|
|
||||||
if (len == DATA_ROW_ID_LEN) {
|
|
||||||
row_id = mach_read_from_6(field);
|
|
||||||
err = DB_SUCCESS;
|
|
||||||
} else {
|
|
||||||
err = DB_CORRUPTION;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (heap != NULL) {
|
|
||||||
mem_heap_free(heap);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
btr_pcur_close(&pcur);
|
btr_pcur_close(&pcur);
|
||||||
mtr_commit(&mtr);
|
mtr_commit(&mtr);
|
||||||
|
|
||||||
DBUG_EXECUTE_IF("ib_import_set_max_rowid_failure",
|
if (row_id) {
|
||||||
err = DB_CORRUPTION;);
|
|
||||||
|
|
||||||
if (err != DB_SUCCESS) {
|
|
||||||
ib_errf(prebuilt->trx->mysql_thd,
|
|
||||||
IB_LOG_LEVEL_WARN,
|
|
||||||
ER_INNODB_INDEX_CORRUPT,
|
|
||||||
"Index `%s` corruption detected, invalid DB_ROW_ID"
|
|
||||||
" in index.", index->name());
|
|
||||||
|
|
||||||
return(err);
|
|
||||||
|
|
||||||
} else if (row_id > 0) {
|
|
||||||
|
|
||||||
/* Update the system row id if the imported index row id is
|
/* Update the system row id if the imported index row id is
|
||||||
greater than the max system row id. */
|
greater than the max system row id. */
|
||||||
|
|
||||||
@ -2329,8 +2288,6 @@ row_import_set_sys_max_row_id(
|
|||||||
|
|
||||||
mutex_exit(&dict_sys->mutex);
|
mutex_exit(&dict_sys->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return(DB_SUCCESS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************//**
|
/*****************************************************************//**
|
||||||
@ -4076,12 +4033,7 @@ row_import_for_mysql(
|
|||||||
any DB_ROW_ID stored in the table. */
|
any DB_ROW_ID stored in the table. */
|
||||||
|
|
||||||
if (prebuilt->clust_index_was_generated) {
|
if (prebuilt->clust_index_was_generated) {
|
||||||
|
row_import_set_sys_max_row_id(prebuilt, table);
|
||||||
err = row_import_set_sys_max_row_id(prebuilt, table);
|
|
||||||
|
|
||||||
if (err != DB_SUCCESS) {
|
|
||||||
return(row_import_error(prebuilt, trx, err));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ib::info() << "Phase III - Flush changes to disk";
|
ib::info() << "Phase III - Flush changes to disk";
|
||||||
|
Reference in New Issue
Block a user