diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2018-11-16 19:31:58 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2018-11-16 20:37:00 +0200 |
commit | eea0c3c3e72c8ea5428dfb0c3310b680e5fd7045 (patch) | |
tree | 5bf0c7bc8bb6da47cc767f916f6f220547552d21 | |
parent | 3773bc594d2496a2dd882975e13fa8dff37b5eba (diff) | |
download | mariadb-git-eea0c3c3e72c8ea5428dfb0c3310b680e5fd7045.tar.gz |
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.
-rw-r--r-- | mysql-test/suite/innodb/r/innodb-wl5522-debug.result | 6 | ||||
-rw-r--r-- | mysql-test/suite/innodb/t/innodb-wl5522-debug.test | 14 | ||||
-rw-r--r-- | mysql-test/suite/innodb_zip/r/wl5522_debug_zip.result | 6 | ||||
-rw-r--r-- | mysql-test/suite/innodb_zip/t/wl5522_debug_zip.test | 14 | ||||
-rw-r--r-- | storage/innobase/row/row0import.cc | 64 |
5 files changed, 8 insertions, 96 deletions
diff --git a/mysql-test/suite/innodb/r/innodb-wl5522-debug.result b/mysql-test/suite/innodb/r/innodb-wl5522-debug.result index ec3856c20b8..ed7477fa033 100644 --- a/mysql-test/suite/innodb/r/innodb-wl5522-debug.result +++ b/mysql-test/suite/innodb/r/innodb-wl5522-debug.result @@ -479,12 +479,6 @@ 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; 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; CREATE TABLE test_wl5522.t1 ( c1 BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, diff --git a/mysql-test/suite/innodb/t/innodb-wl5522-debug.test b/mysql-test/suite/innodb/t/innodb-wl5522-debug.test index ca37521b9cf..15f8544088d 100644 --- a/mysql-test/suite/innodb/t/innodb-wl5522-debug.test +++ b/mysql-test/suite/innodb/t/innodb-wl5522-debug.test @@ -1017,20 +1017,6 @@ do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; ib_restore_tablespaces("test_wl5522", "t1"); 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; --disable_query_log diff --git a/mysql-test/suite/innodb_zip/r/wl5522_debug_zip.result b/mysql-test/suite/innodb_zip/r/wl5522_debug_zip.result index 394a2ea1f09..b3a4ad2b0ba 100644 --- a/mysql-test/suite/innodb_zip/r/wl5522_debug_zip.result +++ b/mysql-test/suite/innodb_zip/r/wl5522_debug_zip.result @@ -107,12 +107,6 @@ 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; 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; CREATE TABLE test_wl5522.t1 ( c1 BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, diff --git a/mysql-test/suite/innodb_zip/t/wl5522_debug_zip.test b/mysql-test/suite/innodb_zip/t/wl5522_debug_zip.test index 986c0508891..c81eca69db8 100644 --- a/mysql-test/suite/innodb_zip/t/wl5522_debug_zip.test +++ b/mysql-test/suite/innodb_zip/t/wl5522_debug_zip.test @@ -282,20 +282,6 @@ do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; ib_restore_tablespaces("test_wl5522", "t1"); 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; --disable_query_log diff --git a/storage/innobase/row/row0import.cc b/storage/innobase/row/row0import.cc index 8a861d1bf4c..f19e2dff943 100644 --- a/storage/innobase/row/row0import.cc +++ b/storage/innobase/row/row0import.cc @@ -2227,17 +2227,15 @@ row_import_adjust_root_pages_of_secondary_indexes( } /*****************************************************************//** -Ensure that dict_sys->row_id exceeds SELECT MAX(DB_ROW_ID). -@return error code */ -static MY_ATTRIBUTE((nonnull, warn_unused_result)) -dberr_t +Ensure that dict_sys->row_id exceeds SELECT MAX(DB_ROW_ID). */ +MY_ATTRIBUTE((nonnull)) static +void row_import_set_sys_max_row_id( /*==========================*/ row_prebuilt_t* prebuilt, /*!< in/out: prebuilt from handler */ const dict_table_t* table) /*!< in: table to import */ { - dberr_t err; const rec_t* rec; mtr_t mtr; btr_pcur_t pcur; @@ -2245,7 +2243,8 @@ row_import_set_sys_max_row_id( dict_index_t* index; 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); @@ -2266,57 +2265,17 @@ row_import_set_sys_max_row_id( /* Check for empty table. */ if (page_rec_is_infimum(rec)) { /* The table is empty. */ - err = DB_SUCCESS; } else if (rec_is_metadata(rec, *index)) { /* The clustered index contains the metadata record only, that is, the table is empty. */ - err = DB_SUCCESS; } else { - ulint len; - 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); - } + row_id = mach_read_from_6(rec); } btr_pcur_close(&pcur); mtr_commit(&mtr); - DBUG_EXECUTE_IF("ib_import_set_max_rowid_failure", - 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) { - + if (row_id) { /* Update the system row id if the imported index row id is greater than the max system row id. */ @@ -2329,8 +2288,6 @@ row_import_set_sys_max_row_id( mutex_exit(&dict_sys->mutex); } - - return(DB_SUCCESS); } /*****************************************************************//** @@ -4076,12 +4033,7 @@ row_import_for_mysql( any DB_ROW_ID stored in the table. */ if (prebuilt->clust_index_was_generated) { - - err = row_import_set_sys_max_row_id(prebuilt, table); - - if (err != DB_SUCCESS) { - return(row_import_error(prebuilt, trx, err)); - } + row_import_set_sys_max_row_id(prebuilt, table); } ib::info() << "Phase III - Flush changes to disk"; |