From 89723ce17959d61a993136e51104fc9b830ac67c Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Thu, 19 Aug 2021 12:34:31 +0530 Subject: [PATCH] After-merge fixup f84e28c119b495da77e197f7cd18af4048fc3126 --- .../suite/encryption/t/innodb_import.test | 3 ++- .../suite/innodb/t/full_crc32_import.test | 1 + storage/innobase/row/row0import.cc | 26 ++++++++++++++----- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/mysql-test/suite/encryption/t/innodb_import.test b/mysql-test/suite/encryption/t/innodb_import.test index 791a1757878..2e5470c5568 100644 --- a/mysql-test/suite/encryption/t/innodb_import.test +++ b/mysql-test/suite/encryption/t/innodb_import.test @@ -1,5 +1,6 @@ --source include/have_innodb.inc --- source include/have_example_key_management_plugin.inc +--source include/have_example_key_management_plugin.inc +--source include/innodb_checksum_algorithm.inc --echo # --echo # MDEV-26131 SEGV in ha_innobase::discard_or_import_tablespace --echo # diff --git a/mysql-test/suite/innodb/t/full_crc32_import.test b/mysql-test/suite/innodb/t/full_crc32_import.test index 02ce565c7f8..c9195111c05 100644 --- a/mysql-test/suite/innodb/t/full_crc32_import.test +++ b/mysql-test/suite/innodb/t/full_crc32_import.test @@ -134,6 +134,7 @@ EOF ALTER TABLE t1 IMPORT TABLESPACE; --enable_warnings ALTER TABLE t1 DROP INDEX idx1; +--replace_regex /opening '.*\/test\//opening '.\/test\// ALTER TABLE t1 IMPORT TABLESPACE; --disable_warnings SHOW CREATE TABLE t1; diff --git a/storage/innobase/row/row0import.cc b/storage/innobase/row/row0import.cc index 0585ac08542..a774143200a 100644 --- a/storage/innobase/row/row0import.cc +++ b/storage/innobase/row/row0import.cc @@ -665,7 +665,7 @@ struct FetchIndexRootPages : public AbstractCallback { @param block Block to use for IO @retval DB_SUCCESS or error code */ dberr_t run(const fil_iterator_t& iter, - buf_block_t* block) UNIV_NOTHROW; + buf_block_t* block) UNIV_NOTHROW override; /** Called for each block as it is read from the file. @param block block to convert, it is not from the buffer pool. @@ -839,7 +839,8 @@ public: } } - dberr_t run(const fil_iterator_t& iter, buf_block_t* block) UNIV_NOTHROW + dberr_t run(const fil_iterator_t& iter, + buf_block_t* block) UNIV_NOTHROW override { return fil_iterate(iter, block, *this); } @@ -3448,6 +3449,8 @@ dberr_t FetchIndexRootPages::run(const fil_iterator_t& iter, #endif srv_page_size; byte* page_compress_buf = static_cast(malloc(buf_size)); + const bool full_crc32 = fil_space_t::full_crc32(m_space_flags); + bool skip_checksum_check = false; ut_ad(!srv_read_only_mode); if (!page_compress_buf) @@ -3486,15 +3489,18 @@ page_corrupted: goto func_exit; } - page_compressed= fil_page_is_compressed_encrypted(readptr) || - fil_page_is_compressed(readptr); + page_compressed= + (full_crc32 && fil_space_t::is_compressed(m_space_flags) && + buf_page_is_compressed(readptr, m_space_flags)) || + (fil_page_is_compressed_encrypted(readptr) || + fil_page_is_compressed(readptr)); if (page_compressed && block->page.zip.data) goto page_corrupted; if (encrypted) { - if (!fil_space_verify_crypt_checksum(readptr, zip_size)) + if (!buf_page_verify_crypt_checksum(readptr, m_space_flags)) goto page_corrupted; if (!fil_space_decrypt(get_space_id(), iter.crypt_data, readptr, @@ -3503,15 +3509,21 @@ page_corrupted: goto func_exit; } + /* For full_crc32 format, skip checksum check + after decryption. */ + skip_checksum_check= full_crc32 && encrypted; + if (page_compressed) { - ulint compress_length= fil_page_decompress(page_compress_buf, readptr, + ulint compress_length= fil_page_decompress(page_compress_buf, + readptr, m_space_flags); ut_ad(compress_length != srv_page_size); if (compress_length == 0) goto page_corrupted; } - else if (buf_page_is_corrupted(false, readptr, m_space_flags)) + else if (!skip_checksum_check + && buf_page_is_corrupted(false, readptr, m_space_flags)) goto page_corrupted; err= this->operator()(block);