diff options
38 files changed, 250 insertions, 1844 deletions
diff --git a/extra/innochecksum.cc b/extra/innochecksum.cc index 833e66341c7..02aec1bd919 100644 --- a/extra/innochecksum.cc +++ b/extra/innochecksum.cc @@ -1,6 +1,6 @@ /* Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. - Copyright (c) 2014, 2020, MariaDB Corporation. + Copyright (c) 2014, 2021, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -68,7 +68,6 @@ static bool do_one_page; static my_bool do_leaf; static my_bool per_page_details; static ulint n_merge; -extern ulong srv_checksum_algorithm; static ulint physical_page_size; /* Page size in bytes on disk. */ ulong srv_page_size; ulong srv_page_size_shift; @@ -78,8 +77,6 @@ unsigned long long cur_page_num; unsigned long long cur_space; /* Skip the checksum verification. */ static bool no_check; -/* Enabled for strict checksum verification. */ -bool strict_verify = 0; /* Enabled for rewrite checksum. */ static bool do_write; /* Mismatches count allowed (0 by default). */ @@ -102,11 +99,6 @@ static bool is_log_enabled = false; struct flock lk; #endif /* _WIN32 */ -/* Strict check algorithm name. */ -static ulong strict_check; -/* Rewrite checksum algorithm name. */ -static ulong write_check; - /* Innodb page type. */ struct innodb_page_type { int n_undo_state_active; @@ -136,24 +128,6 @@ struct innodb_page_type { int n_fil_page_type_page_compressed_encrypted; } page_type; -/* Possible values for "--strict-check" for strictly verify checksum -and "--write" for rewrite checksum. */ -static const char *innochecksum_algorithms[] = { - "crc32", - "crc32", - "innodb", - "innodb", - "none", - "none", - NullS -}; - -/* Used to define an enumerate type of the "innochecksum algorithm". */ -static TYPELIB innochecksum_algorithms_typelib = { - array_elements(innochecksum_algorithms)-1,"", - innochecksum_algorithms, NULL -}; - #define SIZE_RANGES_FOR_PAGE 10 #define NUM_RETRIES 3 #define DEFAULT_RETRY_DELAY 1000000 @@ -646,10 +620,9 @@ static bool update_checksum(byte* page, ulint flags) } if (iscompressed) { - /* page is compressed */ - checksum = page_zip_calc_checksum( - page, physical_page_size, - static_cast<srv_checksum_algorithm_t>(write_check)); + /* ROW_FORMAT=COMPRESSED */ + checksum = page_zip_calc_checksum(page, physical_page_size, + false); mach_write_to_4(page + FIL_PAGE_SPACE_OR_CHKSUM, checksum); if (is_log_enabled) { @@ -673,50 +646,16 @@ static bool update_checksum(byte* page, ulint flags) /* page is uncompressed. */ /* Store the new formula checksum */ - switch ((srv_checksum_algorithm_t) write_check) { - - case SRV_CHECKSUM_ALGORITHM_FULL_CRC32: - case SRV_CHECKSUM_ALGORITHM_STRICT_FULL_CRC32: - case SRV_CHECKSUM_ALGORITHM_CRC32: - case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32: - checksum = buf_calc_page_crc32(page); - break; - - case SRV_CHECKSUM_ALGORITHM_INNODB: - case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB: - checksum = (ib_uint32_t) - buf_calc_page_new_checksum(page); - break; - - case SRV_CHECKSUM_ALGORITHM_NONE: - case SRV_CHECKSUM_ALGORITHM_STRICT_NONE: - checksum = BUF_NO_CHECKSUM_MAGIC; - break; - - /* no default so the compiler will emit a warning if new - enum is added and not handled here */ - } + checksum = buf_calc_page_crc32(page); mach_write_to_4(page + FIL_PAGE_SPACE_OR_CHKSUM, checksum); if (is_log_enabled) { - fprintf(log_file, "page::%llu; Updated checksum field1" + fprintf(log_file, "page::%llu; Updated checksum" " = %u\n", cur_page_num, checksum); } - if (write_check == SRV_CHECKSUM_ALGORITHM_STRICT_INNODB - || write_check == SRV_CHECKSUM_ALGORITHM_INNODB) { - checksum = (ib_uint32_t) - buf_calc_page_old_checksum(page); - } - mach_write_to_4(page + physical_page_size - FIL_PAGE_END_LSN_OLD_CHKSUM,checksum); - - if (is_log_enabled) { - fprintf(log_file, "page::%llu; Updated checksum " - "field2 = %u\n", cur_page_num, checksum); - } - } func_exit: @@ -1270,17 +1209,11 @@ static struct my_option innochecksum_options[] = { {"page", 'p', "Check only this page (0 based).", &do_page, &do_page, 0, GET_ULL, REQUIRED_ARG, 0, 0, ULLONG_MAX, 0, 1, 0}, - {"strict-check", 'C', "Specify the strict checksum algorithm by the user.", - &strict_check, &strict_check, &innochecksum_algorithms_typelib, - GET_ENUM, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"no-check", 'n', "Ignore the checksum verification.", &no_check, &no_check, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"allow-mismatches", 'a', "Maximum checksum mismatch allowed.", &allow_mismatches, &allow_mismatches, 0, GET_ULL, REQUIRED_ARG, 0, 0, ULLONG_MAX, 0, 1, 0}, - {"write", 'w', "Rewrite the checksum algorithm by the user.", - &write_check, &write_check, &innochecksum_algorithms_typelib, - GET_ENUM, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"page-type-summary", 'S', "Display a count of each page type " "in a tablespace.", &page_type_summary, &page_type_summary, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -1321,7 +1254,7 @@ static void usage(void) printf("InnoDB offline file checksum utility.\n"); printf("Usage: %s [-c] [-s <start page>] [-e <end page>] " "[-p <page>] [-i] [-v] [-a <allow mismatches>] [-n] " - "[-C <strict-check>] [-w <write>] [-S] [-D <page type dump>] " + "[-S] [-D <page type dump>] " "[-l <log>] [-l] [-m <merge pages>] <filename or [-]>\n", my_progname); printf("See https://mariadb.com/kb/en/library/innochecksum/" " for usage hints.\n"); @@ -1358,38 +1291,6 @@ innochecksum_get_one_option( my_end(0); exit(EXIT_SUCCESS); break; - case 'C': - strict_verify = true; - switch ((srv_checksum_algorithm_t) strict_check) { - - case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32: - case SRV_CHECKSUM_ALGORITHM_CRC32: - srv_checksum_algorithm = - SRV_CHECKSUM_ALGORITHM_STRICT_CRC32; - break; - - case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB: - case SRV_CHECKSUM_ALGORITHM_INNODB: - srv_checksum_algorithm = - SRV_CHECKSUM_ALGORITHM_STRICT_INNODB; - break; - - case SRV_CHECKSUM_ALGORITHM_STRICT_NONE: - case SRV_CHECKSUM_ALGORITHM_NONE: - srv_checksum_algorithm = - SRV_CHECKSUM_ALGORITHM_STRICT_NONE; - break; - - case SRV_CHECKSUM_ALGORITHM_STRICT_FULL_CRC32: - case SRV_CHECKSUM_ALGORITHM_FULL_CRC32: - srv_checksum_algorithm = - SRV_CHECKSUM_ALGORITHM_STRICT_FULL_CRC32; - break; - - default: - return(true); - } - break; case 'n': no_check = true; break; @@ -1592,13 +1493,6 @@ int main( goto my_exit; } - if (strict_verify && no_check) { - fprintf(stderr, "Error: --strict-check option cannot be used " - "together with --no-check option.\n"); - exit_status = 1; - goto my_exit; - } - if (no_check && !do_write) { fprintf(stderr, "Error: --no-check must be associated with " "--write option.\n"); diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index 56ce2a58eff..31add72d831 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -1556,7 +1556,7 @@ struct my_option xb_server_options[] = {"innodb_checksum_algorithm", OPT_INNODB_CHECKSUM_ALGORITHM, "The algorithm InnoDB uses for page checksumming. [CRC32, STRICT_CRC32, " - "INNODB, STRICT_INNODB, NONE, STRICT_NONE]", &srv_checksum_algorithm, + "FULL_CRC32, STRICT_FULL_CRC32]", &srv_checksum_algorithm, &srv_checksum_algorithm, &innodb_checksum_algorithm_typelib, GET_ENUM, REQUIRED_ARG, SRV_CHECKSUM_ALGORITHM_CRC32, 0, 0, 0, 0, 0}, diff --git a/mysql-test/include/innodb_checksum_algorithm.combinations b/mysql-test/include/innodb_checksum_algorithm.combinations index 039bfaef676..4bdd89ae579 100644 --- a/mysql-test/include/innodb_checksum_algorithm.combinations +++ b/mysql-test/include/innodb_checksum_algorithm.combinations @@ -1,13 +1,6 @@ -[crc32] ---innodb-checksum-algorithm=crc32 - [strict_crc32] --innodb-checksum-algorithm=strict_crc32 --innodb-flush-sync=OFF -[full_crc32] ---innodb-checksum-algorithm=full_crc32 - [strict_full_crc32] --innodb-checksum-algorithm=strict_full_crc32 ---innodb-flush-sync=OFF diff --git a/mysql-test/suite/encryption/r/corrupted_during_recovery.result b/mysql-test/suite/encryption/r/corrupted_during_recovery.result index ea2f1ff3328..356dce64f8d 100644 --- a/mysql-test/suite/encryption/r/corrupted_during_recovery.result +++ b/mysql-test/suite/encryption/r/corrupted_during_recovery.result @@ -1,5 +1,3 @@ -# Work around MDEV-19541 -SET GLOBAL innodb_checksum_algorithm=crc32; CREATE TABLE t1(a BIGINT PRIMARY KEY) ENGINE=InnoDB, ENCRYPTED=YES; INSERT INTO t1 VALUES(1); CREATE TABLE t2(a BIGINT PRIMARY KEY) ENGINE=InnoDB, ENCRYPTED=YES; diff --git a/mysql-test/suite/encryption/r/innodb-checksum-algorithm,32k.rdiff b/mysql-test/suite/encryption/r/innodb-checksum-algorithm,32k.rdiff index d963cde132a..d8407ce5a03 100644 --- a/mysql-test/suite/encryption/r/innodb-checksum-algorithm,32k.rdiff +++ b/mysql-test/suite/encryption/r/innodb-checksum-algorithm,32k.rdiff @@ -1,38 +1,14 @@ --- suite/encryption/r/innodb-checksum-algorithm.result +++ suite/encryption/r/innodb-checksum-algorithm.result -@@ -13,9 +13,9 @@ +@@ -9,9 +9,9 @@ + SET GLOBAL innodb_checksum_algorithm = crc32; SET GLOBAL innodb_default_encryption_key_id=4; - SET GLOBAL innodb_checksum_algorithm=crc32; - create table tce_crc32(a serial, b blob, index(b(10))) engine=innodb + create table tce(a serial, b blob, index(b(10))) engine=innodb -ROW_FORMAT=COMPRESSED encrypted=yes; +ROW_FORMAT=DYNAMIC encrypted=yes; - create table tc_crc32(a serial, b blob, index(b(10))) engine=innodb + create table tc(a serial, b blob, index(b(10))) engine=innodb -ROW_FORMAT=COMPRESSED encrypted=no; +ROW_FORMAT=DYNAMIC encrypted=no; Warnings: Warning 140 InnoDB: ENCRYPTED=NO implies ENCRYPTION_KEY_ID=1 - create table te_crc32(a serial, b blob, index(b(10))) engine=innodb -@@ -153,9 +153,9 @@ - t_crc32, tpe_crc32, tp_crc32; - SET GLOBAL innodb_checksum_algorithm=innodb; - create table tce_innodb(a serial, b blob, index(b(10))) engine=innodb --ROW_FORMAT=COMPRESSED encrypted=yes; -+ROW_FORMAT=DYNAMIC encrypted=yes; - create table tc_innodb(a serial, b blob, index(b(10))) engine=innodb --ROW_FORMAT=COMPRESSED encrypted=no; -+ROW_FORMAT=DYNAMIC encrypted=no; - Warnings: - Warning 140 InnoDB: ENCRYPTED=NO implies ENCRYPTION_KEY_ID=1 - create table te_innodb(a serial, b blob, index(b(10))) engine=innodb -@@ -293,9 +293,9 @@ - t_innodb, tpe_innodb, tp_innodb; - SET GLOBAL innodb_checksum_algorithm=none; - create table tce_none(a serial, b blob, index(b(10))) engine=innodb --ROW_FORMAT=COMPRESSED encrypted=yes; -+ROW_FORMAT=DYNAMIC encrypted=yes; - create table tc_none(a serial, b blob, index(b(10))) engine=innodb --ROW_FORMAT=COMPRESSED encrypted=no; -+ROW_FORMAT=DYNAMIC encrypted=no; - Warnings: - Warning 140 InnoDB: ENCRYPTED=NO implies ENCRYPTION_KEY_ID=1 - create table te_none(a serial, b blob, index(b(10))) engine=innodb + create table te(a serial, b blob, index(b(10))) engine=innodb diff --git a/mysql-test/suite/encryption/r/innodb-checksum-algorithm,64k.rdiff b/mysql-test/suite/encryption/r/innodb-checksum-algorithm,64k.rdiff index d963cde132a..d8407ce5a03 100644 --- a/mysql-test/suite/encryption/r/innodb-checksum-algorithm,64k.rdiff +++ b/mysql-test/suite/encryption/r/innodb-checksum-algorithm,64k.rdiff @@ -1,38 +1,14 @@ --- suite/encryption/r/innodb-checksum-algorithm.result +++ suite/encryption/r/innodb-checksum-algorithm.result -@@ -13,9 +13,9 @@ +@@ -9,9 +9,9 @@ + SET GLOBAL innodb_checksum_algorithm = crc32; SET GLOBAL innodb_default_encryption_key_id=4; - SET GLOBAL innodb_checksum_algorithm=crc32; - create table tce_crc32(a serial, b blob, index(b(10))) engine=innodb + create table tce(a serial, b blob, index(b(10))) engine=innodb -ROW_FORMAT=COMPRESSED encrypted=yes; +ROW_FORMAT=DYNAMIC encrypted=yes; - create table tc_crc32(a serial, b blob, index(b(10))) engine=innodb + create table tc(a serial, b blob, index(b(10))) engine=innodb -ROW_FORMAT=COMPRESSED encrypted=no; +ROW_FORMAT=DYNAMIC encrypted=no; Warnings: Warning 140 InnoDB: ENCRYPTED=NO implies ENCRYPTION_KEY_ID=1 - create table te_crc32(a serial, b blob, index(b(10))) engine=innodb -@@ -153,9 +153,9 @@ - t_crc32, tpe_crc32, tp_crc32; - SET GLOBAL innodb_checksum_algorithm=innodb; - create table tce_innodb(a serial, b blob, index(b(10))) engine=innodb --ROW_FORMAT=COMPRESSED encrypted=yes; -+ROW_FORMAT=DYNAMIC encrypted=yes; - create table tc_innodb(a serial, b blob, index(b(10))) engine=innodb --ROW_FORMAT=COMPRESSED encrypted=no; -+ROW_FORMAT=DYNAMIC encrypted=no; - Warnings: - Warning 140 InnoDB: ENCRYPTED=NO implies ENCRYPTION_KEY_ID=1 - create table te_innodb(a serial, b blob, index(b(10))) engine=innodb -@@ -293,9 +293,9 @@ - t_innodb, tpe_innodb, tp_innodb; - SET GLOBAL innodb_checksum_algorithm=none; - create table tce_none(a serial, b blob, index(b(10))) engine=innodb --ROW_FORMAT=COMPRESSED encrypted=yes; -+ROW_FORMAT=DYNAMIC encrypted=yes; - create table tc_none(a serial, b blob, index(b(10))) engine=innodb --ROW_FORMAT=COMPRESSED encrypted=no; -+ROW_FORMAT=DYNAMIC encrypted=no; - Warnings: - Warning 140 InnoDB: ENCRYPTED=NO implies ENCRYPTION_KEY_ID=1 - create table te_none(a serial, b blob, index(b(10))) engine=innodb + create table te(a serial, b blob, index(b(10))) engine=innodb diff --git a/mysql-test/suite/encryption/r/innodb-checksum-algorithm.result b/mysql-test/suite/encryption/r/innodb-checksum-algorithm.result index ff42e975b8d..7b97eb6b5bd 100644 --- a/mysql-test/suite/encryption/r/innodb-checksum-algorithm.result +++ b/mysql-test/suite/encryption/r/innodb-checksum-algorithm.result @@ -1,439 +1,98 @@ SET @saved_file_per_table = @@global.innodb_file_per_table; -SET @saved_checksum_algorithm = @@global.innodb_checksum_algorithm; SET @saved_encrypt_tables = @@global.innodb_encrypt_tables; SET @saved_encryption_threads = @@global.innodb_encryption_threads; SET @saved_encryption_key_id = @@global.innodb_default_encryption_key_id; SET GLOBAL innodb_file_per_table = ON; SET GLOBAL innodb_encrypt_tables = ON; SET GLOBAL innodb_encryption_threads = 4; -call mtr.add_suppression("InnoDB: innodb_checksum_algorithm is set to \"strict_(crc32|none|innodb)\" but the page \\[page id: space=[0-9]+, page number=[0-9]+\\] contains a valid checksum \"(innodb|none|crc32)\""); -SET GLOBAL innodb_checksum_algorithm = innodb; SET GLOBAL innodb_default_encryption_key_id=4; -SET GLOBAL innodb_checksum_algorithm=crc32; -create table tce_crc32(a serial, b blob, index(b(10))) engine=innodb +create table tce(a serial, b blob, index(b(10))) engine=innodb ROW_FORMAT=COMPRESSED encrypted=yes; -create table tc_crc32(a serial, b blob, index(b(10))) engine=innodb +create table tc(a serial, b blob, index(b(10))) engine=innodb ROW_FORMAT=COMPRESSED encrypted=no; Warnings: Warning 140 InnoDB: ENCRYPTED=NO implies ENCRYPTION_KEY_ID=1 -create table te_crc32(a serial, b blob, index(b(10))) engine=innodb +create table te(a serial, b blob, index(b(10))) engine=innodb encrypted=yes; -create table t_crc32(a serial, b blob, index(b(10))) engine=innodb +create table t(a serial, b blob, index(b(10))) engine=innodb encrypted=no; Warnings: Warning 140 InnoDB: ENCRYPTED=NO implies ENCRYPTION_KEY_ID=1 -create table tpe_crc32(a serial, b blob, index(b(10))) engine=innodb +create table tpe(a serial, b blob, index(b(10))) engine=innodb page_compressed=yes encrypted=yes; -create table tp_crc32(a serial, b blob, index(b(10))) engine=innodb +create table tp(a serial, b blob, index(b(10))) engine=innodb page_compressed=yes encrypted=no; Warnings: Warning 140 InnoDB: ENCRYPTED=NO implies ENCRYPTION_KEY_ID=1 begin; -insert into tce_crc32(b) values (repeat('secret',20)); -insert into tc_crc32(b) values (repeat('secret',20)); -insert into te_crc32(b) values (repeat('secret',20)); -insert into t_crc32(b) values (repeat('secret',20)); -insert into tpe_crc32(b) values (repeat('secret',20)); -insert into tp_crc32(b) values (repeat('secret',20)); +insert into tce(b) values (repeat('secret',20)); +insert into tc(b) values (repeat('secret',20)); +insert into te(b) values (repeat('secret',20)); +insert into t(b) values (repeat('secret',20)); +insert into tpe(b) values (repeat('secret',20)); +insert into tp(b) values (repeat('secret',20)); commit; -FLUSH TABLES tce_crc32, tc_crc32, te_crc32, -t_crc32, tpe_crc32, tp_crc32 FOR EXPORT; -backup: tce_crc32 -backup: tc_crc32 -backup: te_crc32 -backup: t_crc32 -backup: tpe_crc32 -backup: tp_crc32 +FLUSH TABLES tce, tc, te, t, tpe, tp FOR EXPORT; +backup: tce +backup: tc +backup: te +backup: t +backup: tpe +backup: tp db.opt -t_crc32.cfg -t_crc32.frm -t_crc32.ibd -tc_crc32.cfg -tc_crc32.frm -tc_crc32.ibd -tce_crc32.cfg -tce_crc32.frm -tce_crc32.ibd -te_crc32.cfg -te_crc32.frm -te_crc32.ibd -tp_crc32.cfg -tp_crc32.frm -tp_crc32.ibd -tpe_crc32.cfg -tpe_crc32.frm -tpe_crc32.ibd +t.cfg +t.frm +t.ibd +tc.cfg +tc.frm +tc.ibd +tce.cfg +tce.frm +tce.ibd +te.cfg +te.frm +te.ibd +tp.cfg +tp.frm +tp.ibd +tpe.cfg +tpe.frm +tpe.ibd UNLOCK TABLES; -SET GLOBAL innodb_checksum_algorithm=crc32; -ALTER TABLE tce_crc32 DISCARD TABLESPACE; -ALTER TABLE tc_crc32 DISCARD TABLESPACE; -ALTER TABLE te_crc32 DISCARD TABLESPACE; -ALTER TABLE t_crc32 DISCARD TABLESPACE; -ALTER TABLE tpe_crc32 DISCARD TABLESPACE; -ALTER TABLE tp_crc32 DISCARD TABLESPACE; -restore: tce_crc32 .ibd and .cfg files -restore: tc_crc32 .ibd and .cfg files -restore: te_crc32 .ibd and .cfg files -restore: t_crc32 .ibd and .cfg files -restore: tpe_crc32 .ibd and .cfg files -restore: tp_crc32 .ibd and .cfg files -ALTER TABLE tce_crc32 IMPORT TABLESPACE; -update tce_crc32 set b=substr(b,1); -ALTER TABLE tc_crc32 IMPORT TABLESPACE; -update tc_crc32 set b=substr(b,1); -ALTER TABLE te_crc32 IMPORT TABLESPACE; -update te_crc32 set b=substr(b,1); -ALTER TABLE t_crc32 IMPORT TABLESPACE; -update t_crc32 set b=substr(b,1); -ALTER TABLE tpe_crc32 IMPORT TABLESPACE; -update tpe_crc32 set b=substr(b,1); -ALTER TABLE tp_crc32 IMPORT TABLESPACE; -update tp_crc32 set b=substr(b,1); -SET GLOBAL innodb_checksum_algorithm=innodb; -ALTER TABLE tce_crc32 DISCARD TABLESPACE; -ALTER TABLE tc_crc32 DISCARD TABLESPACE; -ALTER TABLE te_crc32 DISCARD TABLESPACE; -ALTER TABLE t_crc32 DISCARD TABLESPACE; -ALTER TABLE tpe_crc32 DISCARD TABLESPACE; -ALTER TABLE tp_crc32 DISCARD TABLESPACE; -restore: tce_crc32 .ibd and .cfg files -restore: tc_crc32 .ibd and .cfg files -restore: te_crc32 .ibd and .cfg files -restore: t_crc32 .ibd and .cfg files -restore: tpe_crc32 .ibd and .cfg files -restore: tp_crc32 .ibd and .cfg files -ALTER TABLE tce_crc32 IMPORT TABLESPACE; -update tce_crc32 set b=substr(b,1); -ALTER TABLE tc_crc32 IMPORT TABLESPACE; -update tc_crc32 set b=substr(b,1); -ALTER TABLE te_crc32 IMPORT TABLESPACE; -update te_crc32 set b=substr(b,1); -ALTER TABLE t_crc32 IMPORT TABLESPACE; -update t_crc32 set b=substr(b,1); -ALTER TABLE tpe_crc32 IMPORT TABLESPACE; -update tpe_crc32 set b=substr(b,1); -ALTER TABLE tp_crc32 IMPORT TABLESPACE; -update tp_crc32 set b=substr(b,1); -SET GLOBAL innodb_checksum_algorithm=none; -ALTER TABLE tce_crc32 DISCARD TABLESPACE; -ALTER TABLE tc_crc32 DISCARD TABLESPACE; -ALTER TABLE te_crc32 DISCARD TABLESPACE; -ALTER TABLE t_crc32 DISCARD TABLESPACE; -ALTER TABLE tpe_crc32 DISCARD TABLESPACE; -ALTER TABLE tp_crc32 DISCARD TABLESPACE; -restore: tce_crc32 .ibd and .cfg files -restore: tc_crc32 .ibd and .cfg files -restore: te_crc32 .ibd and .cfg files -restore: t_crc32 .ibd and .cfg files -restore: tpe_crc32 .ibd and .cfg files -restore: tp_crc32 .ibd and .cfg files -ALTER TABLE tce_crc32 IMPORT TABLESPACE; -update tce_crc32 set b=substr(b,1); -ALTER TABLE tc_crc32 IMPORT TABLESPACE; -update tc_crc32 set b=substr(b,1); -ALTER TABLE te_crc32 IMPORT TABLESPACE; -update te_crc32 set b=substr(b,1); -ALTER TABLE t_crc32 IMPORT TABLESPACE; -update t_crc32 set b=substr(b,1); -ALTER TABLE tpe_crc32 IMPORT TABLESPACE; -update tpe_crc32 set b=substr(b,1); -ALTER TABLE tp_crc32 IMPORT TABLESPACE; -update tp_crc32 set b=substr(b,1); -CHECK TABLE tce_crc32, tc_crc32, te_crc32, -t_crc32, tpe_crc32, tp_crc32; +ALTER TABLE tce DISCARD TABLESPACE; +ALTER TABLE tc DISCARD TABLESPACE; +ALTER TABLE te DISCARD TABLESPACE; +ALTER TABLE t DISCARD TABLESPACE; +ALTER TABLE tpe DISCARD TABLESPACE; +ALTER TABLE tp DISCARD TABLESPACE; +restore: tce .ibd and .cfg files +restore: tc .ibd and .cfg files +restore: te .ibd and .cfg files +restore: t .ibd and .cfg files +restore: tpe .ibd and .cfg files +restore: tp .ibd and .cfg files +ALTER TABLE tce IMPORT TABLESPACE; +update tce set b=substr(b,1); +ALTER TABLE tc IMPORT TABLESPACE; +update tc set b=substr(b,1); +ALTER TABLE te IMPORT TABLESPACE; +update te set b=substr(b,1); +ALTER TABLE t IMPORT TABLESPACE; +update t set b=substr(b,1); +ALTER TABLE tpe IMPORT TABLESPACE; +update tpe set b=substr(b,1); +ALTER TABLE tp IMPORT TABLESPACE; +update tp set b=substr(b,1); +CHECK TABLE tce, tc, te, t, tpe, tp; Table Op Msg_type Msg_text -test.tce_crc32 check status OK -test.tc_crc32 check status OK -test.te_crc32 check status OK -test.t_crc32 check status OK -test.tpe_crc32 check status OK -test.tp_crc32 check status OK -DROP TABLE tce_crc32, tc_crc32, te_crc32, -t_crc32, tpe_crc32, tp_crc32; -SET GLOBAL innodb_checksum_algorithm=innodb; -create table tce_innodb(a serial, b blob, index(b(10))) engine=innodb -ROW_FORMAT=COMPRESSED encrypted=yes; -create table tc_innodb(a serial, b blob, index(b(10))) engine=innodb -ROW_FORMAT=COMPRESSED encrypted=no; -Warnings: -Warning 140 InnoDB: ENCRYPTED=NO implies ENCRYPTION_KEY_ID=1 -create table te_innodb(a serial, b blob, index(b(10))) engine=innodb -encrypted=yes; -create table t_innodb(a serial, b blob, index(b(10))) engine=innodb -encrypted=no; -Warnings: -Warning 140 InnoDB: ENCRYPTED=NO implies ENCRYPTION_KEY_ID=1 -create table tpe_innodb(a serial, b blob, index(b(10))) engine=innodb -page_compressed=yes encrypted=yes; -create table tp_innodb(a serial, b blob, index(b(10))) engine=innodb -page_compressed=yes encrypted=no; -Warnings: -Warning 140 InnoDB: ENCRYPTED=NO implies ENCRYPTION_KEY_ID=1 -begin; -insert into tce_innodb(b) values (repeat('secret',20)); -insert into tc_innodb(b) values (repeat('secret',20)); -insert into te_innodb(b) values (repeat('secret',20)); -insert into t_innodb(b) values (repeat('secret',20)); -insert into tpe_innodb(b) values (repeat('secret',20)); -insert into tp_innodb(b) values (repeat('secret',20)); -commit; -FLUSH TABLES tce_innodb, tc_innodb, te_innodb, -t_innodb, tpe_innodb, tp_innodb FOR EXPORT; -backup: tce_innodb -backup: tc_innodb -backup: te_innodb -backup: t_innodb -backup: tpe_innodb -backup: tp_innodb -db.opt -t_innodb.cfg -t_innodb.frm -t_innodb.ibd -tc_innodb.cfg -tc_innodb.frm -tc_innodb.ibd -tce_innodb.cfg -tce_innodb.frm -tce_innodb.ibd -te_innodb.cfg -te_innodb.frm -te_innodb.ibd -tp_innodb.cfg -tp_innodb.frm -tp_innodb.ibd -tpe_innodb.cfg -tpe_innodb.frm -tpe_innodb.ibd -UNLOCK TABLES; -SET GLOBAL innodb_checksum_algorithm=crc32; -ALTER TABLE tce_innodb DISCARD TABLESPACE; -ALTER TABLE tc_innodb DISCARD TABLESPACE; -ALTER TABLE te_innodb DISCARD TABLESPACE; -ALTER TABLE t_innodb DISCARD TABLESPACE; -ALTER TABLE tpe_innodb DISCARD TABLESPACE; -ALTER TABLE tp_innodb DISCARD TABLESPACE; -restore: tce_innodb .ibd and .cfg files -restore: tc_innodb .ibd and .cfg files -restore: te_innodb .ibd and .cfg files -restore: t_innodb .ibd and .cfg files -restore: tpe_innodb .ibd and .cfg files -restore: tp_innodb .ibd and .cfg files -ALTER TABLE tce_innodb IMPORT TABLESPACE; -update tce_innodb set b=substr(b,1); -ALTER TABLE tc_innodb IMPORT TABLESPACE; -update tc_innodb set b=substr(b,1); -ALTER TABLE te_innodb IMPORT TABLESPACE; -update te_innodb set b=substr(b,1); -ALTER TABLE t_innodb IMPORT TABLESPACE; -update t_innodb set b=substr(b,1); -ALTER TABLE tpe_innodb IMPORT TABLESPACE; -update tpe_innodb set b=substr(b,1); -ALTER TABLE tp_innodb IMPORT TABLESPACE; -update tp_innodb set b=substr(b,1); -SET GLOBAL innodb_checksum_algorithm=innodb; -ALTER TABLE tce_innodb DISCARD TABLESPACE; -ALTER TABLE tc_innodb DISCARD TABLESPACE; -ALTER TABLE te_innodb DISCARD TABLESPACE; -ALTER TABLE t_innodb DISCARD TABLESPACE; -ALTER TABLE tpe_innodb DISCARD TABLESPACE; -ALTER TABLE tp_innodb DISCARD TABLESPACE; -restore: tce_innodb .ibd and .cfg files -restore: tc_innodb .ibd and .cfg files -restore: te_innodb .ibd and .cfg files -restore: t_innodb .ibd and .cfg files -restore: tpe_innodb .ibd and .cfg files -restore: tp_innodb .ibd and .cfg files -ALTER TABLE tce_innodb IMPORT TABLESPACE; -update tce_innodb set b=substr(b,1); -ALTER TABLE tc_innodb IMPORT TABLESPACE; -update tc_innodb set b=substr(b,1); -ALTER TABLE te_innodb IMPORT TABLESPACE; -update te_innodb set b=substr(b,1); -ALTER TABLE t_innodb IMPORT TABLESPACE; -update t_innodb set b=substr(b,1); -ALTER TABLE tpe_innodb IMPORT TABLESPACE; -update tpe_innodb set b=substr(b,1); -ALTER TABLE tp_innodb IMPORT TABLESPACE; -update tp_innodb set b=substr(b,1); -SET GLOBAL innodb_checksum_algorithm=none; -ALTER TABLE tce_innodb DISCARD TABLESPACE; -ALTER TABLE tc_innodb DISCARD TABLESPACE; -ALTER TABLE te_innodb DISCARD TABLESPACE; -ALTER TABLE t_innodb DISCARD TABLESPACE; -ALTER TABLE tpe_innodb DISCARD TABLESPACE; -ALTER TABLE tp_innodb DISCARD TABLESPACE; -restore: tce_innodb .ibd and .cfg files -restore: tc_innodb .ibd and .cfg files -restore: te_innodb .ibd and .cfg files -restore: t_innodb .ibd and .cfg files -restore: tpe_innodb .ibd and .cfg files -restore: tp_innodb .ibd and .cfg files -ALTER TABLE tce_innodb IMPORT TABLESPACE; -update tce_innodb set b=substr(b,1); -ALTER TABLE tc_innodb IMPORT TABLESPACE; -update tc_innodb set b=substr(b,1); -ALTER TABLE te_innodb IMPORT TABLESPACE; -update te_innodb set b=substr(b,1); -ALTER TABLE t_innodb IMPORT TABLESPACE; -update t_innodb set b=substr(b,1); -ALTER TABLE tpe_innodb IMPORT TABLESPACE; -update tpe_innodb set b=substr(b,1); -ALTER TABLE tp_innodb IMPORT TABLESPACE; -update tp_innodb set b=substr(b,1); -CHECK TABLE tce_innodb, tc_innodb, te_innodb, -t_innodb, tpe_innodb, tp_innodb; -Table Op Msg_type Msg_text -test.tce_innodb check status OK -test.tc_innodb check status OK -test.te_innodb check status OK -test.t_innodb check status OK -test.tpe_innodb check status OK -test.tp_innodb check status OK -DROP TABLE tce_innodb, tc_innodb, te_innodb, -t_innodb, tpe_innodb, tp_innodb; -SET GLOBAL innodb_checksum_algorithm=none; -create table tce_none(a serial, b blob, index(b(10))) engine=innodb -ROW_FORMAT=COMPRESSED encrypted=yes; -create table tc_none(a serial, b blob, index(b(10))) engine=innodb -ROW_FORMAT=COMPRESSED encrypted=no; -Warnings: -Warning 140 InnoDB: ENCRYPTED=NO implies ENCRYPTION_KEY_ID=1 -create table te_none(a serial, b blob, index(b(10))) engine=innodb -encrypted=yes; -create table t_none(a serial, b blob, index(b(10))) engine=innodb -encrypted=no; -Warnings: -Warning 140 InnoDB: ENCRYPTED=NO implies ENCRYPTION_KEY_ID=1 -create table tpe_none(a serial, b blob, index(b(10))) engine=innodb -page_compressed=yes encrypted=yes; -create table tp_none(a serial, b blob, index(b(10))) engine=innodb -page_compressed=yes encrypted=no; -Warnings: -Warning 140 InnoDB: ENCRYPTED=NO implies ENCRYPTION_KEY_ID=1 -begin; -insert into tce_none(b) values (repeat('secret',20)); -insert into tc_none(b) values (repeat('secret',20)); -insert into te_none(b) values (repeat('secret',20)); -insert into t_none(b) values (repeat('secret',20)); -insert into tpe_none(b) values (repeat('secret',20)); -insert into tp_none(b) values (repeat('secret',20)); -commit; -FLUSH TABLES tce_none, tc_none, te_none, -t_none, tpe_none, tp_none FOR EXPORT; -backup: tce_none -backup: tc_none -backup: te_none -backup: t_none -backup: tpe_none -backup: tp_none -db.opt -t_none.cfg -t_none.frm -t_none.ibd -tc_none.cfg -tc_none.frm -tc_none.ibd -tce_none.cfg -tce_none.frm -tce_none.ibd -te_none.cfg -te_none.frm -te_none.ibd -tp_none.cfg -tp_none.frm -tp_none.ibd -tpe_none.cfg -tpe_none.frm -tpe_none.ibd -UNLOCK TABLES; -SET GLOBAL innodb_checksum_algorithm=crc32; -ALTER TABLE tce_none DISCARD TABLESPACE; -ALTER TABLE tc_none DISCARD TABLESPACE; -ALTER TABLE te_none DISCARD TABLESPACE; -ALTER TABLE t_none DISCARD TABLESPACE; -ALTER TABLE tpe_none DISCARD TABLESPACE; -ALTER TABLE tp_none DISCARD TABLESPACE; -restore: tce_none .ibd and .cfg files -restore: tc_none .ibd and .cfg files -restore: te_none .ibd and .cfg files -restore: t_none .ibd and .cfg files -restore: tpe_none .ibd and .cfg files -restore: tp_none .ibd and .cfg files -ALTER TABLE tce_none IMPORT TABLESPACE; -update tce_none set b=substr(b,1); -ALTER TABLE tc_none IMPORT TABLESPACE; -update tc_none set b=substr(b,1); -ALTER TABLE te_none IMPORT TABLESPACE; -update te_none set b=substr(b,1); -ALTER TABLE t_none IMPORT TABLESPACE; -update t_none set b=substr(b,1); -ALTER TABLE tpe_none IMPORT TABLESPACE; -update tpe_none set b=substr(b,1); -ALTER TABLE tp_none IMPORT TABLESPACE; -update tp_none set b=substr(b,1); -SET GLOBAL innodb_checksum_algorithm=innodb; -ALTER TABLE tce_none DISCARD TABLESPACE; -ALTER TABLE tc_none DISCARD TABLESPACE; -ALTER TABLE te_none DISCARD TABLESPACE; -ALTER TABLE t_none DISCARD TABLESPACE; -ALTER TABLE tpe_none DISCARD TABLESPACE; -ALTER TABLE tp_none DISCARD TABLESPACE; -restore: tce_none .ibd and .cfg files -restore: tc_none .ibd and .cfg files -restore: te_none .ibd and .cfg files -restore: t_none .ibd and .cfg files -restore: tpe_none .ibd and .cfg files -restore: tp_none .ibd and .cfg files -ALTER TABLE tce_none IMPORT TABLESPACE; -update tce_none set b=substr(b,1); -ALTER TABLE tc_none IMPORT TABLESPACE; -update tc_none set b=substr(b,1); -ALTER TABLE te_none IMPORT TABLESPACE; -update te_none set b=substr(b,1); -ALTER TABLE t_none IMPORT TABLESPACE; -update t_none set b=substr(b,1); -ALTER TABLE tpe_none IMPORT TABLESPACE; -update tpe_none set b=substr(b,1); -ALTER TABLE tp_none IMPORT TABLESPACE; -update tp_none set b=substr(b,1); -SET GLOBAL innodb_checksum_algorithm=none; -ALTER TABLE tce_none DISCARD TABLESPACE; -ALTER TABLE tc_none DISCARD TABLESPACE; -ALTER TABLE te_none DISCARD TABLESPACE; -ALTER TABLE t_none DISCARD TABLESPACE; -ALTER TABLE tpe_none DISCARD TABLESPACE; -ALTER TABLE tp_none DISCARD TABLESPACE; -restore: tce_none .ibd and .cfg files -restore: tc_none .ibd and .cfg files -restore: te_none .ibd and .cfg files -restore: t_none .ibd and .cfg files -restore: tpe_none .ibd and .cfg files -restore: tp_none .ibd and .cfg files -ALTER TABLE tce_none IMPORT TABLESPACE; -update tce_none set b=substr(b,1); -ALTER TABLE tc_none IMPORT TABLESPACE; -update tc_none set b=substr(b,1); -ALTER TABLE te_none IMPORT TABLESPACE; -update te_none set b=substr(b,1); -ALTER TABLE t_none IMPORT TABLESPACE; -update t_none set b=substr(b,1); -ALTER TABLE tpe_none IMPORT TABLESPACE; -update tpe_none set b=substr(b,1); -ALTER TABLE tp_none IMPORT TABLESPACE; -update tp_none set b=substr(b,1); -CHECK TABLE tce_none, tc_none, te_none, -t_none, tpe_none, tp_none; -Table Op Msg_type Msg_text -test.tce_none check status OK -test.tc_none check status OK -test.te_none check status OK -test.t_none check status OK -test.tpe_none check status OK -test.tp_none check status OK -DROP TABLE tce_none, tc_none, te_none, -t_none, tpe_none, tp_none; +test.tce check status OK +test.tc check status OK +test.te check status OK +test.t check status OK +test.tpe check status OK +test.tp check status OK +DROP TABLE tce, tc, te, t, tpe, tp; SET GLOBAL innodb_file_per_table = @saved_file_per_table; -SET GLOBAL innodb_checksum_algorithm = @saved_checksum_algorithm; SET GLOBAL innodb_encrypt_tables = @saved_encrypt_tables; SET GLOBAL innodb_encryption_threads = @saved_encryption_threads; SET GLOBAL innodb_default_encryption_key_id = @saved_encryption_key_id; diff --git a/mysql-test/suite/encryption/t/corrupted_during_recovery.combinations b/mysql-test/suite/encryption/t/corrupted_during_recovery.combinations index 729380593f3..9ac914f22ed 100644 --- a/mysql-test/suite/encryption/t/corrupted_during_recovery.combinations +++ b/mysql-test/suite/encryption/t/corrupted_during_recovery.combinations @@ -1,5 +1,7 @@ [strict_crc32] --innodb-checksum-algorithm=strict_crc32 +--skip-innodb-doublewrite [strict_full_crc32] --innodb-checksum-algorithm=strict_full_crc32 +--skip-innodb-doublewrite diff --git a/mysql-test/suite/encryption/t/corrupted_during_recovery.test b/mysql-test/suite/encryption/t/corrupted_during_recovery.test index 48445ccb08b..70650d0f746 100644 --- a/mysql-test/suite/encryption/t/corrupted_during_recovery.test +++ b/mysql-test/suite/encryption/t/corrupted_during_recovery.test @@ -11,10 +11,7 @@ call mtr.add_suppression("InnoDB: The page \\[page id: space=\\d+, page number=3 call mtr.add_suppression("InnoDB: Table in tablespace \\d+ encrypted. However key management plugin or used key_version \\d+ is not found or used encryption algorithm or method does not match. Can't continue opening the table."); --enable_query_log -let INNODB_CHECKSUM_ALGORITHM = `SELECT @@innodb_checksum_algorithm`; let INNODB_PAGE_SIZE=`select @@innodb_page_size`; ---echo # Work around MDEV-19541 -SET GLOBAL innodb_checksum_algorithm=crc32; CREATE TABLE t1(a BIGINT PRIMARY KEY) ENGINE=InnoDB, ENCRYPTED=YES; INSERT INTO t1 VALUES(1); # Force a redo log checkpoint. diff --git a/mysql-test/suite/encryption/t/innodb-checksum-algorithm.test b/mysql-test/suite/encryption/t/innodb-checksum-algorithm.test index c9a4a9e1b92..157fb25b185 100644 --- a/mysql-test/suite/encryption/t/innodb-checksum-algorithm.test +++ b/mysql-test/suite/encryption/t/innodb-checksum-algorithm.test @@ -1,8 +1,8 @@ +-- source include/innodb_checksum_algorithm.inc -- source include/innodb_page_size.inc -- source include/have_file_key_management_plugin.inc SET @saved_file_per_table = @@global.innodb_file_per_table; -SET @saved_checksum_algorithm = @@global.innodb_checksum_algorithm; SET @saved_encrypt_tables = @@global.innodb_encrypt_tables; SET @saved_encryption_threads = @@global.innodb_encryption_threads; SET @saved_encryption_key_id = @@global.innodb_default_encryption_key_id; @@ -11,9 +11,6 @@ SET GLOBAL innodb_file_per_table = ON; SET GLOBAL innodb_encrypt_tables = ON; SET GLOBAL innodb_encryption_threads = 4; -call mtr.add_suppression("InnoDB: innodb_checksum_algorithm is set to \"strict_(crc32|none|innodb)\" but the page \\[page id: space=[0-9]+, page number=[0-9]+\\] contains a valid checksum \"(innodb|none|crc32)\""); - -SET GLOBAL innodb_checksum_algorithm = innodb; SET GLOBAL innodb_default_encryption_key_id=4; let MYSQLD_DATADIR =`SELECT @@datadir`; @@ -22,96 +19,65 @@ let MYSQLD_DATADIR =`SELECT @@datadir`; let $row_format_compressed= `select case when @@global.innodb_page_size>16384 then 'ROW_FORMAT=DYNAMIC' else 'ROW_FORMAT=COMPRESSED' end`; -let $from = 3; -while ($from) -{ -dec $from; -let checksum = `select case $from - when 0 then 'none' - when 1 then 'innodb' - when 2 then 'crc32' - end`; -eval SET GLOBAL innodb_checksum_algorithm=$checksum; - -eval create table tce_$checksum(a serial, b blob, index(b(10))) engine=innodb +eval create table tce(a serial, b blob, index(b(10))) engine=innodb $row_format_compressed encrypted=yes; -eval create table tc_$checksum(a serial, b blob, index(b(10))) engine=innodb +eval create table tc(a serial, b blob, index(b(10))) engine=innodb $row_format_compressed encrypted=no; -eval create table te_$checksum(a serial, b blob, index(b(10))) engine=innodb +eval create table te(a serial, b blob, index(b(10))) engine=innodb encrypted=yes; -eval create table t_$checksum(a serial, b blob, index(b(10))) engine=innodb +eval create table t(a serial, b blob, index(b(10))) engine=innodb encrypted=no; -eval create table tpe_$checksum(a serial, b blob, index(b(10))) engine=innodb +eval create table tpe(a serial, b blob, index(b(10))) engine=innodb page_compressed=yes encrypted=yes; -eval create table tp_$checksum(a serial, b blob, index(b(10))) engine=innodb +eval create table tp(a serial, b blob, index(b(10))) engine=innodb page_compressed=yes encrypted=no; begin; -eval insert into tce_$checksum(b) values (repeat('secret',20)); -eval insert into tc_$checksum(b) values (repeat('secret',20)); -eval insert into te_$checksum(b) values (repeat('secret',20)); -eval insert into t_$checksum(b) values (repeat('secret',20)); -eval insert into tpe_$checksum(b) values (repeat('secret',20)); -eval insert into tp_$checksum(b) values (repeat('secret',20)); +eval insert into tce(b) values (repeat('secret',20)); +eval insert into tc(b) values (repeat('secret',20)); +eval insert into te(b) values (repeat('secret',20)); +eval insert into t(b) values (repeat('secret',20)); +eval insert into tpe(b) values (repeat('secret',20)); +eval insert into tp(b) values (repeat('secret',20)); commit; -eval FLUSH TABLES tce_$checksum, tc_$checksum, te_$checksum, -t_$checksum, tpe_$checksum, tp_$checksum FOR EXPORT; +eval FLUSH TABLES tce, tc, te, t, tpe, tp FOR EXPORT; perl; do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; -my @tables = ("tce_", "tc_", "te_", "t_", "tpe_", "tp_"); -ib_backup_tablespaces("test", map{ $_ . $ENV{checksum} } @tables); +ib_backup_tablespaces("test", ("tce", "tc", "te", "t", "tpe", "tp")); EOF --list_files $MYSQLD_DATADIR/test UNLOCK TABLES; -let $to = 3; -while ($to) -{ -dec $to; -let $tocksum = `select case $to - when 0 then 'none' - when 1 then 'innodb' - when 2 then 'crc32' - end`; - -eval SET GLOBAL innodb_checksum_algorithm=$tocksum; - -eval ALTER TABLE tce_$checksum DISCARD TABLESPACE; -eval ALTER TABLE tc_$checksum DISCARD TABLESPACE; -eval ALTER TABLE te_$checksum DISCARD TABLESPACE; -eval ALTER TABLE t_$checksum DISCARD TABLESPACE; -eval ALTER TABLE tpe_$checksum DISCARD TABLESPACE; -eval ALTER TABLE tp_$checksum DISCARD TABLESPACE; +ALTER TABLE tce DISCARD TABLESPACE; +ALTER TABLE tc DISCARD TABLESPACE; +ALTER TABLE te DISCARD TABLESPACE; +ALTER TABLE t DISCARD TABLESPACE; +ALTER TABLE tpe DISCARD TABLESPACE; +ALTER TABLE tp DISCARD TABLESPACE; perl; do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; -my @tables = ("tce_", "tc_", "te_", "t_", "tpe_", "tp_"); -ib_restore_tablespaces("test", map{ $_ . $ENV{checksum} } @tables); +ib_restore_tablespaces("test", ("tce", "tc", "te", "t", "tpe", "tp")); EOF -eval ALTER TABLE tce_$checksum IMPORT TABLESPACE; -eval update tce_$checksum set b=substr(b,1); -eval ALTER TABLE tc_$checksum IMPORT TABLESPACE; -eval update tc_$checksum set b=substr(b,1); -eval ALTER TABLE te_$checksum IMPORT TABLESPACE; -eval update te_$checksum set b=substr(b,1); -eval ALTER TABLE t_$checksum IMPORT TABLESPACE; -eval update t_$checksum set b=substr(b,1); -eval ALTER TABLE tpe_$checksum IMPORT TABLESPACE; -eval update tpe_$checksum set b=substr(b,1); -eval ALTER TABLE tp_$checksum IMPORT TABLESPACE; -eval update tp_$checksum set b=substr(b,1); -} - -eval CHECK TABLE tce_$checksum, tc_$checksum, te_$checksum, -t_$checksum, tpe_$checksum, tp_$checksum; -eval DROP TABLE tce_$checksum, tc_$checksum, te_$checksum, -t_$checksum, tpe_$checksum, tp_$checksum; -} +ALTER TABLE tce IMPORT TABLESPACE; +update tce set b=substr(b,1); +ALTER TABLE tc IMPORT TABLESPACE; +update tc set b=substr(b,1); +ALTER TABLE te IMPORT TABLESPACE; +update te set b=substr(b,1); +ALTER TABLE t IMPORT TABLESPACE; +update t set b=substr(b,1); +ALTER TABLE tpe IMPORT TABLESPACE; +update tpe set b=substr(b,1); +ALTER TABLE tp IMPORT TABLESPACE; +update tp set b=substr(b,1); + +CHECK TABLE tce, tc, te, t, tpe, tp; +DROP TABLE tce, tc, te, t, tpe, tp; SET GLOBAL innodb_file_per_table = @saved_file_per_table; -SET GLOBAL innodb_checksum_algorithm = @saved_checksum_algorithm; SET GLOBAL innodb_encrypt_tables = @saved_encrypt_tables; SET GLOBAL innodb_encryption_threads = @saved_encryption_threads; SET GLOBAL innodb_default_encryption_key_id = @saved_encryption_key_id; diff --git a/mysql-test/suite/encryption/t/innodb-compressed-blob.combinations b/mysql-test/suite/encryption/t/innodb-compressed-blob.combinations deleted file mode 100644 index df4560f06e5..00000000000 --- a/mysql-test/suite/encryption/t/innodb-compressed-blob.combinations +++ /dev/null @@ -1,4 +0,0 @@ -[crc32] -loose-innodb-checksum-algorithm=crc32 -[none] -loose-innodb-checksum-algorithm=none diff --git a/mysql-test/suite/innodb/t/page_id_innochecksum.test b/mysql-test/suite/innodb/t/page_id_innochecksum.test index 106da09df6d..2726b3254da 100644 --- a/mysql-test/suite/innodb/t/page_id_innochecksum.test +++ b/mysql-test/suite/innodb/t/page_id_innochecksum.test @@ -54,7 +54,7 @@ close IBD_FILE; EOF --error 1 -exec $INNOCHECKSUM -C crc32 -l $resultlog $MYSQLD_DATADIR/test/t1.ibd; +exec $INNOCHECKSUM -l $resultlog $MYSQLD_DATADIR/test/t1.ibd; let SEARCH_FILE = $MYSQLTEST_VARDIR/tmp/result.log; let SEARCH_PATTERN=page id mismatch; diff --git a/mysql-test/suite/innodb_zip/include/innodb-wl6045.inc b/mysql-test/suite/innodb_zip/include/innodb-wl6045.inc deleted file mode 100644 index 26ce7e72983..00000000000 --- a/mysql-test/suite/innodb_zip/include/innodb-wl6045.inc +++ /dev/null @@ -1,20 +0,0 @@ ---echo ===> Testing size=$size ---disable_warnings ---eval CREATE TABLE t1(id INT AUTO_INCREMENT PRIMARY KEY, msg VARCHAR(255)) ENGINE=INNODB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=$size ---enable_warnings - -insert into t1 values(1,"I"); -insert into t1 values(2,"AM"); -insert into t1 values(3,"COMPRESSED"); - ---source include/shutdown_mysqld.inc - ---exec $INNOCHECKSUM $MYSQLD_DATADIR/test/t1.ibd ---exec $INNOCHECKSUM --write=crc32 $MYSQLD_DATADIR/test/t1.ibd ---exec $INNOCHECKSUM --strict-check=crc32 $MYSQLD_DATADIR/test/t1.ibd ---exec $INNOCHECKSUM --write=none $MYSQLD_DATADIR/test/t1.ibd ---exec $INNOCHECKSUM --strict-check=none $MYSQLD_DATADIR/test/t1.ibd - ---source include/start_mysqld.inc -select * from t1; -drop table t1; diff --git a/mysql-test/suite/innodb_zip/r/innochecksum.result b/mysql-test/suite/innodb_zip/r/innochecksum.result index e1d3a187186..e6525af4b52 100644 --- a/mysql-test/suite/innodb_zip/r/innochecksum.result +++ b/mysql-test/suite/innodb_zip/r/innochecksum.result @@ -1,96 +1,22 @@ -# Set the environmental variables call mtr.add_suppression("InnoDB: Unable to read tablespace .* page no .* into the buffer pool after 100 attempts"); call mtr.add_suppression("InnoDB: Warning: database page corruption or a failed"); CREATE TABLE tab1(c1 INT PRIMARY KEY,c2 VARCHAR(20)) ENGINE=InnoDB; CREATE INDEX idx1 ON tab1(c2(10)); INSERT INTO tab1 VALUES(1, 'Innochecksum InnoDB1'); -CREATE TABLE t1(id INT AUTO_INCREMENT PRIMARY KEY, msg VARCHAR(255)) ENGINE=INNODB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4; -insert into t1 values(1,"i"); -insert into t1 values(2,"am"); -insert into t1 values(3,"compressed table"); # Shutdown the Server # Server Default checksum = innodb [1b]: check the innochecksum without --strict-check -[2]: check the innochecksum with full form --strict-check=crc32 -[3]: check the innochecksum with short form -C crc32 [4]: check the innochecksum with --no-check ignores algorithm check, warning is expected FOUND 1 /Error: --no-check must be associated with --write option./ in my_restart.err [5]: check the innochecksum with short form --no-check ignores algorithm check, warning is expected FOUND 1 /Error: --no-check must be associated with --write option./ in my_restart.err [6]: check the innochecksum with full form strict-check & no-check , an error is expected -FOUND 1 /Error: --strict-check option cannot be used together with --no-check option./ in my_restart.err +FOUND 1 /unknown variable 'strict-check=innodb'/ in my_restart.err [7]: check the innochecksum with short form strict-check & no-check , an error is expected -FOUND 1 /Error: --strict-check option cannot be used together with --no-check option./ in my_restart.err -[8]: check the innochecksum with short & full form combination -# strict-check & no-check, an error is expected -FOUND 1 /Error: --strict-check option cannot be used together with --no-check option./ in my_restart.err -[9]: check the innochecksum with full form --strict-check=innodb -[10]: check the innochecksum with full form --strict-check=none -# when server Default checksum=crc32 -[11]: check the innochecksum with short form -C innodb -# when server Default checksum=crc32 -[12]: check the innochecksum with short form -C none -# when server Default checksum=crc32 -[13]: check strict-check with invalid values -FOUND 1 /Error while setting value \'strict_innodb\' to \'strict-check\'/ in my_restart.err -FOUND 1 /Error while setting value \'strict_innodb\' to \'strict-check\'/ in my_restart.err -FOUND 1 /Error while setting value \'strict_crc32\' to \'strict-check\'/ in my_restart.err -FOUND 1 /Error while setting value \'strict_crc32\' to \'strict-check\'/ in my_restart.err -FOUND 1 /Error while setting value \'strict_none\' to \'strict-check\'/ in my_restart.err -FOUND 1 /Error while setting value \'strict_none\' to \'strict-check\'/ in my_restart.err -FOUND 1 /Error while setting value \'InnoBD\' to \'strict-check\'/ in my_restart.err -FOUND 1 /Error while setting value \'InnoBD\' to \'strict-check\'/ in my_restart.err -FOUND 1 /Error while setting value \'crc\' to \'strict-check\'/ in my_restart.err -FOUND 1 /Error while setting value \'no\' to \'strict-check\'/ in my_restart.err -[14a]: when server default checksum=crc32 rewrite new checksum=crc32 with innochecksum -# Also check the long form of write option. -[14b]: when server default checksum=crc32 rewrite new checksum=innodb with innochecksum -# Also check the long form of write option. -# start the server with innodb_checksum_algorithm=InnoDB -# restart: --innodb_checksum_algorithm=innodb -INSERT INTO tab1 VALUES(2, 'Innochecksum CRC32'); -SELECT c1,c2 FROM tab1 order by c1,c2; -c1 c2 -1 Innochecksum InnoDB1 -2 Innochecksum CRC32 -# Stop the server -[15]: when server default checksum=crc32 rewrite new checksum=none with innochecksum -# Also check the short form of write option. -# Start the server with checksum algorithm=none -# restart: --innodb_checksum_algorithm=none -INSERT INTO tab1 VALUES(3, 'Innochecksum None'); -SELECT c1,c2 FROM tab1 order by c1,c2; -c1 c2 -1 Innochecksum InnoDB1 -2 Innochecksum CRC32 -3 Innochecksum None -DROP TABLE t1; -# Stop the server -[16]: rewrite into new checksum=crc32 with innochecksum -# Restart the DB server with innodb_checksum_algorithm=crc32 -# restart: --innodb_checksum_algorithm=crc32 -SELECT * FROM tab1; -c1 c2 -1 Innochecksum InnoDB1 -2 Innochecksum CRC32 -3 Innochecksum None -DELETE FROM tab1 where c1=3; -SELECT c1,c2 FROM tab1 order by c1,c2; -c1 c2 -1 Innochecksum InnoDB1 -2 Innochecksum CRC32 -# Stop server -[17]: rewrite into new checksum=InnoDB -# Restart the DB server with innodb_checksum_algorithm=InnoDB -# restart: --innodb_checksum_algorithm=innodb -DELETE FROM tab1 where c1=2; +FOUND 1 /unknown option '-C'/ in my_restart.err +FOUND 1 /unknown variable 'write=crc32'/ in my_restart.err +# restart SELECT * FROM tab1; c1 c2 1 Innochecksum InnoDB1 -# Stop server -[18]:check Innochecksum with invalid write options -FOUND 1 /Error while setting value \'strict_crc32\' to \'write\'/ in my_restart.err -FOUND 1 /Error while setting value \'strict_innodb\' to \'write\'/ in my_restart.err -FOUND 1 /Error while setting value \'crc23\' to \'write\'/ in my_restart.err -# restart DROP TABLE tab1; diff --git a/mysql-test/suite/innodb_zip/r/innochecksum_2.result b/mysql-test/suite/innodb_zip/r/innochecksum_2.result index bfd03c72f12..7be6f6f9af3 100644 --- a/mysql-test/suite/innodb_zip/r/innochecksum_2.result +++ b/mysql-test/suite/innodb_zip/r/innochecksum_2.result @@ -25,10 +25,8 @@ count FALSE start-page 0 end-page 0 page 0 -strict-check crc32 no-check FALSE allow-mismatches 0 -write crc32 page-type-summary FALSE page-type-dump MYSQLTEST_VARDIR/tmp/dump.txt per-page-details FALSE @@ -42,7 +40,7 @@ innochecksum Ver #.#.# Copyright (c) YEAR, YEAR , Oracle, MariaDB Corporation Ab and others. InnoDB offline file checksum utility. -Usage: innochecksum [-c] [-s <start page>] [-e <end page>] [-p <page>] [-i] [-v] [-a <allow mismatches>] [-n] [-C <strict-check>] [-w <write>] [-S] [-D <page type dump>] [-l <log>] [-l] [-m <merge pages>] <filename or [-]> +Usage: innochecksum [-c] [-s <start page>] [-e <end page>] [-p <page>] [-i] [-v] [-a <allow mismatches>] [-n] [-S] [-D <page type dump>] [-l <log>] [-l] [-m <merge pages>] <filename or [-]> See https://mariadb.com/kb/en/library/innochecksum/ for usage hints. -?, --help Displays this help and exits. -I, --info Synonym for --help. @@ -53,14 +51,9 @@ See https://mariadb.com/kb/en/library/innochecksum/ for usage hints. -s, --start-page=# Start on this page number (0 based). -e, --end-page=# End at this page number (0 based). -p, --page=# Check only this page (0 based). - -C, --strict-check=name - Specify the strict checksum algorithm by the user.. One - of: crc32, crc32, innodb, innodb, none, none -n, --no-check Ignore the checksum verification. -a, --allow-mismatches=# Maximum checksum mismatch allowed. - -w, --write=name Rewrite the checksum algorithm by the user.. One of: - crc32, crc32, innodb, innodb, none, none -S, --page-type-summary Display a count of each page type in a tablespace. -D, --page-type-dump=name @@ -80,10 +73,8 @@ count FALSE start-page 0 end-page 0 page 0 -strict-check crc32 no-check FALSE allow-mismatches 0 -write crc32 page-type-summary FALSE page-type-dump (No default value) per-page-details FALSE @@ -96,67 +87,3 @@ Number of pages:# [4]:# Print the version of innochecksum and exit innochecksum Ver #.#.## Restart the DB server DROP TABLE t1; -[5]:# Check the innochecksum for compressed table t1 with different key_block_size -# Test for KEY_BLOCK_SIZE=1 -===> Testing size=1 -CREATE TABLE t1(id INT AUTO_INCREMENT PRIMARY KEY, msg VARCHAR(255)) ENGINE=INNODB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1; -insert into t1 values(1,"I"); -insert into t1 values(2,"AM"); -insert into t1 values(3,"COMPRESSED"); -select * from t1; -id msg -1 I -2 AM -3 COMPRESSED -drop table t1; -# Test for KEY_BLOCK_SIZE=2 -===> Testing size=2 -CREATE TABLE t1(id INT AUTO_INCREMENT PRIMARY KEY, msg VARCHAR(255)) ENGINE=INNODB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=2; -insert into t1 values(1,"I"); -insert into t1 values(2,"AM"); -insert into t1 values(3,"COMPRESSED"); -select * from t1; -id msg -1 I -2 AM -3 COMPRESSED -drop table t1; -# Test for for KEY_BLOCK_SIZE=4 -===> Testing size=4 -CREATE TABLE t1(id INT AUTO_INCREMENT PRIMARY KEY, msg VARCHAR(255)) ENGINE=INNODB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4; -insert into t1 values(1,"I"); -insert into t1 values(2,"AM"); -insert into t1 values(3,"COMPRESSED"); -select * from t1; -id msg -1 I -2 AM -3 COMPRESSED -drop table t1; -set innodb_strict_mode=off; -# Test for for KEY_BLOCK_SIZE=8 -===> Testing size=8 -CREATE TABLE t1(id INT AUTO_INCREMENT PRIMARY KEY, msg VARCHAR(255)) ENGINE=INNODB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8; -insert into t1 values(1,"I"); -insert into t1 values(2,"AM"); -insert into t1 values(3,"COMPRESSED"); -select * from t1; -id msg -1 I -2 AM -3 COMPRESSED -drop table t1; -set innodb_strict_mode=off; -# Test for KEY_BLOCK_SIZE=16 -===> Testing size=16 -CREATE TABLE t1(id INT AUTO_INCREMENT PRIMARY KEY, msg VARCHAR(255)) ENGINE=INNODB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=16; -insert into t1 values(1,"I"); -insert into t1 values(2,"AM"); -insert into t1 values(3,"COMPRESSED"); -select * from t1; -id msg -1 I -2 AM -3 COMPRESSED -drop table t1; -# Test[5] completed diff --git a/mysql-test/suite/innodb_zip/r/innochecksum_3.result b/mysql-test/suite/innodb_zip/r/innochecksum_3.result index cfe1e4852ba..b7ba8704347 100644 --- a/mysql-test/suite/innodb_zip/r/innochecksum_3.result +++ b/mysql-test/suite/innodb_zip/r/innochecksum_3.result @@ -1,7 +1,6 @@ # Set the environmental variables call mtr.add_suppression("InnoDB: Unable to read tablespace .* page no .* into the buffer pool after 100 attempts"); call mtr.add_suppression("InnoDB: innodb_checksum_algorithm is set to.*"); -[1]: Further Test are for rewrite checksum (innodb|crc32|none) for all ibd file & start the server. CREATE TABLE tab1 (pk INTEGER NOT NULL PRIMARY KEY, linestring_key GEOMETRY NOT NULL, linestring_nokey GEOMETRY NOT NULL) @@ -35,58 +34,6 @@ INSERT INTO tab2(col_1,col_2,col_3,col_4,col_5,col_6,col_7) VALUES (@col_1,@col_2,@col_3,@col_4,@cl_5,@col_6,2); INSERT INTO tab2(col_1,col_2,col_3,col_4,col_5,col_6,col_7) VALUES (@col_1,@col_2,@col_3,@col_4,@cl_5,@col_6,1); -SELECT * FROM tab2 ORDER BY col_7; -# stop the server -[1(a)]: Rewrite into new checksum=InnoDB for all *.ibd file and ibdata1 -: start the server with innodb_checksum_algorithm=strict_innodb -# restart: --innodb_checksum_algorithm=strict_innodb -INSERT INTO tab1 (pk, linestring_key, linestring_nokey) -VALUES (2, ST_GeomFromText('LINESTRING(10 10,20 20,30 30)'), ST_GeomFromText('LINESTRING(10 10,20 20,30 30)')); -SET @col_1 = repeat('a', 5); -SET @col_2 = repeat('b', 20); -SET @col_3 = repeat('c', 100); -SET @col_4 = repeat('d', 100); -SET @col_5 = repeat('e', 100); -SET @col_6 = repeat('f', 100); -INSERT INTO tab2(col_1,col_2,col_3,col_4,col_5,col_6,col_7) -VALUES (@col_1,@col_2,@col_3,@col_4,@cl_5,@col_6,6); -SELECT pk,ST_AsText(linestring_key),ST_AsText(linestring_nokey) -FROM tab1 ORDER BY pk; -SELECT * FROM tab2 ORDER BY col_7; -# stop the server -[1(b)]: Rewrite into new checksum=crc32 for all *.ibd file and ibdata1 -# start the server with innodb_checksum_algorithm=strict_crc32 -# restart: --innodb_checksum_algorithm=strict_crc32 -INSERT INTO tab1 (pk, linestring_key, linestring_nokey) -VALUES (3, ST_GeomFromText('POLYGON((0 0,5 5,10 10,15 15,0 0),(10 10,20 20,30 30,40 40,10 10))'), -ST_GeomFromText('POLYGON((0 0,5 5,10 10,15 15,0 0),(10 10,20 20,30 30,40 40,10 10))')); -SET @col_1 = repeat('g', 5); -SET @col_2 = repeat('h', 20); -SET @col_3 = repeat('i', 100); -SET @col_4 = repeat('j', 100); -SET @col_5 = repeat('k', 100); -SET @col_6 = repeat('l', 100); -INSERT INTO tab2(col_1,col_2,col_3,col_4,col_5,col_6,col_7) -VALUES (@col_1,@col_2,@col_3,@col_4,@cl_5,@col_6,7); -SELECT pk,ST_AsText(linestring_key),ST_AsText(linestring_nokey) -FROM tab1 ORDER BY pk; -SELECT * FROM tab2 ORDER BY col_7; -# stop the server -[1(c)]: Rewrite into new checksum=none for all *.ibd file and ibdata1 -# restart: --innodb_checksum_algorithm=strict_none -INSERT INTO tab1 (pk, linestring_key, linestring_nokey) -VALUES (4, ST_GeomFromText('MULTIPOINT(0 0,5 5,10 10,20 20) '), ST_GeomFromText('MULTIPOINT(0 0,5 5,10 10,20 20) ')); -SET @col_1 = repeat('m', 5); -SET @col_2 = repeat('n', 20); -SET @col_3 = repeat('o', 100); -SET @col_4 = repeat('p', 100); -SET @col_5 = repeat('q', 100); -SET @col_6 = repeat('r', 100); -INSERT INTO tab2(col_1,col_2,col_3,col_4,col_5,col_6,col_7) -VALUES (@col_1,@col_2,@col_3,@col_4,@cl_5,@col_6,8); -SELECT pk,ST_AsText(linestring_key),ST_AsText(linestring_nokey) -FROM tab1 ORDER BY pk; -SELECT * FROM tab2 ORDER BY col_7; # stop the server [2]: Check the page type summary with shortform for tab1.ibd @@ -184,10 +131,8 @@ count FALSE start-page 0 end-page 0 page 0 -strict-check crc32 no-check FALSE allow-mismatches 0 -write crc32 page-type-summary FALSE page-type-dump MYSQLTEST_VARDIR/tmp/dump.txt per-page-details FALSE diff --git a/mysql-test/suite/innodb_zip/t/innochecksum.combinations b/mysql-test/suite/innodb_zip/t/innochecksum.combinations deleted file mode 100644 index 79e5f7836ed..00000000000 --- a/mysql-test/suite/innodb_zip/t/innochecksum.combinations +++ /dev/null @@ -1,5 +0,0 @@ -[crc32] ---innodb-checksum-algorithm=crc32 - -[full_crc32] ---innodb-checksum-algorithm=full_crc32 diff --git a/mysql-test/suite/innodb_zip/t/innochecksum.opt b/mysql-test/suite/innodb_zip/t/innochecksum.opt deleted file mode 100644 index ac26eca328c..00000000000 --- a/mysql-test/suite/innodb_zip/t/innochecksum.opt +++ /dev/null @@ -1 +0,0 @@ ---skip-innodb-doublewrite diff --git a/mysql-test/suite/innodb_zip/t/innochecksum.test b/mysql-test/suite/innodb_zip/t/innochecksum.test index ea5654056d9..60860adeac8 100644 --- a/mysql-test/suite/innodb_zip/t/innochecksum.test +++ b/mysql-test/suite/innodb_zip/t/innochecksum.test @@ -1,19 +1,12 @@ #************************************************************ # WL6045:Improve Innochecksum #************************************************************ ---source include/innodb_page_size_small.inc +--source include/have_innodb.inc --source include/no_valgrind_without_big.inc -# Embedded server does not support crashing. --source include/not_embedded.inc -# Avoid CrashReporter popup on Mac. ---source include/not_crashrep.inc - ---echo # Set the environmental variables -let MYSQLD_BASEDIR= `SELECT @@basedir`; -let MYSQLD_DATADIR= `SELECT @@datadir`; +let $MYSQLD_DATADIR= `SELECT @@datadir`; let SEARCH_FILE= $MYSQLTEST_VARDIR/log/my_restart.err; -let $checksum_algorithm = `SELECT @@innodb_checksum_algorithm`; call mtr.add_suppression("InnoDB: Unable to read tablespace .* page no .* into the buffer pool after 100 attempts"); call mtr.add_suppression("InnoDB: Warning: database page corruption or a failed"); @@ -21,10 +14,6 @@ call mtr.add_suppression("InnoDB: Warning: database page corruption or a failed" CREATE TABLE tab1(c1 INT PRIMARY KEY,c2 VARCHAR(20)) ENGINE=InnoDB; CREATE INDEX idx1 ON tab1(c2(10)); INSERT INTO tab1 VALUES(1, 'Innochecksum InnoDB1'); -CREATE TABLE t1(id INT AUTO_INCREMENT PRIMARY KEY, msg VARCHAR(255)) ENGINE=INNODB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4; -insert into t1 values(1,"i"); -insert into t1 values(2,"am"); -insert into t1 values(3,"compressed table"); --echo # Shutdown the Server --source include/shutdown_mysqld.inc @@ -42,12 +31,6 @@ insert into t1 values(3,"compressed table"); --echo [1b]: check the innochecksum without --strict-check --exec $INNOCHECKSUM $MYSQLD_DATADIR/test/tab1.ibd ---echo [2]: check the innochecksum with full form --strict-check=crc32 ---exec $INNOCHECKSUM --strict-check=crc32 $MYSQLD_DATADIR/test/tab1.ibd - ---echo [3]: check the innochecksum with short form -C crc32 ---exec $INNOCHECKSUM -C crc32 $MYSQLD_DATADIR/test/tab1.ibd - --echo [4]: check the innochecksum with --no-check ignores algorithm check, warning is expected --error 1 --exec $INNOCHECKSUM --no-check $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE @@ -63,195 +46,21 @@ let SEARCH_PATTERN= Error: --no-check must be associated with --write option.; --echo [6]: check the innochecksum with full form strict-check & no-check , an error is expected --error 1 --exec $INNOCHECKSUM --strict-check=innodb --no-check $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE -let SEARCH_PATTERN= Error: --strict-check option cannot be used together with --no-check option.; +let SEARCH_PATTERN= unknown variable 'strict-check=innodb'; --source include/search_pattern_in_file.inc --echo [7]: check the innochecksum with short form strict-check & no-check , an error is expected --error 1 --exec $INNOCHECKSUM -C innodb -n $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE -let SEARCH_PATTERN= Error: --strict-check option cannot be used together with --no-check option.; ---source include/search_pattern_in_file.inc - ---echo [8]: check the innochecksum with short & full form combination ---echo # strict-check & no-check, an error is expected ---error 1 ---exec $INNOCHECKSUM --strict-check=innodb -n $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE -let SEARCH_PATTERN= Error: --strict-check option cannot be used together with --no-check option.; ---source include/search_pattern_in_file.inc - ---echo [9]: check the innochecksum with full form --strict-check=innodb -# Server Default checksum = crc32 -let $error_code = 0; - -if ($checksum_algorithm == "crc32") -{ - let $error_code = 1; -} - -if ($checksum_algorithm == "strict_crc32") -{ - let $error_code = 1; -} - ---error $error_code ---exec $INNOCHECKSUM --strict-check=innodb $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE - ---echo [10]: check the innochecksum with full form --strict-check=none ---echo # when server Default checksum=crc32 ---error $error_code ---exec $INNOCHECKSUM --strict-check=none $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE - ---echo [11]: check the innochecksum with short form -C innodb ---echo # when server Default checksum=crc32 ---error $error_code ---exec $INNOCHECKSUM -C innodb $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE - ---echo [12]: check the innochecksum with short form -C none ---echo # when server Default checksum=crc32 ---error $error_code ---exec $INNOCHECKSUM -C none $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE - ---echo [13]: check strict-check with invalid values ---error 1 ---exec $INNOCHECKSUM --strict-check=strict_innodb $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE -let SEARCH_PATTERN= Error while setting value \'strict_innodb\' to \'strict-check\'; ---source include/search_pattern_in_file.inc - ---error 1 ---exec $INNOCHECKSUM -C strict_innodb $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE -let SEARCH_PATTERN= Error while setting value \'strict_innodb\' to \'strict-check\'; +let SEARCH_PATTERN= unknown option '-C'; --source include/search_pattern_in_file.inc --error 1 ---exec $INNOCHECKSUM --strict-check=strict_crc32 $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE -let SEARCH_PATTERN= Error while setting value \'strict_crc32\' to \'strict-check\'; +--exec $INNOCHECKSUM --no-check --write=crc32 $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE +let SEARCH_PATTERN= unknown variable 'write=crc32'; --source include/search_pattern_in_file.inc ---error 1 ---exec $INNOCHECKSUM -C strict_crc32 $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE -let SEARCH_PATTERN= Error while setting value \'strict_crc32\' to \'strict-check\'; ---source include/search_pattern_in_file.inc - ---error 1 ---exec $INNOCHECKSUM --strict-check=strict_none $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE -let SEARCH_PATTERN= Error while setting value \'strict_none\' to \'strict-check\'; ---source include/search_pattern_in_file.inc - ---error 1 ---exec $INNOCHECKSUM -C strict_none $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE -let SEARCH_PATTERN= Error while setting value \'strict_none\' to \'strict-check\'; ---source include/search_pattern_in_file.inc - ---error 1 ---exec $INNOCHECKSUM --strict-check=InnoBD $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE -let SEARCH_PATTERN= Error while setting value \'InnoBD\' to \'strict-check\'; ---source include/search_pattern_in_file.inc - ---error 1 ---exec $INNOCHECKSUM -C InnoBD $MYSQLD_DATADIR/test/tab1.ibd 2>$SEARCH_FILE -let SEARCH_PATTERN= Error while setting value \'InnoBD\' to \'strict-check\'; ---source include/search_pattern_in_file.inc - ---error 1 ---exec $INNOCHECKSUM --strict-check=crc $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE -let SEARCH_PATTERN= Error while setting value \'crc\' to \'strict-check\'; ---source include/search_pattern_in_file.inc - ---error 1 ---exec $INNOCHECKSUM --strict-check=no $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE -let SEARCH_PATTERN= Error while setting value \'no\' to \'strict-check\'; ---source include/search_pattern_in_file.inc - ---echo [14a]: when server default checksum=crc32 rewrite new checksum=crc32 with innochecksum ---echo # Also check the long form of write option. ---exec $INNOCHECKSUM --strict-check=crc32 --write=crc32 $MYSQLD_DATADIR/test/tab1.ibd ---exec $INNOCHECKSUM --strict-check=crc32 --write=crc32 $MYSQLD_DATADIR/test/t1.ibd -# Rewrite done, verify with --strict-check=crc32 ---exec $INNOCHECKSUM --strict-check=crc32 $MYSQLD_DATADIR/test/tab1.ibd ---exec $INNOCHECKSUM --strict-check=crc32 $MYSQLD_DATADIR/test/t1.ibd - ---echo [14b]: when server default checksum=crc32 rewrite new checksum=innodb with innochecksum ---echo # Also check the long form of write option. ---exec $INNOCHECKSUM --no-check --write=innodb $MYSQLD_DATADIR/test/tab1.ibd ---exec $INNOCHECKSUM --strict-check=crc32 --write=innodb $MYSQLD_DATADIR/test/t1.ibd -# Rewrite done, verify with --strict-check=innodb ---exec $INNOCHECKSUM --strict-check=innodb $MYSQLD_DATADIR/test/tab1.ibd - ---echo # start the server with innodb_checksum_algorithm=InnoDB ---let $restart_parameters= --innodb_checksum_algorithm=innodb ---source include/start_mysqld.inc - -INSERT INTO tab1 VALUES(2, 'Innochecksum CRC32'); -SELECT c1,c2 FROM tab1 order by c1,c2; - ---echo # Stop the server ---source include/shutdown_mysqld.inc - ---echo [15]: when server default checksum=crc32 rewrite new checksum=none with innochecksum ---echo # Also check the short form of write option. ---exec $INNOCHECKSUM --no-check -w none $MYSQLD_DATADIR/test/tab1.ibd ---exec $INNOCHECKSUM --no-check -w none $MYSQLD_DATADIR/test/t1.ibd -# Rewrite done, verify with --strict-check=none ---exec $INNOCHECKSUM --strict-check=none $MYSQLD_DATADIR/test/tab1.ibd ---exec $INNOCHECKSUM --strict-check=none $MYSQLD_DATADIR/test/t1.ibd - ---echo # Start the server with checksum algorithm=none ---let $restart_parameters= --innodb_checksum_algorithm=none ---source include/start_mysqld.inc - -INSERT INTO tab1 VALUES(3, 'Innochecksum None'); -SELECT c1,c2 FROM tab1 order by c1,c2; -DROP TABLE t1; - ---echo # Stop the server ---source include/shutdown_mysqld.inc - ---echo [16]: rewrite into new checksum=crc32 with innochecksum ---exec $INNOCHECKSUM --no-check --write=crc32 $MYSQLD_DATADIR/test/tab1.ibd - ---echo # Restart the DB server with innodb_checksum_algorithm=crc32 ---let $restart_parameters= --innodb_checksum_algorithm=crc32 --source include/start_mysqld.inc SELECT * FROM tab1; -DELETE FROM tab1 where c1=3; -SELECT c1,c2 FROM tab1 order by c1,c2; - ---echo # Stop server ---source include/shutdown_mysqld.inc - ---echo [17]: rewrite into new checksum=InnoDB ---exec $INNOCHECKSUM --no-check --write=InnoDB $MYSQLD_DATADIR/test/tab1.ibd - ---echo # Restart the DB server with innodb_checksum_algorithm=InnoDB ---let $restart_parameters= --innodb_checksum_algorithm=innodb ---source include/start_mysqld.inc - -DELETE FROM tab1 where c1=2; -SELECT * FROM tab1; - ---echo # Stop server ---source include/shutdown_mysqld.inc - ---echo [18]:check Innochecksum with invalid write options ---error 1 ---exec $INNOCHECKSUM --no-check --write=strict_crc32 $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE -let SEARCH_PATTERN=Error while setting value \'strict_crc32\' to \'write\'; ---source include/search_pattern_in_file.inc - ---error 1 ---exec $INNOCHECKSUM --no-check --write=strict_innodb $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE -let SEARCH_PATTERN=Error while setting value \'strict_innodb\' to \'write\'; ---source include/search_pattern_in_file.inc - ---error 1 ---exec $INNOCHECKSUM --no-check --write=crc23 $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE -let SEARCH_PATTERN=Error while setting value \'crc23\' to \'write\'; ---source include/search_pattern_in_file.inc ---remove_file $SEARCH_FILE - -# Cleanup ---let $restart_parameters= ---source include/start_mysqld.inc - DROP TABLE tab1; diff --git a/mysql-test/suite/innodb_zip/t/innochecksum_2.test b/mysql-test/suite/innodb_zip/t/innochecksum_2.test index 1efe653cd1a..62e792c1ce4 100644 --- a/mysql-test/suite/innodb_zip/t/innochecksum_2.test +++ b/mysql-test/suite/innodb_zip/t/innochecksum_2.test @@ -3,7 +3,6 @@ #************************************************************ --source include/innodb_page_size_small.inc --source include/have_debug.inc ---source include/no_valgrind_without_big.inc # Avoid CrashReporter popup on Mac. --source include/not_crashrep.inc @@ -93,27 +92,3 @@ EOF --source include/start_mysqld.inc DROP TABLE t1; - ---echo [5]:# Check the innochecksum for compressed table t1 with different key_block_size ---echo # Test for KEY_BLOCK_SIZE=1 ---let $size=1 ---source ../include/innodb-wl6045.inc - ---echo # Test for KEY_BLOCK_SIZE=2 ---let $size=2 ---source ../include/innodb-wl6045.inc - ---echo # Test for for KEY_BLOCK_SIZE=4 ---let $size=4 ---source ../include/innodb-wl6045.inc - -set innodb_strict_mode=off; ---echo # Test for for KEY_BLOCK_SIZE=8 ---let $size=8 ---source ../include/innodb-wl6045.inc - -set innodb_strict_mode=off; ---echo # Test for KEY_BLOCK_SIZE=16 ---let $size=16 ---source ../include/innodb-wl6045.inc ---echo # Test[5] completed diff --git a/mysql-test/suite/innodb_zip/t/innochecksum_3.test b/mysql-test/suite/innodb_zip/t/innochecksum_3.test index dab10dcc997..88898aea521 100644 --- a/mysql-test/suite/innodb_zip/t/innochecksum_3.test +++ b/mysql-test/suite/innodb_zip/t/innochecksum_3.test @@ -19,8 +19,6 @@ let SEARCH_FILE= $MYSQLTEST_VARDIR/log/my_restart.err; call mtr.add_suppression("InnoDB: Unable to read tablespace .* page no .* into the buffer pool after 100 attempts"); call mtr.add_suppression("InnoDB: innodb_checksum_algorithm is set to.*"); ---echo [1]: Further Test are for rewrite checksum (innodb|crc32|none) for all ibd file & start the server. - CREATE TABLE tab1 (pk INTEGER NOT NULL PRIMARY KEY, linestring_key GEOMETRY NOT NULL, linestring_nokey GEOMETRY NOT NULL) @@ -59,137 +57,6 @@ while ($i) { dec $i; } ---disable_result_log -SELECT * FROM tab2 ORDER BY col_7; - ---echo # stop the server ---source include/shutdown_mysqld.inc - ---echo [1(a)]: Rewrite into new checksum=InnoDB for all *.ibd file and ibdata1 ---exec $INNOCHECKSUM --write=InnoDB $MYSQLD_DATADIR/test/tab1.ibd ---exec $INNOCHECKSUM --write=InnoDB $MYSQLD_DATADIR/test/tab2.ibd ---exec $INNOCHECKSUM --write=InnoDB $MYSQLD_DATADIR/ibdata1 -perl; -foreach (glob("$ENV{MYSQLD_DATADIR}/*/*.ibd")) { - system("$ENV{INNOCHECKSUM} --no-check --write=InnoDB $_") -} -EOF - ---echo : start the server with innodb_checksum_algorithm=strict_innodb ---let $restart_parameters= --innodb_checksum_algorithm=strict_innodb ---source include/start_mysqld.inc - -INSERT INTO tab1 (pk, linestring_key, linestring_nokey) -VALUES (2, ST_GeomFromText('LINESTRING(10 10,20 20,30 30)'), ST_GeomFromText('LINESTRING(10 10,20 20,30 30)')); - -# load the with repeat function -SET @col_1 = repeat('a', 5); -SET @col_2 = repeat('b', 20); -SET @col_3 = repeat('c', 100); -SET @col_4 = repeat('d', 100); -SET @col_5 = repeat('e', 100); -SET @col_6 = repeat('f', 100); - -# check the table status is GOOD with DML -let $i = 6; -eval INSERT INTO tab2(col_1,col_2,col_3,col_4,col_5,col_6,col_7) -VALUES (@col_1,@col_2,@col_3,@col_4,@cl_5,@col_6,$i); - --- disable_result_log -SELECT pk,ST_AsText(linestring_key),ST_AsText(linestring_nokey) -FROM tab1 ORDER BY pk; - --- disable_result_log -SELECT * FROM tab2 ORDER BY col_7; - ---echo # stop the server ---source include/shutdown_mysqld.inc - ---echo [1(b)]: Rewrite into new checksum=crc32 for all *.ibd file and ibdata1 ---exec $INNOCHECKSUM --write=CRC32 $MYSQLD_DATADIR/test/tab1.ibd ---exec $INNOCHECKSUM --write=CRC32 $MYSQLD_DATADIR/test/tab2.ibd ---exec $INNOCHECKSUM --write=CRC32 $MYSQLD_DATADIR/ibdata1 -perl; -foreach (glob("$ENV{MYSQLD_DATADIR}/*/*.ibd")) { - system("$ENV{INNOCHECKSUM} --no-check --write=crc32 $_") -} -EOF - ---echo # start the server with innodb_checksum_algorithm=strict_crc32 ---let $restart_parameters= --innodb_checksum_algorithm=strict_crc32 ---source include/start_mysqld.inc - -# check the table status is GOOD with DML -INSERT INTO tab1 (pk, linestring_key, linestring_nokey) -VALUES (3, ST_GeomFromText('POLYGON((0 0,5 5,10 10,15 15,0 0),(10 10,20 20,30 30,40 40,10 10))'), -ST_GeomFromText('POLYGON((0 0,5 5,10 10,15 15,0 0),(10 10,20 20,30 30,40 40,10 10))')); - -# load the with repeat function -SET @col_1 = repeat('g', 5); -SET @col_2 = repeat('h', 20); -SET @col_3 = repeat('i', 100); -SET @col_4 = repeat('j', 100); -SET @col_5 = repeat('k', 100); -SET @col_6 = repeat('l', 100); - -# check the table status is GOOD with DML -let $i = 7; -eval INSERT INTO tab2(col_1,col_2,col_3,col_4,col_5,col_6,col_7) -VALUES (@col_1,@col_2,@col_3,@col_4,@cl_5,@col_6,$i); - -# check the records from table --- disable_result_log -SELECT pk,ST_AsText(linestring_key),ST_AsText(linestring_nokey) -FROM tab1 ORDER BY pk; - --- disable_result_log -SELECT * FROM tab2 ORDER BY col_7; - ---echo # stop the server ---source include/shutdown_mysqld.inc - ---echo [1(c)]: Rewrite into new checksum=none for all *.ibd file and ibdata1 ---exec $INNOCHECKSUM --write=none $MYSQLD_DATADIR/test/tab1.ibd ---exec $INNOCHECKSUM --write=none $MYSQLD_DATADIR/test/tab2.ibd ---exec $INNOCHECKSUM --write=none $MYSQLD_DATADIR/ibdata1 -perl; -foreach (glob("$ENV{MYSQLD_DATADIR}/undo*")) { - system("$ENV{INNOCHECKSUM} --no-check --write=NONE $_") -} -foreach (glob("$ENV{MYSQLD_DATADIR}/*/*.ibd")) { - system("$ENV{INNOCHECKSUM} --no-check --write=NONE $_") -} -EOF - ---let $restart_parameters= --innodb_checksum_algorithm=strict_none ---source include/start_mysqld.inc ---let $restart_parameters= -# check the table status is GOOD with DML -INSERT INTO tab1 (pk, linestring_key, linestring_nokey) -VALUES (4, ST_GeomFromText('MULTIPOINT(0 0,5 5,10 10,20 20) '), ST_GeomFromText('MULTIPOINT(0 0,5 5,10 10,20 20) ')); - -# load the with repeat function -SET @col_1 = repeat('m', 5); -SET @col_2 = repeat('n', 20); -SET @col_3 = repeat('o', 100); -SET @col_4 = repeat('p', 100); -SET @col_5 = repeat('q', 100); -SET @col_6 = repeat('r', 100); - -# check the table status is GOOD with DML -let $i = 8; -eval INSERT INTO tab2(col_1,col_2,col_3,col_4,col_5,col_6,col_7) -VALUES (@col_1,@col_2,@col_3,@col_4,@cl_5,@col_6,$i); - -# check the records from table --- disable_result_log -SELECT pk,ST_AsText(linestring_key),ST_AsText(linestring_nokey) -FROM tab1 ORDER BY pk; - ---disable_result_log -SELECT * FROM tab2 ORDER BY col_7; ---enable_result_log - --echo # stop the server --source include/shutdown_mysqld.inc diff --git a/mysql-test/suite/sys_vars/r/innodb_checksum_algorithm_basic.result b/mysql-test/suite/sys_vars/r/innodb_checksum_algorithm_basic.result index 91d3c65597a..b17d8ea4fbb 100644 --- a/mysql-test/suite/sys_vars/r/innodb_checksum_algorithm_basic.result +++ b/mysql-test/suite/sys_vars/r/innodb_checksum_algorithm_basic.result @@ -10,22 +10,6 @@ SET GLOBAL innodb_checksum_algorithm = 'strict_crc32'; SELECT @@global.innodb_checksum_algorithm; @@global.innodb_checksum_algorithm strict_crc32 -SET GLOBAL innodb_checksum_algorithm = 'innodb'; -SELECT @@global.innodb_checksum_algorithm; -@@global.innodb_checksum_algorithm -innodb -SET GLOBAL innodb_checksum_algorithm = 'strict_innodb'; -SELECT @@global.innodb_checksum_algorithm; -@@global.innodb_checksum_algorithm -strict_innodb -SET GLOBAL innodb_checksum_algorithm = 'none'; -SELECT @@global.innodb_checksum_algorithm; -@@global.innodb_checksum_algorithm -none -SET GLOBAL innodb_checksum_algorithm = 'strict_none'; -SELECT @@global.innodb_checksum_algorithm; -@@global.innodb_checksum_algorithm -strict_none SET GLOBAL innodb_checksum_algorithm = 'full_crc32'; SELECT @@global.innodb_checksum_algorithm; @@global.innodb_checksum_algorithm diff --git a/mysql-test/suite/sys_vars/r/sysvars_innodb.result b/mysql-test/suite/sys_vars/r/sysvars_innodb.result index e47c35f4d1f..41e6b06fa7d 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_innodb.result +++ b/mysql-test/suite/sys_vars/r/sysvars_innodb.result @@ -294,7 +294,7 @@ VARIABLE_COMMENT The algorithm InnoDB uses for page checksumming. Possible value NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST crc32,strict_crc32,innodb,strict_innodb,none,strict_none,full_crc32,strict_full_crc32 +ENUM_VALUE_LIST crc32,strict_crc32,full_crc32,strict_full_crc32 READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME INNODB_CMP_PER_INDEX_ENABLED diff --git a/mysql-test/suite/sys_vars/t/innodb_checksum_algorithm_basic.test b/mysql-test/suite/sys_vars/t/innodb_checksum_algorithm_basic.test index 947007a5dd1..b0a0fcc92f5 100644 --- a/mysql-test/suite/sys_vars/t/innodb_checksum_algorithm_basic.test +++ b/mysql-test/suite/sys_vars/t/innodb_checksum_algorithm_basic.test @@ -10,18 +10,6 @@ SELECT @@global.innodb_checksum_algorithm; SET GLOBAL innodb_checksum_algorithm = 'strict_crc32'; SELECT @@global.innodb_checksum_algorithm; -SET GLOBAL innodb_checksum_algorithm = 'innodb'; -SELECT @@global.innodb_checksum_algorithm; - -SET GLOBAL innodb_checksum_algorithm = 'strict_innodb'; -SELECT @@global.innodb_checksum_algorithm; - -SET GLOBAL innodb_checksum_algorithm = 'none'; -SELECT @@global.innodb_checksum_algorithm; - -SET GLOBAL innodb_checksum_algorithm = 'strict_none'; -SELECT @@global.innodb_checksum_algorithm; - SET GLOBAL innodb_checksum_algorithm = 'full_crc32'; SELECT @@global.innodb_checksum_algorithm; diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index b1307801b3e..e9993b1c023 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -500,6 +500,7 @@ decrypt_failed: @param[in] checksum_field1 new checksum field @param[in] checksum_field2 old checksum field @return true if the page is in crc32 checksum format. */ +static bool buf_page_is_checksum_valid_crc32( const byte* read_buf, @@ -509,8 +510,9 @@ buf_page_is_checksum_valid_crc32( const uint32_t crc32 = buf_calc_page_crc32(read_buf); #ifdef UNIV_INNOCHECKSUM - if (log_file - && srv_checksum_algorithm == SRV_CHECKSUM_ALGORITHM_STRICT_CRC32) { + extern FILE* log_file; + extern unsigned long long cur_page_num; + if (log_file) { fprintf(log_file, "page::%llu;" " crc32 calculated = %u;" " recorded checksum field1 = " ULINTPF " recorded" @@ -526,132 +528,6 @@ buf_page_is_checksum_valid_crc32( return checksum_field1 == crc32; } -/** Checks if the page is in innodb checksum format. -@param[in] read_buf database page -@param[in] checksum_field1 new checksum field -@param[in] checksum_field2 old checksum field -@return true if the page is in innodb checksum format. */ -bool -buf_page_is_checksum_valid_innodb( - const byte* read_buf, - ulint checksum_field1, - ulint checksum_field2) -{ - /* There are 2 valid formulas for - checksum_field2 (old checksum field) which algo=innodb could have - written to the page: - - 1. Very old versions of InnoDB only stored 8 byte lsn to the - start and the end of the page. - - 2. Newer InnoDB versions store the old formula checksum - (buf_calc_page_old_checksum()). */ - - ulint old_checksum = buf_calc_page_old_checksum(read_buf); - ulint new_checksum = buf_calc_page_new_checksum(read_buf); - -#ifdef UNIV_INNOCHECKSUM - if (log_file - && srv_checksum_algorithm == SRV_CHECKSUM_ALGORITHM_INNODB) { - fprintf(log_file, "page::%llu;" - " old style: calculated =" - " " ULINTPF "; recorded = " ULINTPF "\n", - cur_page_num, old_checksum, - checksum_field2); - fprintf(log_file, "page::%llu;" - " new style: calculated =" - " " ULINTPF "; crc32 = %u; recorded = " ULINTPF "\n", - cur_page_num, new_checksum, - buf_calc_page_crc32(read_buf), checksum_field1); - } - - if (log_file - && srv_checksum_algorithm == SRV_CHECKSUM_ALGORITHM_STRICT_INNODB) { - fprintf(log_file, "page::%llu;" - " old style: calculated =" - " " ULINTPF "; recorded checksum = " ULINTPF "\n", - cur_page_num, old_checksum, - checksum_field2); - fprintf(log_file, "page::%llu;" - " new style: calculated =" - " " ULINTPF "; recorded checksum = " ULINTPF "\n", - cur_page_num, new_checksum, - checksum_field1); - } -#endif /* UNIV_INNOCHECKSUM */ - - - if (checksum_field2 != mach_read_from_4(read_buf + FIL_PAGE_LSN) - && checksum_field2 != old_checksum) { - DBUG_LOG("checksum", - "Page checksum crc32 not valid" - << " field1 " << checksum_field1 - << " field2 " << checksum_field2 - << " crc32 " << buf_calc_page_old_checksum(read_buf) - << " lsn " << mach_read_from_4( - read_buf + FIL_PAGE_LSN)); - return(false); - } - - /* old field is fine, check the new field */ - - /* InnoDB versions < 4.0.14 and < 4.1.1 stored the space id - (always equal to 0), to FIL_PAGE_SPACE_OR_CHKSUM */ - - if (checksum_field1 != 0 && checksum_field1 != new_checksum) { - DBUG_LOG("checksum", - "Page checksum crc32 not valid" - << " field1 " << checksum_field1 - << " field2 " << checksum_field2 - << " crc32 " << buf_calc_page_new_checksum(read_buf) - << " lsn " << mach_read_from_4( - read_buf + FIL_PAGE_LSN)); - return(false); - } - - return(true); -} - -/** Checks if the page is in none checksum format. -@param[in] read_buf database page -@param[in] checksum_field1 new checksum field -@param[in] checksum_field2 old checksum field -@return true if the page is in none checksum format. */ -bool -buf_page_is_checksum_valid_none( - const byte* read_buf, - ulint checksum_field1, - ulint checksum_field2) -{ -#ifndef DBUG_OFF - if (checksum_field1 != checksum_field2 - && checksum_field1 != BUF_NO_CHECKSUM_MAGIC) { - DBUG_LOG("checksum", - "Page checksum crc32 not valid" - << " field1 " << checksum_field1 - << " field2 " << checksum_field2 - << " crc32 " << BUF_NO_CHECKSUM_MAGIC - << " lsn " << mach_read_from_4(read_buf - + FIL_PAGE_LSN)); - } -#endif /* DBUG_OFF */ - -#ifdef UNIV_INNOCHECKSUM - if (log_file - && srv_checksum_algorithm == SRV_CHECKSUM_ALGORITHM_STRICT_NONE) { - fprintf(log_file, - "page::%llu; none checksum: calculated" - " = %lu; recorded checksum_field1 = " ULINTPF - " recorded checksum_field2 = " ULINTPF "\n", - cur_page_num, BUF_NO_CHECKSUM_MAGIC, - checksum_field1, checksum_field2); - } -#endif /* UNIV_INNOCHECKSUM */ - - return(checksum_field1 == checksum_field2 - && checksum_field1 == BUF_NO_CHECKSUM_MAGIC); -} - /** Checks whether the lsn present in the page is lesser than the peek current lsn. @param[in] check_lsn lsn to check @@ -759,11 +635,10 @@ buf_page_is_corrupted( return false; } - size_t checksum_field1 = 0; - size_t checksum_field2 = 0; +#ifndef UNIV_INNOCHECKSUM uint32_t crc32 = 0; bool crc32_inited = false; - bool crc32_chksum = false; +#endif /* !UNIV_INNOCHECKSUM */ const ulint zip_size = fil_space_t::zip_size(fsp_flags); const uint16_t page_type = fil_page_get_type(read_buf); @@ -802,21 +677,14 @@ buf_page_is_corrupted( /* Check whether the checksum fields have correct values */ - const srv_checksum_algorithm_t curr_algo = - static_cast<srv_checksum_algorithm_t>(srv_checksum_algorithm); - - if (curr_algo == SRV_CHECKSUM_ALGORITHM_NONE) { - return(false); - } - if (zip_size) { return !page_zip_verify_checksum(read_buf, zip_size); } - checksum_field1 = mach_read_from_4( + const uint32_t checksum_field1 = mach_read_from_4( read_buf + FIL_PAGE_SPACE_OR_CHKSUM); - checksum_field2 = mach_read_from_4( + const uint32_t checksum_field2 = mach_read_from_4( read_buf + srv_page_size - FIL_PAGE_END_LSN_OLD_CHKSUM); static_assert(FIL_PAGE_LSN % 8 == 0, "alignment"); @@ -851,45 +719,20 @@ buf_page_is_corrupted( } } - switch (curr_algo) { +#ifndef UNIV_INNOCHECKSUM + switch (srv_checksum_algorithm) { case SRV_CHECKSUM_ALGORITHM_STRICT_FULL_CRC32: case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32: +#endif /* !UNIV_INNOCHECKSUM */ return !buf_page_is_checksum_valid_crc32( read_buf, checksum_field1, checksum_field2); - case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB: - return !buf_page_is_checksum_valid_innodb( - read_buf, checksum_field1, checksum_field2); - case SRV_CHECKSUM_ALGORITHM_STRICT_NONE: - return !buf_page_is_checksum_valid_none( - read_buf, checksum_field1, checksum_field2); - case SRV_CHECKSUM_ALGORITHM_FULL_CRC32: - case SRV_CHECKSUM_ALGORITHM_CRC32: - case SRV_CHECKSUM_ALGORITHM_INNODB: - if (buf_page_is_checksum_valid_none(read_buf, - checksum_field1, checksum_field2)) { -#ifdef UNIV_INNOCHECKSUM - if (log_file) { - fprintf(log_file, "page::%llu;" - " old style: calculated = %u;" - " recorded = " ULINTPF ";\n", - cur_page_num, - buf_calc_page_old_checksum(read_buf), - checksum_field2); - fprintf(log_file, "page::%llu;" - " new style: calculated = %u;" - " crc32 = %u; recorded = " ULINTPF ";\n", - cur_page_num, - buf_calc_page_new_checksum(read_buf), - buf_calc_page_crc32(read_buf), - checksum_field1); - } -#endif /* UNIV_INNOCHECKSUM */ +#ifndef UNIV_INNOCHECKSUM + default: + if (checksum_field1 == BUF_NO_CHECKSUM_MAGIC + && checksum_field2 == BUF_NO_CHECKSUM_MAGIC) { return false; } - crc32_chksum = curr_algo == SRV_CHECKSUM_ALGORITHM_CRC32 - || curr_algo == SRV_CHECKSUM_ALGORITHM_FULL_CRC32; - /* Very old versions of InnoDB only stored 8 byte lsn to the start and the end of the page. */ @@ -900,43 +743,29 @@ buf_page_is_corrupted( != mach_read_from_4(read_buf + FIL_PAGE_LSN) && checksum_field2 != BUF_NO_CHECKSUM_MAGIC) { - if (crc32_chksum) { - crc32 = buf_calc_page_crc32(read_buf); - crc32_inited = true; + crc32 = buf_calc_page_crc32(read_buf); + crc32_inited = true; - DBUG_EXECUTE_IF( - "page_intermittent_checksum_mismatch", { + DBUG_EXECUTE_IF( + "page_intermittent_checksum_mismatch", { static int page_counter; if (page_counter++ == 2) { crc32++; } }); - if (checksum_field2 != crc32 - && checksum_field2 - != buf_calc_page_old_checksum(read_buf)) { - return true; - } - } else { - ut_ad(curr_algo - == SRV_CHECKSUM_ALGORITHM_INNODB); - - if (checksum_field2 - != buf_calc_page_old_checksum(read_buf)) { - crc32 = buf_calc_page_crc32(read_buf); - crc32_inited = true; - - if (checksum_field2 != crc32) { - return true; - } - } + if (checksum_field2 != crc32 + && checksum_field2 + != buf_calc_page_old_checksum(read_buf)) { + return true; } } - if (checksum_field1 == 0 - || checksum_field1 == BUF_NO_CHECKSUM_MAGIC) { - } else if (crc32_chksum) { - + switch (checksum_field1) { + case 0: + case BUF_NO_CHECKSUM_MAGIC: + break; + default: if (!crc32_inited) { crc32 = buf_calc_page_crc32(read_buf); crc32_inited = true; @@ -947,38 +776,15 @@ buf_page_is_corrupted( != buf_calc_page_new_checksum(read_buf)) { return true; } - } else { - ut_ad(curr_algo == SRV_CHECKSUM_ALGORITHM_INNODB); - - if (checksum_field1 - != buf_calc_page_new_checksum(read_buf)) { - - if (!crc32_inited) { - crc32 = buf_calc_page_crc32(read_buf); - crc32_inited = true; - } - - if (checksum_field1 != crc32) { - return true; - } - } } - if (crc32_inited - && ((checksum_field1 == crc32 - && checksum_field2 != crc32) - || (checksum_field1 != crc32 - && checksum_field2 == crc32))) { - return true; - } - - break; - case SRV_CHECKSUM_ALGORITHM_NONE: - /* should have returned false earlier */ - break; + return crc32_inited + && ((checksum_field1 == crc32 + && checksum_field2 != crc32) + || (checksum_field1 != crc32 + && checksum_field2 == crc32)); } - - return false; +#endif /* !UNIV_INNOCHECKSUM */ } #ifndef UNIV_INNOCHECKSUM @@ -1048,26 +854,10 @@ void buf_page_print(const byte* read_buf, ulint zip_size) << mach_read_from_4( read_buf + FIL_PAGE_SPACE_OR_CHKSUM) << "; calculated checksums for field1: " - << buf_checksum_algorithm_name( - SRV_CHECKSUM_ALGORITHM_CRC32) - << " " - << page_zip_calc_checksum( - read_buf, zip_size, - SRV_CHECKSUM_ALGORITHM_CRC32) - << ", " - << buf_checksum_algorithm_name( - SRV_CHECKSUM_ALGORITHM_INNODB) - << " " - << page_zip_calc_checksum( - read_buf, zip_size, - SRV_CHECKSUM_ALGORITHM_INNODB) - << ", " - << buf_checksum_algorithm_name( - SRV_CHECKSUM_ALGORITHM_NONE) - << " " - << page_zip_calc_checksum( - read_buf, zip_size, - SRV_CHECKSUM_ALGORITHM_NONE) + << "crc32 " + << page_zip_calc_checksum(read_buf, zip_size, false) + << ", adler32 " + << page_zip_calc_checksum(read_buf, zip_size, true) << "; page LSN " << mach_read_from_8(read_buf + FIL_PAGE_LSN) << "; page number (if stored to page" @@ -1084,35 +874,16 @@ void buf_page_print(const byte* read_buf, ulint zip_size) ib::info() << "Uncompressed page, stored checksum in field1 " << mach_read_from_4( read_buf + FIL_PAGE_SPACE_OR_CHKSUM) - << ", calculated checksums for field1: " - << buf_checksum_algorithm_name( - SRV_CHECKSUM_ALGORITHM_CRC32) << " " + << ", calculated checksums for field1: crc32 " << crc32 - << ", " - << buf_checksum_algorithm_name( - SRV_CHECKSUM_ALGORITHM_INNODB) << " " + << ", innodb " << buf_calc_page_new_checksum(read_buf) - << ", " - << " page type " << page_type << " == " - << fil_get_page_type_name(page_type) << "." - << buf_checksum_algorithm_name( - SRV_CHECKSUM_ALGORITHM_NONE) << " " - << BUF_NO_CHECKSUM_MAGIC + << ", page type " << page_type << ", stored checksum in field2 " << mach_read_from_4(read_buf + srv_page_size - FIL_PAGE_END_LSN_OLD_CHKSUM) - << ", calculated checksums for field2: " - << buf_checksum_algorithm_name( - SRV_CHECKSUM_ALGORITHM_CRC32) << " " - << crc32 - << ", " - << buf_checksum_algorithm_name( - SRV_CHECKSUM_ALGORITHM_INNODB) << " " + << ", innodb checksum for field2: " << buf_calc_page_old_checksum(read_buf) - << ", " - << buf_checksum_algorithm_name( - SRV_CHECKSUM_ALGORITHM_NONE) << " " - << BUF_NO_CHECKSUM_MAGIC << ", page LSN " << mach_read_from_4(read_buf + FIL_PAGE_LSN) << " " @@ -2660,15 +2431,9 @@ buf_zip_decompress( << block->page.id() << ": stored: " << mach_read_from_4(frame + FIL_PAGE_SPACE_OR_CHKSUM) << ", crc32: " - << page_zip_calc_checksum( - frame, size, SRV_CHECKSUM_ALGORITHM_CRC32) - << " innodb: " - << page_zip_calc_checksum( - frame, size, SRV_CHECKSUM_ALGORITHM_INNODB) - << ", none: " - << page_zip_calc_checksum( - frame, size, SRV_CHECKSUM_ALGORITHM_NONE) - << " (algorithm: " << srv_checksum_algorithm << ")"; + << page_zip_calc_checksum(frame, size, false) + << " adler32: " + << page_zip_calc_checksum(frame, size, true); goto err_exit; } diff --git a/storage/innobase/buf/buf0checksum.cc b/storage/innobase/buf/buf0checksum.cc index e98dc18452e..c9818fa600f 100644 --- a/storage/innobase/buf/buf0checksum.cc +++ b/storage/innobase/buf/buf0checksum.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2019, MariaDB Corporation. +Copyright (c) 2017, 2021, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -33,9 +33,6 @@ Created Aug 11, 2011 Vasil Dimov #include "srv0srv.h" #endif /* !UNIV_INNOCHECKSUM */ -/** the value of innodb_checksum_algorithm */ -ulong srv_checksum_algorithm; - /** Calculate the CRC32 checksum of a page. The value is stored to the page when it is written to a file and also checked for a match when reading from the file. Note that we must be careful to calculate the same value on all @@ -57,6 +54,7 @@ uint32_t buf_calc_page_crc32(const byte* page) - (FIL_PAGE_DATA + FIL_PAGE_END_LSN_OLD_CHKSUM)); } +#ifndef UNIV_INNOCHECKSUM /** Calculate a checksum which is stored to the page when it is written to a file. Note that we must be careful to calculate the same value on 32-bit and 64-bit architectures. @@ -98,32 +96,4 @@ buf_calc_page_old_checksum(const byte* page) return(static_cast<uint32_t> (ut_fold_binary(page, FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION))); } - -/** Return a printable string describing the checksum algorithm. -@param[in] algo algorithm -@return algorithm name */ -const char* -buf_checksum_algorithm_name(srv_checksum_algorithm_t algo) -{ - switch (algo) { - case SRV_CHECKSUM_ALGORITHM_CRC32: - return("crc32"); - case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32: - return("strict_crc32"); - case SRV_CHECKSUM_ALGORITHM_INNODB: - return("innodb"); - case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB: - return("strict_innodb"); - case SRV_CHECKSUM_ALGORITHM_NONE: - return("none"); - case SRV_CHECKSUM_ALGORITHM_STRICT_NONE: - return("strict_none"); - case SRV_CHECKSUM_ALGORITHM_FULL_CRC32: - return("full_crc32"); - case SRV_CHECKSUM_ALGORITHM_STRICT_FULL_CRC32: - return("strict_full_crc32"); - } - - ut_error; - return(NULL); -} +#endif /* !UNIV_INNOCHECKSUM */ diff --git a/storage/innobase/buf/buf0dblwr.cc b/storage/innobase/buf/buf0dblwr.cc index 6f61fd4b604..635a60918f5 100644 --- a/storage/innobase/buf/buf0dblwr.cc +++ b/storage/innobase/buf/buf0dblwr.cc @@ -300,7 +300,7 @@ func_exit: for (ulint i= 0; i < size * 2; i++, page += srv_page_size) { memset(page + FIL_PAGE_SPACE_ID, 0, 4); - /* For innodb_checksum_algorithm=innodb, we do not need to + /* For pre-MySQL-4.1 innodb_checksum_algorithm=innodb, we do not need to calculate new checksums for the pages because the field .._SPACE_ID does not affect them. Write the page back to where we read it from. */ diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc index 7df0739d9fb..b663fdf0ebc 100644 --- a/storage/innobase/buf/buf0flu.cc +++ b/storage/innobase/buf/buf0flu.cc @@ -412,9 +412,7 @@ void buf_flush_update_zip_checksum(buf_frame_t *page, ulint size) { ut_ad(size > 0); mach_write_to_4(page + FIL_PAGE_SPACE_OR_CHKSUM, - page_zip_calc_checksum(page, size, - static_cast<srv_checksum_algorithm_t> - (srv_checksum_algorithm))); + page_zip_calc_checksum(page, size, false)); } /** Assign the full crc32 checksum for non-compressed page. @@ -569,38 +567,8 @@ buf_flush_init_for_writing( } } - uint32_t checksum = BUF_NO_CHECKSUM_MAGIC; - - switch (srv_checksum_algorithm_t(srv_checksum_algorithm)) { - case SRV_CHECKSUM_ALGORITHM_INNODB: - case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB: - checksum = buf_calc_page_new_checksum(page); - mach_write_to_4(page + FIL_PAGE_SPACE_OR_CHKSUM, - checksum); - /* With the InnoDB checksum, we overwrite the first 4 bytes of - the end lsn field to store the old formula checksum. Since it - depends also on the field FIL_PAGE_SPACE_OR_CHKSUM, it has to - be calculated after storing the new formula checksum. */ - checksum = buf_calc_page_old_checksum(page); - break; - case SRV_CHECKSUM_ALGORITHM_FULL_CRC32: - case SRV_CHECKSUM_ALGORITHM_STRICT_FULL_CRC32: - case SRV_CHECKSUM_ALGORITHM_CRC32: - case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32: - /* In other cases we write the same checksum to both fields. */ - checksum = buf_calc_page_crc32(page); - mach_write_to_4(page + FIL_PAGE_SPACE_OR_CHKSUM, - checksum); - break; - case SRV_CHECKSUM_ALGORITHM_NONE: - case SRV_CHECKSUM_ALGORITHM_STRICT_NONE: - mach_write_to_4(page + FIL_PAGE_SPACE_OR_CHKSUM, - checksum); - break; - /* no default so the compiler will emit a warning if - new enum is added and not handled here */ - } - + const uint32_t checksum = buf_calc_page_crc32(page); + mach_write_to_4(page + FIL_PAGE_SPACE_OR_CHKSUM, checksum); mach_write_to_4(page + srv_page_size - FIL_PAGE_END_LSN_OLD_CHKSUM, checksum); } diff --git a/storage/innobase/fil/fil0crypt.cc b/storage/innobase/fil/fil0crypt.cc index ec8ea6cbe00..6bc799f8f2d 100644 --- a/storage/innobase/fil/fil0crypt.cc +++ b/storage/innobase/fil/fil0crypt.cc @@ -2466,46 +2466,31 @@ bool fil_space_verify_crypt_checksum(const byte* page, ulint zip_size) /* If stored checksum matches one of the calculated checksums page is not corrupted. */ - switch (srv_checksum_algorithm_t(srv_checksum_algorithm)) { +#ifndef UNIV_INNOCHECKSUM + switch (srv_checksum_algorithm) { case SRV_CHECKSUM_ALGORITHM_STRICT_FULL_CRC32: case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32: +#endif /* !UNIV_INNOCHECKSUM */ if (zip_size) { return checksum == page_zip_calc_checksum( - page, zip_size, SRV_CHECKSUM_ALGORITHM_CRC32); + page, zip_size, false); } return checksum == buf_calc_page_crc32(page); - case SRV_CHECKSUM_ALGORITHM_STRICT_NONE: - /* Starting with MariaDB 10.1.25, 10.2.7, 10.3.1, - due to MDEV-12114, fil_crypt_calculate_checksum() - is only using CRC32 for the encrypted pages. - Due to this, we must treat "strict_none" as "none". */ - case SRV_CHECKSUM_ALGORITHM_NONE: - return true; - case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB: - /* Starting with MariaDB 10.1.25, 10.2.7, 10.3.1, - due to MDEV-12114, fil_crypt_calculate_checksum() - is only using CRC32 for the encrypted pages. - Due to this, we must treat "strict_innodb" as "innodb". */ - case SRV_CHECKSUM_ALGORITHM_INNODB: - case SRV_CHECKSUM_ALGORITHM_CRC32: - case SRV_CHECKSUM_ALGORITHM_FULL_CRC32: +#ifndef UNIV_INNOCHECKSUM + default: if (checksum == BUF_NO_CHECKSUM_MAGIC) { return true; } if (zip_size) { return checksum == page_zip_calc_checksum( - page, zip_size, - SRV_CHECKSUM_ALGORITHM_CRC32) + page, zip_size, false) || checksum == page_zip_calc_checksum( - page, zip_size, - SRV_CHECKSUM_ALGORITHM_INNODB); + page, zip_size, true); } return checksum == buf_calc_page_crc32(page) || checksum == buf_calc_page_new_checksum(page); } - - ut_ad("unhandled innodb_checksum_algorithm" == 0); - return false; +#endif /* !UNIV_INNOCHECKSUM */ } diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index c103e636a80..401c1c4bb39 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -314,10 +314,6 @@ static TYPELIB innodb_stats_method_typelib = { const char* innodb_checksum_algorithm_names[] = { "crc32", "strict_crc32", - "innodb", - "strict_innodb", - "none", - "strict_none", "full_crc32", "strict_full_crc32", NullS diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h index 11b9d41b592..977b8d4ed5b 100644 --- a/storage/innobase/include/buf0buf.h +++ b/storage/innobase/include/buf0buf.h @@ -413,42 +413,6 @@ Decrements the bufferfix count. */ @return whether the buffer is all zeroes */ bool buf_is_zeroes(st_::span<const byte> buf); -/** Checks if the page is in crc32 checksum format. -@param[in] read_buf database page -@param[in] checksum_field1 new checksum field -@param[in] checksum_field2 old checksum field -@return true if the page is in crc32 checksum format. */ -bool -buf_page_is_checksum_valid_crc32( - const byte* read_buf, - ulint checksum_field1, - ulint checksum_field2) - MY_ATTRIBUTE((nonnull(1), warn_unused_result)); - -/** Checks if the page is in innodb checksum format. -@param[in] read_buf database page -@param[in] checksum_field1 new checksum field -@param[in] checksum_field2 old checksum field -@return true if the page is in innodb checksum format. */ -bool -buf_page_is_checksum_valid_innodb( - const byte* read_buf, - ulint checksum_field1, - ulint checksum_field2) - MY_ATTRIBUTE((nonnull(1), warn_unused_result)); - -/** Checks if the page is in none checksum format. -@param[in] read_buf database page -@param[in] checksum_field1 new checksum field -@param[in] checksum_field2 old checksum field -@return true if the page is in none checksum format. */ -bool -buf_page_is_checksum_valid_none( - const byte* read_buf, - ulint checksum_field1, - ulint checksum_field2) - MY_ATTRIBUTE((nonnull(1), warn_unused_result)); - /** Check if a page is corrupt. @param[in] check_lsn whether the LSN should be checked @param[in] read_buf database page diff --git a/storage/innobase/include/buf0checksum.h b/storage/innobase/include/buf0checksum.h index 8dc25f91d59..d9f03177812 100644 --- a/storage/innobase/include/buf0checksum.h +++ b/storage/innobase/include/buf0checksum.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2019, MariaDB Corporation. +Copyright (c) 2017, 2021, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -24,9 +24,7 @@ Buffer pool checksum functions, also linked from /extra/innochecksum.cc Created Aug 11, 2011 Vasil Dimov *******************************************************/ -#ifndef buf0checksum_h -#define buf0checksum_h - +#pragma once #include "buf0types.h" /** Calculate the CRC32 checksum of a page. The value is stored to the page @@ -37,6 +35,7 @@ architectures. @return CRC-32C */ uint32_t buf_calc_page_crc32(const byte* page); +#ifndef UNIV_INNOCHECKSUM /** Calculate a checksum which is stored to the page when it is written to a file. Note that we must be careful to calculate the same value on 32-bit and 64-bit architectures. @@ -55,13 +54,4 @@ because this takes that field as an input! @return checksum */ uint32_t buf_calc_page_old_checksum(const byte* page); - -/** Return a printable string describing the checksum algorithm. -@param[in] algo algorithm -@return algorithm name */ -const char* -buf_checksum_algorithm_name(srv_checksum_algorithm_t algo); - -extern ulong srv_checksum_algorithm; - -#endif /* buf0checksum_h */ +#endif /* !UNIV_INNOCHECKSUM */ diff --git a/storage/innobase/include/buf0types.h b/storage/innobase/include/buf0types.h index 4fb93e75515..679f3735392 100644 --- a/storage/innobase/include/buf0types.h +++ b/storage/innobase/include/buf0types.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2015, Oracle and/or its affiliates. All rights reserved. -Copyright (c) 2019, 2020, MariaDB Corporation. +Copyright (c) 2019, 2021, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -52,44 +52,26 @@ enum buf_io_fix { /** Alternatives for srv_checksum_algorithm, which can be changed by setting innodb_checksum_algorithm */ enum srv_checksum_algorithm_t { - SRV_CHECKSUM_ALGORITHM_CRC32, /*!< Write crc32, allow crc32, - innodb or none when reading */ - SRV_CHECKSUM_ALGORITHM_STRICT_CRC32, /*!< Write crc32, allow crc32 - when reading */ - SRV_CHECKSUM_ALGORITHM_INNODB, /*!< Write innodb, allow crc32, - innodb or none when reading */ - SRV_CHECKSUM_ALGORITHM_STRICT_INNODB, /*!< Write innodb, allow - innodb when reading */ - SRV_CHECKSUM_ALGORITHM_NONE, /*!< Write none, allow crc32, - innodb or none when reading */ - SRV_CHECKSUM_ALGORITHM_STRICT_NONE, /*!< Write none, allow none - when reading */ - - /** For new files, always compute CRC-32C for the whole page. - For old files, allow crc32, innodb or none when reading. */ - SRV_CHECKSUM_ALGORITHM_FULL_CRC32, - - /** For new files, always compute CRC-32C for the whole page. - For old files, allow crc32 when reading. */ - SRV_CHECKSUM_ALGORITHM_STRICT_FULL_CRC32 + /** Write crc32; allow full_crc32,crc32,innodb,none when reading */ + SRV_CHECKSUM_ALGORITHM_CRC32, + /** Write crc32; allow full_crc23,crc32 when reading */ + SRV_CHECKSUM_ALGORITHM_STRICT_CRC32, + /** For new files, always compute CRC-32C for the whole page. + For old files, allow crc32, innodb or none when reading. */ + SRV_CHECKSUM_ALGORITHM_FULL_CRC32, + /** For new files, always compute CRC-32C for the whole page. + For old files, allow crc32 when reading. */ + SRV_CHECKSUM_ALGORITHM_STRICT_FULL_CRC32 }; -inline -bool -is_checksum_strict(srv_checksum_algorithm_t algo) +inline bool is_checksum_strict(srv_checksum_algorithm_t algo) { - return(algo == SRV_CHECKSUM_ALGORITHM_STRICT_CRC32 - || algo == SRV_CHECKSUM_ALGORITHM_STRICT_INNODB - || algo == SRV_CHECKSUM_ALGORITHM_STRICT_NONE); + return algo == SRV_CHECKSUM_ALGORITHM_STRICT_CRC32; } -inline -bool -is_checksum_strict(ulint algo) +inline bool is_checksum_strict(ulint algo) { - return(algo == SRV_CHECKSUM_ALGORITHM_STRICT_CRC32 - || algo == SRV_CHECKSUM_ALGORITHM_STRICT_INNODB - || algo == SRV_CHECKSUM_ALGORITHM_STRICT_NONE); + return algo == SRV_CHECKSUM_ALGORITHM_STRICT_CRC32; } /** Parameters of binary buddy system for compressed pages (buf0buddy.h) */ diff --git a/storage/innobase/include/page0zip.h b/storage/innobase/include/page0zip.h index 5a70e995a1e..4c577e9e434 100644 --- a/storage/innobase/include/page0zip.h +++ b/storage/innobase/include/page0zip.h @@ -2,7 +2,7 @@ Copyright (c) 2005, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. -Copyright (c) 2017, 2020, MariaDB Corporation. +Copyright (c) 2017, 2021, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -361,15 +361,11 @@ page_zip_copy_recs( #endif /* !UNIV_INNOCHECKSUM */ /** Calculate the compressed page checksum. -@param[in] data compressed page -@param[in] size size of compressed page -@param[in] algo algorithm to use +@param data compressed page +@param size size of compressed page +@param use_adler whether to use Adler32 instead of a XOR of 3 CRC-32C @return page checksum */ -uint32_t -page_zip_calc_checksum( - const void* data, - ulint size, - srv_checksum_algorithm_t algo); +uint32_t page_zip_calc_checksum(const void *data, size_t size, bool use_adler); /** Validate the checksum on a ROW_FORMAT=COMPRESSED page. @param data ROW_FORMAT=COMPRESSED page diff --git a/storage/innobase/include/srv0srv.h b/storage/innobase/include/srv0srv.h index e201771f2ef..fbbf5216742 100644 --- a/storage/innobase/include/srv0srv.h +++ b/storage/innobase/include/srv0srv.h @@ -343,6 +343,9 @@ extern ulong srv_buf_pool_load_pages_abort; /** Lock table size in bytes */ extern ulint srv_lock_table_size; +/** the value of innodb_checksum_algorithm */ +extern ulong srv_checksum_algorithm; + extern uint srv_n_file_io_threads; extern my_bool srv_random_read_ahead; extern ulong srv_read_ahead_threshold; diff --git a/storage/innobase/include/univ.i b/storage/innobase/include/univ.i index 9808e34c860..c8d4ef9444a 100644 --- a/storage/innobase/include/univ.i +++ b/storage/innobase/include/univ.i @@ -78,15 +78,7 @@ support cross-platform development and expose comonly used SQL names. */ #include <my_global.h> #include "my_counter.h" #include <m_string.h> - -/* JAN: TODO: missing 5.7 header */ -#ifdef HAVE_MY_THREAD_H -//# include <my_thread.h> -#endif - -#ifndef UNIV_INNOCHECKSUM -# include <mysqld_error.h> -#endif /* !UNIV_INNOCHECKSUM */ +#include <mysqld_error.h> /* Include <sys/stat.h> to get S_I... macros defined for os0file.cc */ #include <sys/stat.h> @@ -415,12 +407,6 @@ in both 32-bit and 64-bit environments. */ # define UINT64PFx "%016" PRIx64 #endif -#ifdef UNIV_INNOCHECKSUM -extern bool strict_verify; -extern FILE* log_file; -extern unsigned long long cur_page_num; -#endif /* UNIV_INNOCHECKSUM */ - typedef int64_t ib_int64_t; typedef uint64_t ib_uint64_t; typedef uint32_t ib_uint32_t; diff --git a/storage/innobase/page/page0zip.cc b/storage/innobase/page/page0zip.cc index b25f034d0ae..00cc934a289 100644 --- a/storage/innobase/page/page0zip.cc +++ b/storage/innobase/page/page0zip.cc @@ -2,7 +2,7 @@ Copyright (c) 2005, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. -Copyright (c) 2014, 2020, MariaDB Corporation. +Copyright (c) 2014, 2021, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -4616,37 +4616,26 @@ page_zip_copy_recs( #endif /* !UNIV_INNOCHECKSUM */ /** Calculate the compressed page checksum. -@param[in] data compressed page -@param[in] size size of compressed page -@param[in] algo algorithm to use +@param data compressed page +@param size size of compressed page +@param use_adler whether to use Adler32 instead of a XOR of 3 CRC-32C @return page checksum */ -uint32_t -page_zip_calc_checksum( - const void* data, - ulint size, - srv_checksum_algorithm_t algo) +uint32_t page_zip_calc_checksum(const void *data, size_t size, bool use_adler) { uLong adler; const Bytef* s = static_cast<const byte*>(data); /* Exclude FIL_PAGE_SPACE_OR_CHKSUM, FIL_PAGE_LSN, and FIL_PAGE_FILE_FLUSH_LSN from the checksum. */ + ut_ad(size > FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID); - switch (algo) { - case SRV_CHECKSUM_ALGORITHM_FULL_CRC32: - case SRV_CHECKSUM_ALGORITHM_STRICT_FULL_CRC32: - case SRV_CHECKSUM_ALGORITHM_CRC32: - case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32: - ut_ad(size > FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID); + if (!use_adler) { return ut_crc32(s + FIL_PAGE_OFFSET, FIL_PAGE_LSN - FIL_PAGE_OFFSET) ^ ut_crc32(s + FIL_PAGE_TYPE, 2) ^ ut_crc32(s + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID, size - FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID); - case SRV_CHECKSUM_ALGORITHM_INNODB: - case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB: - ut_ad(size > FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID); - + } else { adler = adler32(0L, s + FIL_PAGE_OFFSET, FIL_PAGE_LSN - FIL_PAGE_OFFSET); adler = adler32(adler, s + FIL_PAGE_TYPE, 2); @@ -4656,15 +4645,7 @@ page_zip_calc_checksum( - FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID); return(uint32_t(adler)); - case SRV_CHECKSUM_ALGORITHM_NONE: - case SRV_CHECKSUM_ALGORITHM_STRICT_NONE: - return(BUF_NO_CHECKSUM_MAGIC); - /* no default so the compiler will emit a warning if new enum - is added and not handled here */ } - - ut_error; - return(0); } /** Validate the checksum on a ROW_FORMAT=COMPRESSED page. @@ -4673,13 +4654,6 @@ page_zip_calc_checksum( @return whether the stored checksum matches innodb_checksum_algorithm */ bool page_zip_verify_checksum(const byte *data, size_t size) { - const srv_checksum_algorithm_t curr_algo = - static_cast<srv_checksum_algorithm_t>(srv_checksum_algorithm); - - if (curr_algo == SRV_CHECKSUM_ALGORITHM_NONE) { - return true; - } - if (buf_is_zeroes(span<const byte>(data, size))) { return true; } @@ -4687,62 +4661,37 @@ bool page_zip_verify_checksum(const byte *data, size_t size) const uint32_t stored = mach_read_from_4( data + FIL_PAGE_SPACE_OR_CHKSUM); - uint32_t calc = page_zip_calc_checksum(data, size, curr_algo); + uint32_t calc = page_zip_calc_checksum(data, size, false); #ifdef UNIV_INNOCHECKSUM + extern FILE* log_file; + extern unsigned long long cur_page_num; + if (log_file) { fprintf(log_file, "page::%llu;" - " %s checksum: calculated = %u;" + " checksum: calculated = %u;" " recorded = %u\n", cur_page_num, - buf_checksum_algorithm_name( - static_cast<srv_checksum_algorithm_t>( - srv_checksum_algorithm)), calc, stored); } - - if (!strict_verify) { - const uint32_t crc32 = page_zip_calc_checksum( - data, size, SRV_CHECKSUM_ALGORITHM_CRC32); - - if (log_file) { - fprintf(log_file, "page::%llu: crc32 checksum:" - " calculated = %u; recorded = %u\n", - cur_page_num, crc32, stored); - fprintf(log_file, "page::%llu: none checksum:" - " calculated = %lu; recorded = %u\n", - cur_page_num, BUF_NO_CHECKSUM_MAGIC, stored); - } - } #endif /* UNIV_INNOCHECKSUM */ if (stored == calc) { return(TRUE); } - switch (curr_algo) { +#ifndef UNIV_INNOCHECKSUM + switch (srv_checksum_algorithm) { case SRV_CHECKSUM_ALGORITHM_STRICT_FULL_CRC32: case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32: - case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB: - case SRV_CHECKSUM_ALGORITHM_STRICT_NONE: - return FALSE; - case SRV_CHECKSUM_ALGORITHM_FULL_CRC32: - case SRV_CHECKSUM_ALGORITHM_CRC32: + break; + default: if (stored == BUF_NO_CHECKSUM_MAGIC) { return(TRUE); } - return stored == page_zip_calc_checksum( - data, size, SRV_CHECKSUM_ALGORITHM_INNODB); - case SRV_CHECKSUM_ALGORITHM_INNODB: - if (stored == BUF_NO_CHECKSUM_MAGIC) { - return TRUE; - } - - return stored == page_zip_calc_checksum( - data, size, SRV_CHECKSUM_ALGORITHM_CRC32); - case SRV_CHECKSUM_ALGORITHM_NONE: - return TRUE; + return stored == page_zip_calc_checksum(data, size, true); } +#endif /* !UNIV_INNOCHECKSUM */ return FALSE; } diff --git a/storage/innobase/srv/srv0srv.cc b/storage/innobase/srv/srv0srv.cc index fc49968948e..21bfe81f9a8 100644 --- a/storage/innobase/srv/srv0srv.cc +++ b/storage/innobase/srv/srv0srv.cc @@ -40,9 +40,6 @@ Created 10/8/1995 Heikki Tuuri *******************************************************/ #include "my_global.h" -// JAN: TODO: MySQL 5.7 missing header -//#include "my_thread.h" -// #include "mysql/psi/mysql_stage.h" #include "mysql/psi/psi.h" @@ -219,6 +216,9 @@ ulong srv_buf_pool_load_pages_abort = LONG_MAX; /** Lock table size in bytes */ ulint srv_lock_table_size = ULINT_MAX; +/** the value of innodb_checksum_algorithm */ +ulong srv_checksum_algorithm; + /** innodb_read_io_threads */ uint srv_n_read_io_threads; /** innodb_write_io_threads */ |