diff options
author | Jan Lindström <jan.lindstrom@mariadb.com> | 2016-09-29 13:59:41 +0300 |
---|---|---|
committer | Jan Lindström <jan.lindstrom@mariadb.com> | 2016-09-30 08:08:19 +0300 |
commit | 737295c75286a55507eadf42f4b648a118790f4d (patch) | |
tree | 0b95d6bba8ae296e4ab672cd50153e8593380a31 /storage | |
parent | b3f7d52e1e06bd60cacc1e689aa216d1562e80b6 (diff) | |
download | mariadb-git-737295c75286a55507eadf42f4b648a118790f4d.tar.gz |
MDEV-10727: Merge 5.7 Innochecksum with 5.6
Diffstat (limited to 'storage')
-rw-r--r-- | storage/innobase/include/fil0fil.ic | 23 | ||||
-rw-r--r-- | storage/innobase/page/page0zip.cc | 111 |
2 files changed, 108 insertions, 26 deletions
diff --git a/storage/innobase/include/fil0fil.ic b/storage/innobase/include/fil0fil.ic index b17bf8213ab..ae350333a16 100644 --- a/storage/innobase/include/fil0fil.ic +++ b/storage/innobase/include/fil0fil.ic @@ -89,6 +89,14 @@ fil_get_page_type_name( return (const char*)"ZBLOB2"; case FIL_PAGE_COMPRESSED: return (const char*)"ORACLE PAGE COMPRESSED"; + case FIL_PAGE_ENCRYPTED: + return (const char*)"ORACLE PAGE ENCRYPTED"; + case FIL_PAGE_COMPRESSED_AND_ENCRYPTED: + return (const char*)"ORACLE PAGE COMPRESSED AND ENCRYPTED"; + case FIL_PAGE_ENCRYPTED_RTREE: + return (const char*)"ORACLE RTREE ENCRYPTED"; + case FIL_PAGE_TYPE_UNKNOWN: + return (const char*)"OLD UNKOWN PAGE TYPE"; default: return (const char*)"PAGE TYPE CORRUPTED"; } @@ -133,7 +141,12 @@ fil_page_type_validate( page_type == FIL_PAGE_TYPE_XDES || page_type == FIL_PAGE_TYPE_BLOB || page_type == FIL_PAGE_TYPE_ZBLOB || - page_type == FIL_PAGE_COMPRESSED))) { + page_type == FIL_PAGE_TYPE_ZBLOB2 || + page_type == FIL_PAGE_COMPRESSED || + page_type == FIL_PAGE_TYPE_UNKNOWN || + page_type == FIL_PAGE_ENCRYPTED || + page_type == FIL_PAGE_COMPRESSED_AND_ENCRYPTED || + page_type == FIL_PAGE_ENCRYPTED_RTREE))) { uint key_version = mach_read_from_4(page + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION); bool page_compressed = (page_type == FIL_PAGE_PAGE_COMPRESSED); @@ -167,7 +180,13 @@ fil_page_type_validate( page_type == FIL_PAGE_TYPE_XDES || page_type == FIL_PAGE_TYPE_BLOB || page_type == FIL_PAGE_TYPE_ZBLOB || - page_type == FIL_PAGE_COMPRESSED); + page_type == FIL_PAGE_TYPE_ZBLOB2 || + page_type == FIL_PAGE_COMPRESSED || + page_type == FIL_PAGE_TYPE_UNKNOWN || + page_type == FIL_PAGE_ENCRYPTED || + page_type == FIL_PAGE_COMPRESSED_AND_ENCRYPTED || + page_type == FIL_PAGE_ENCRYPTED_RTREE); + return false; } diff --git a/storage/innobase/page/page0zip.cc b/storage/innobase/page/page0zip.cc index 35ae10fc1bb..d93b80778b5 100644 --- a/storage/innobase/page/page0zip.cc +++ b/storage/innobase/page/page0zip.cc @@ -5041,6 +5041,19 @@ page_zip_verify_checksum( const uint32_t stored = static_cast<uint32_t>( mach_read_from_4(p)); +#ifdef UNIV_INNOCHECKSUM + p = static_cast<const unsigned char*>(data) + FIL_PAGE_TYPE; + bool no_checksum = (mach_read_from_2(p) == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED); + p = static_cast<const unsigned char*>(data) + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION; + bool encrypted = (mach_read_from_4(p) != 0); + p = static_cast<const unsigned char*>(data) + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION + 4; + const uint32_t checksum = static_cast<uint32_t>(mach_read_from_4(p)); + + if (no_checksum) { + return (TRUE); + } +#endif + #if FIL_PAGE_LSN % 8 #error "FIL_PAGE_LSN must be 64 bit aligned" #endif @@ -5121,7 +5134,12 @@ page_zip_verify_checksum( } } #endif /* UNIV_INNOCHECKSUM */ - if (stored == calc) { + + if (stored == calc +#ifdef UNIV_INNOCHECKSUM + || ( encrypted == true && stored == checksum) +#endif + ) { return(TRUE); } @@ -5129,7 +5147,7 @@ page_zip_verify_checksum( switch (curr_algo) { case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32: - case SRV_CHECKSUM_ALGORITHM_CRC32: + case SRV_CHECKSUM_ALGORITHM_CRC32: { if (stored == BUF_NO_CHECKSUM_MAGIC) { #ifndef UNIV_INNOCHECKSUM @@ -5151,16 +5169,27 @@ page_zip_verify_checksum( matching legacy big endian checksum, we try to match it first. Otherwise we check innodb checksum first. */ if (legacy_big_endian_checksum) { - if (stored == page_zip_calc_checksum( - data, size, curr_algo, true)) { + const uint32_t calculated = + page_zip_calc_checksum(data, size, curr_algo, true); + if (stored == calculated +#ifdef UNIV_INNOCHECKSUM + || ( encrypted == true && calculated == checksum) +#endif + ) { return(TRUE); } legacy_checksum_checked = true; } - if (stored == page_zip_calc_checksum( - data, size, SRV_CHECKSUM_ALGORITHM_INNODB)) { + uint32_t calculated = + page_zip_calc_checksum(data, size, SRV_CHECKSUM_ALGORITHM_INNODB); + + if (stored == calculated +#ifdef UNIV_INNOCHECKSUM + || ( encrypted == true && stored == checksum) +#endif + ) { #ifndef UNIV_INNOCHECKSUM if (curr_algo @@ -5175,20 +5204,30 @@ page_zip_verify_checksum( return(TRUE); } - /* If legacy checksum is not checked, do it now. */ - if (!legacy_checksum_checked - && stored == page_zip_calc_checksum( - data, size, curr_algo, true)) { + calculated = page_zip_calc_checksum( + data, size, curr_algo, true); + /* If legacy checksum is not checked, do it now. */ + if ((legacy_checksum_checked + && stored == calculated) +#ifdef UNIV_INNOCHECKSUM + || ( encrypted == true && calculated == checksum) +#endif + ) { legacy_big_endian_checksum = true; - return(TRUE); + return(TRUE); } break; + } case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB: - case SRV_CHECKSUM_ALGORITHM_INNODB: + case SRV_CHECKSUM_ALGORITHM_INNODB: { - if (stored == BUF_NO_CHECKSUM_MAGIC) { + if (stored == BUF_NO_CHECKSUM_MAGIC +#ifdef UNIV_INNOCHECKSUM + || ( encrypted == true && checksum == BUF_NO_CHECKSUM_MAGIC) +#endif + ) { #ifndef UNIV_INNOCHECKSUM if (curr_algo == SRV_CHECKSUM_ALGORITHM_STRICT_INNODB) { @@ -5202,10 +5241,18 @@ page_zip_verify_checksum( return(TRUE); } - if (stored == page_zip_calc_checksum( - data, size, SRV_CHECKSUM_ALGORITHM_CRC32) - || stored == page_zip_calc_checksum( - data, size, SRV_CHECKSUM_ALGORITHM_CRC32, true)) { + const uint32_t calculated = page_zip_calc_checksum( + data, size, SRV_CHECKSUM_ALGORITHM_CRC32); + const uint32_t calculated1 = page_zip_calc_checksum( + data, size, SRV_CHECKSUM_ALGORITHM_CRC32, true); + + if (stored == calculated + || stored == calculated1 +#ifdef UNIV_INNOCHECKSUM + || ( encrypted == true && checksum == calculated) + || ( encrypted == true && checksum == calculated1) +#endif + ) { #ifndef UNIV_INNOCHECKSUM if (curr_algo == SRV_CHECKSUM_ALGORITHM_STRICT_INNODB) { @@ -5219,12 +5266,21 @@ page_zip_verify_checksum( } break; - case SRV_CHECKSUM_ALGORITHM_STRICT_NONE: + } + case SRV_CHECKSUM_ALGORITHM_STRICT_NONE: { + + uint32_t calculated = page_zip_calc_checksum( + data, size, SRV_CHECKSUM_ALGORITHM_CRC32); + const uint32_t calculated1 = page_zip_calc_checksum( + data, size, SRV_CHECKSUM_ALGORITHM_CRC32, true); - if (stored == page_zip_calc_checksum( - data, size, SRV_CHECKSUM_ALGORITHM_CRC32) - || stored == page_zip_calc_checksum( - data, size, SRV_CHECKSUM_ALGORITHM_CRC32, true)) { + if (stored == calculated + || stored == calculated1 +#ifdef UNIV_INNOCHECKSUM + || ( encrypted == true && checksum == calculated) + || ( encrypted == true && checksum == calculated1) +#endif + ) { #ifndef UNIV_INNOCHECKSUM page_warn_strict_checksum( curr_algo, @@ -5234,8 +5290,14 @@ page_zip_verify_checksum( return(TRUE); } - if (stored == page_zip_calc_checksum( - data, size, SRV_CHECKSUM_ALGORITHM_INNODB)) { + calculated = page_zip_calc_checksum( + data, size, SRV_CHECKSUM_ALGORITHM_INNODB); + + if (stored == calculated +#ifdef UNIV_INNOCHECKSUM + || ( encrypted == true && checksum == calculated) +#endif + ) { #ifndef UNIV_INNOCHECKSUM page_warn_strict_checksum( @@ -5247,6 +5309,7 @@ page_zip_verify_checksum( } break; + } case SRV_CHECKSUM_ALGORITHM_NONE: ut_error; /* no default so the compiler will emit a warning if new enum |