1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

MDEV-25105 Remove innodb_checksum_algorithm values none,innodb,...

Historically, InnoDB supported a buggy page checksum algorithm that did not
compute a checksum over the full page. Later, well before MySQL 4.1
introduced .ibd files and the innodb_file_per_table option, the algorithm
was corrected and the first 4 bytes of each page were redefined to be
a checksum.

The original checksum was so slow that an option to disable page checksum
was introduced for benchmarketing purposes.

The Intel Nehalem microarchitecture introduced the SSE4.2 instruction set
extension, which includes instructions for faster computation of CRC-32C.
In MySQL 5.6 (and MariaDB 10.0), innodb_checksum_algorithm=crc32 was
implemented to make of that. As that option was changed to be the default
in MySQL 5.7, a bug was found on big-endian platforms and some work-around
code was added to weaken that checksum further. MariaDB disables that
work-around by default since MDEV-17958.

Later, SIMD-accelerated CRC-32C has been implemented in MariaDB for POWER
and ARM and also for IA-32/AMD64, making use of carry-less multiplication
where available.

Long story short, innodb_checksum_algorithm=crc32 is faster and more secure
than the pre-MySQL 5.6 checksum, called innodb_checksum_algorithm=innodb.
It should have removed any need to use innodb_checksum_algorithm=none.

The setting innodb_checksum_algorithm=crc32 is the default in
MySQL 5.7 and MariaDB Server 10.2, 10.3, 10.4. In MariaDB 10.5,
MDEV-19534 made innodb_checksum_algorithm=full_crc32 the default.
It is even faster and more secure.

The default settings in MariaDB do allow old data files to be read,
no matter if a worse checksum algorithm had been used.
(Unfortunately, before innodb_checksum_algorithm=full_crc32,
the data files did not identify which checksum algorithm is being used.)

The non-default settings innodb_checksum_algorithm=strict_crc32 or
innodb_checksum_algorithm=strict_full_crc32 would only allow CRC-32C
checksums. The incompatibility with old data files is why they are
not the default.

The newest server not to support innodb_checksum_algorithm=crc32
were MySQL 5.5 and MariaDB 5.5. Both have reached their end of life.
A valid reason for using innodb_checksum_algorithm=innodb could have
been the ability to downgrade. If it is really needed, data files
can be converted with an older version of the innochecksum utility.

Because there is no good reason to allow data files to be written
with insecure checksums, we will reject those option values:

    innodb_checksum_algorithm=none
    innodb_checksum_algorithm=innodb
    innodb_checksum_algorithm=strict_none
    innodb_checksum_algorithm=strict_innodb

Furthermore, the following innochecksum options will be removed,
because only strict crc32 will be supported:

    innochecksum --strict-check=crc32
    innochecksum -C crc32
    innochecksum --write=crc32
    innochecksum -w crc32

If a user wishes to convert a data file to use a different checksum
(so that it might be used with the no-longer-supported
MySQL 5.5 or MariaDB 5.5, which do not support IMPORT TABLESPACE
nor system tablespace format changes that were made in MariaDB 10.3),
then the innochecksum tool from MariaDB 10.2, 10.3, 10.4, 10.5 or
MySQL 5.7 can be used.

Reviewed by: Thirunarayanan Balathandayuthapani
This commit is contained in:
Marko Mäkelä
2021-03-11 11:56:35 +02:00
parent 0da6d67a3a
commit 7a4fbb55b0
38 changed files with 251 additions and 1845 deletions

View File

@ -1,6 +1,6 @@
/* /*
Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. 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 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 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 do_leaf;
static my_bool per_page_details; static my_bool per_page_details;
static ulint n_merge; static ulint n_merge;
extern ulong srv_checksum_algorithm;
static ulint physical_page_size; /* Page size in bytes on disk. */ static ulint physical_page_size; /* Page size in bytes on disk. */
ulong srv_page_size; ulong srv_page_size;
ulong srv_page_size_shift; ulong srv_page_size_shift;
@ -78,8 +77,6 @@ unsigned long long cur_page_num;
unsigned long long cur_space; unsigned long long cur_space;
/* Skip the checksum verification. */ /* Skip the checksum verification. */
static bool no_check; static bool no_check;
/* Enabled for strict checksum verification. */
bool strict_verify = 0;
/* Enabled for rewrite checksum. */ /* Enabled for rewrite checksum. */
static bool do_write; static bool do_write;
/* Mismatches count allowed (0 by default). */ /* Mismatches count allowed (0 by default). */
@ -102,11 +99,6 @@ static bool is_log_enabled = false;
struct flock lk; struct flock lk;
#endif /* _WIN32 */ #endif /* _WIN32 */
/* Strict check algorithm name. */
static ulong strict_check;
/* Rewrite checksum algorithm name. */
static ulong write_check;
/* Innodb page type. */ /* Innodb page type. */
struct innodb_page_type { struct innodb_page_type {
int n_undo_state_active; int n_undo_state_active;
@ -136,24 +128,6 @@ struct innodb_page_type {
int n_fil_page_type_page_compressed_encrypted; int n_fil_page_type_page_compressed_encrypted;
} page_type; } 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 SIZE_RANGES_FOR_PAGE 10
#define NUM_RETRIES 3 #define NUM_RETRIES 3
#define DEFAULT_RETRY_DELAY 1000000 #define DEFAULT_RETRY_DELAY 1000000
@ -646,10 +620,9 @@ static bool update_checksum(byte* page, ulint flags)
} }
if (iscompressed) { if (iscompressed) {
/* page is compressed */ /* ROW_FORMAT=COMPRESSED */
checksum = page_zip_calc_checksum( checksum = page_zip_calc_checksum(page, physical_page_size,
page, physical_page_size, false);
static_cast<srv_checksum_algorithm_t>(write_check));
mach_write_to_4(page + FIL_PAGE_SPACE_OR_CHKSUM, checksum); mach_write_to_4(page + FIL_PAGE_SPACE_OR_CHKSUM, checksum);
if (is_log_enabled) { if (is_log_enabled) {
@ -673,50 +646,16 @@ static bool update_checksum(byte* page, ulint flags)
/* page is uncompressed. */ /* page is uncompressed. */
/* Store the new formula checksum */ /* Store the new formula checksum */
switch ((srv_checksum_algorithm_t) write_check) { checksum = buf_calc_page_crc32(page);
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 */
}
mach_write_to_4(page + FIL_PAGE_SPACE_OR_CHKSUM, checksum); mach_write_to_4(page + FIL_PAGE_SPACE_OR_CHKSUM, checksum);
if (is_log_enabled) { 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); " = %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 - mach_write_to_4(page + physical_page_size -
FIL_PAGE_END_LSN_OLD_CHKSUM,checksum); 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: func_exit:
@ -1270,17 +1209,11 @@ static struct my_option innochecksum_options[] = {
{"page", 'p', "Check only this page (0 based).", {"page", 'p', "Check only this page (0 based).",
&do_page, &do_page, 0, GET_ULL, REQUIRED_ARG, &do_page, &do_page, 0, GET_ULL, REQUIRED_ARG,
0, 0, ULLONG_MAX, 0, 1, 0}, 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", 'n', "Ignore the checksum verification.",
&no_check, &no_check, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, &no_check, &no_check, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"allow-mismatches", 'a', "Maximum checksum mismatch allowed.", {"allow-mismatches", 'a', "Maximum checksum mismatch allowed.",
&allow_mismatches, &allow_mismatches, 0, &allow_mismatches, &allow_mismatches, 0,
GET_ULL, REQUIRED_ARG, 0, 0, ULLONG_MAX, 0, 1, 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 " {"page-type-summary", 'S', "Display a count of each page type "
"in a tablespace.", &page_type_summary, &page_type_summary, 0, "in a tablespace.", &page_type_summary, &page_type_summary, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 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("InnoDB offline file checksum utility.\n");
printf("Usage: %s [-c] [-s <start page>] [-e <end page>] " printf("Usage: %s [-c] [-s <start page>] [-e <end page>] "
"[-p <page>] [-i] [-v] [-a <allow mismatches>] [-n] " "[-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); "[-l <log>] [-l] [-m <merge pages>] <filename or [-]>\n", my_progname);
printf("See https://mariadb.com/kb/en/library/innochecksum/" printf("See https://mariadb.com/kb/en/library/innochecksum/"
" for usage hints.\n"); " for usage hints.\n");
@ -1358,38 +1291,6 @@ innochecksum_get_one_option(
my_end(0); my_end(0);
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
break; 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': case 'n':
no_check = true; no_check = true;
break; break;
@ -1592,13 +1493,6 @@ int main(
goto my_exit; 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) { if (no_check && !do_write) {
fprintf(stderr, "Error: --no-check must be associated with " fprintf(stderr, "Error: --no-check must be associated with "
"--write option.\n"); "--write option.\n");

View File

@ -1556,7 +1556,7 @@ struct my_option xb_server_options[] =
{"innodb_checksum_algorithm", OPT_INNODB_CHECKSUM_ALGORITHM, {"innodb_checksum_algorithm", OPT_INNODB_CHECKSUM_ALGORITHM,
"The algorithm InnoDB uses for page checksumming. [CRC32, STRICT_CRC32, " "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, &srv_checksum_algorithm, &innodb_checksum_algorithm_typelib, GET_ENUM,
REQUIRED_ARG, SRV_CHECKSUM_ALGORITHM_CRC32, 0, 0, 0, 0, 0}, REQUIRED_ARG, SRV_CHECKSUM_ALGORITHM_CRC32, 0, 0, 0, 0, 0},

View File

@ -1,13 +1,6 @@
[crc32]
--innodb-checksum-algorithm=crc32
[strict_crc32] [strict_crc32]
--innodb-checksum-algorithm=strict_crc32 --innodb-checksum-algorithm=strict_crc32
--innodb-flush-sync=OFF --innodb-flush-sync=OFF
[full_crc32]
--innodb-checksum-algorithm=full_crc32
[strict_full_crc32] [strict_full_crc32]
--innodb-checksum-algorithm=strict_full_crc32 --innodb-checksum-algorithm=strict_full_crc32
--innodb-flush-sync=OFF

View File

@ -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; CREATE TABLE t1(a BIGINT PRIMARY KEY) ENGINE=InnoDB, ENCRYPTED=YES;
INSERT INTO t1 VALUES(1); INSERT INTO t1 VALUES(1);
CREATE TABLE t2(a BIGINT PRIMARY KEY) ENGINE=InnoDB, ENCRYPTED=YES; CREATE TABLE t2(a BIGINT PRIMARY KEY) ENGINE=InnoDB, ENCRYPTED=YES;

View File

@ -1,38 +1,14 @@
--- suite/encryption/r/innodb-checksum-algorithm.result --- suite/encryption/r/innodb-checksum-algorithm.result
+++ 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_default_encryption_key_id=4;
SET GLOBAL innodb_checksum_algorithm=crc32; create table tce(a serial, b blob, index(b(10))) engine=innodb
create table tce_crc32(a serial, b blob, index(b(10))) engine=innodb
-ROW_FORMAT=COMPRESSED encrypted=yes; -ROW_FORMAT=COMPRESSED encrypted=yes;
+ROW_FORMAT=DYNAMIC 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=COMPRESSED encrypted=no;
+ROW_FORMAT=DYNAMIC encrypted=no; +ROW_FORMAT=DYNAMIC encrypted=no;
Warnings: Warnings:
Warning 140 InnoDB: ENCRYPTED=NO implies ENCRYPTION_KEY_ID=1 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
@@ -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

View File

@ -1,38 +1,14 @@
--- suite/encryption/r/innodb-checksum-algorithm.result --- suite/encryption/r/innodb-checksum-algorithm.result
+++ 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_default_encryption_key_id=4;
SET GLOBAL innodb_checksum_algorithm=crc32; create table tce(a serial, b blob, index(b(10))) engine=innodb
create table tce_crc32(a serial, b blob, index(b(10))) engine=innodb
-ROW_FORMAT=COMPRESSED encrypted=yes; -ROW_FORMAT=COMPRESSED encrypted=yes;
+ROW_FORMAT=DYNAMIC 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=COMPRESSED encrypted=no;
+ROW_FORMAT=DYNAMIC encrypted=no; +ROW_FORMAT=DYNAMIC encrypted=no;
Warnings: Warnings:
Warning 140 InnoDB: ENCRYPTED=NO implies ENCRYPTION_KEY_ID=1 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
@@ -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

View File

@ -1,439 +1,98 @@
SET @saved_file_per_table = @@global.innodb_file_per_table; 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_encrypt_tables = @@global.innodb_encrypt_tables;
SET @saved_encryption_threads = @@global.innodb_encryption_threads; SET @saved_encryption_threads = @@global.innodb_encryption_threads;
SET @saved_encryption_key_id = @@global.innodb_default_encryption_key_id; SET @saved_encryption_key_id = @@global.innodb_default_encryption_key_id;
SET GLOBAL innodb_file_per_table = ON; SET GLOBAL innodb_file_per_table = ON;
SET GLOBAL innodb_encrypt_tables = ON; SET GLOBAL innodb_encrypt_tables = ON;
SET GLOBAL innodb_encryption_threads = 4; 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_default_encryption_key_id=4;
SET GLOBAL innodb_checksum_algorithm=crc32; create table tce(a serial, b blob, index(b(10))) engine=innodb
create table tce_crc32(a serial, b blob, index(b(10))) engine=innodb
ROW_FORMAT=COMPRESSED encrypted=yes; 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; ROW_FORMAT=COMPRESSED encrypted=no;
Warnings: Warnings:
Warning 140 InnoDB: ENCRYPTED=NO implies ENCRYPTION_KEY_ID=1 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; 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; encrypted=no;
Warnings: Warnings:
Warning 140 InnoDB: ENCRYPTED=NO implies ENCRYPTION_KEY_ID=1 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; 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; page_compressed=yes encrypted=no;
Warnings: Warnings:
Warning 140 InnoDB: ENCRYPTED=NO implies ENCRYPTION_KEY_ID=1 Warning 140 InnoDB: ENCRYPTED=NO implies ENCRYPTION_KEY_ID=1
begin; begin;
insert into tce_crc32(b) values (repeat('secret',20)); insert into tce(b) values (repeat('secret',20));
insert into tc_crc32(b) values (repeat('secret',20)); insert into tc(b) values (repeat('secret',20));
insert into te_crc32(b) values (repeat('secret',20)); insert into te(b) values (repeat('secret',20));
insert into t_crc32(b) values (repeat('secret',20)); insert into t(b) values (repeat('secret',20));
insert into tpe_crc32(b) values (repeat('secret',20)); insert into tpe(b) values (repeat('secret',20));
insert into tp_crc32(b) values (repeat('secret',20)); insert into tp(b) values (repeat('secret',20));
commit; commit;
FLUSH TABLES tce_crc32, tc_crc32, te_crc32, FLUSH TABLES tce, tc, te, t, tpe, tp FOR EXPORT;
t_crc32, tpe_crc32, tp_crc32 FOR EXPORT; backup: tce
backup: tce_crc32 backup: tc
backup: tc_crc32 backup: te
backup: te_crc32 backup: t
backup: t_crc32 backup: tpe
backup: tpe_crc32 backup: tp
backup: tp_crc32
db.opt db.opt
t_crc32.cfg t.cfg
t_crc32.frm t.frm
t_crc32.ibd t.ibd
tc_crc32.cfg tc.cfg
tc_crc32.frm tc.frm
tc_crc32.ibd tc.ibd
tce_crc32.cfg tce.cfg
tce_crc32.frm tce.frm
tce_crc32.ibd tce.ibd
te_crc32.cfg te.cfg
te_crc32.frm te.frm
te_crc32.ibd te.ibd
tp_crc32.cfg tp.cfg
tp_crc32.frm tp.frm
tp_crc32.ibd tp.ibd
tpe_crc32.cfg tpe.cfg
tpe_crc32.frm tpe.frm
tpe_crc32.ibd tpe.ibd
UNLOCK TABLES; UNLOCK TABLES;
SET GLOBAL innodb_checksum_algorithm=crc32; ALTER TABLE tce DISCARD TABLESPACE;
ALTER TABLE tce_crc32 DISCARD TABLESPACE; ALTER TABLE tc DISCARD TABLESPACE;
ALTER TABLE tc_crc32 DISCARD TABLESPACE; ALTER TABLE te DISCARD TABLESPACE;
ALTER TABLE te_crc32 DISCARD TABLESPACE; ALTER TABLE t DISCARD TABLESPACE;
ALTER TABLE t_crc32 DISCARD TABLESPACE; ALTER TABLE tpe DISCARD TABLESPACE;
ALTER TABLE tpe_crc32 DISCARD TABLESPACE; ALTER TABLE tp DISCARD TABLESPACE;
ALTER TABLE tp_crc32 DISCARD TABLESPACE; restore: tce .ibd and .cfg files
restore: tce_crc32 .ibd and .cfg files restore: tc .ibd and .cfg files
restore: tc_crc32 .ibd and .cfg files restore: te .ibd and .cfg files
restore: te_crc32 .ibd and .cfg files restore: t .ibd and .cfg files
restore: t_crc32 .ibd and .cfg files restore: tpe .ibd and .cfg files
restore: tpe_crc32 .ibd and .cfg files restore: tp .ibd and .cfg files
restore: tp_crc32 .ibd and .cfg files ALTER TABLE tce IMPORT TABLESPACE;
ALTER TABLE tce_crc32 IMPORT TABLESPACE; update tce set b=substr(b,1);
update tce_crc32 set b=substr(b,1); ALTER TABLE tc IMPORT TABLESPACE;
ALTER TABLE tc_crc32 IMPORT TABLESPACE; update tc set b=substr(b,1);
update tc_crc32 set b=substr(b,1); ALTER TABLE te IMPORT TABLESPACE;
ALTER TABLE te_crc32 IMPORT TABLESPACE; update te set b=substr(b,1);
update te_crc32 set b=substr(b,1); ALTER TABLE t IMPORT TABLESPACE;
ALTER TABLE t_crc32 IMPORT TABLESPACE; update t set b=substr(b,1);
update t_crc32 set b=substr(b,1); ALTER TABLE tpe IMPORT TABLESPACE;
ALTER TABLE tpe_crc32 IMPORT TABLESPACE; update tpe set b=substr(b,1);
update tpe_crc32 set b=substr(b,1); ALTER TABLE tp IMPORT TABLESPACE;
ALTER TABLE tp_crc32 IMPORT TABLESPACE; update tp set b=substr(b,1);
update tp_crc32 set b=substr(b,1); CHECK TABLE tce, tc, te, t, tpe, tp;
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;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.tce_crc32 check status OK test.tce check status OK
test.tc_crc32 check status OK test.tc check status OK
test.te_crc32 check status OK test.te check status OK
test.t_crc32 check status OK test.t check status OK
test.tpe_crc32 check status OK test.tpe check status OK
test.tp_crc32 check status OK test.tp check status OK
DROP TABLE tce_crc32, tc_crc32, te_crc32, DROP TABLE tce, tc, te, t, tpe, tp;
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;
SET GLOBAL innodb_file_per_table = @saved_file_per_table; 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_encrypt_tables = @saved_encrypt_tables;
SET GLOBAL innodb_encryption_threads = @saved_encryption_threads; SET GLOBAL innodb_encryption_threads = @saved_encryption_threads;
SET GLOBAL innodb_default_encryption_key_id = @saved_encryption_key_id; SET GLOBAL innodb_default_encryption_key_id = @saved_encryption_key_id;

View File

@ -1,5 +1,7 @@
[strict_crc32] [strict_crc32]
--innodb-checksum-algorithm=strict_crc32 --innodb-checksum-algorithm=strict_crc32
--skip-innodb-doublewrite
[strict_full_crc32] [strict_full_crc32]
--innodb-checksum-algorithm=strict_full_crc32 --innodb-checksum-algorithm=strict_full_crc32
--skip-innodb-doublewrite

View File

@ -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."); 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 --enable_query_log
let INNODB_CHECKSUM_ALGORITHM = `SELECT @@innodb_checksum_algorithm`;
let INNODB_PAGE_SIZE=`select @@innodb_page_size`; 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; CREATE TABLE t1(a BIGINT PRIMARY KEY) ENGINE=InnoDB, ENCRYPTED=YES;
INSERT INTO t1 VALUES(1); INSERT INTO t1 VALUES(1);
# Force a redo log checkpoint. # Force a redo log checkpoint.

View File

@ -1,8 +1,8 @@
-- source include/innodb_checksum_algorithm.inc
-- source include/innodb_page_size.inc -- source include/innodb_page_size.inc
-- source include/have_file_key_management_plugin.inc -- source include/have_file_key_management_plugin.inc
SET @saved_file_per_table = @@global.innodb_file_per_table; 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_encrypt_tables = @@global.innodb_encrypt_tables;
SET @saved_encryption_threads = @@global.innodb_encryption_threads; SET @saved_encryption_threads = @@global.innodb_encryption_threads;
SET @saved_encryption_key_id = @@global.innodb_default_encryption_key_id; 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_encrypt_tables = ON;
SET GLOBAL innodb_encryption_threads = 4; 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_default_encryption_key_id=4;
let MYSQLD_DATADIR =`SELECT @@datadir`; 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 let $row_format_compressed= `select case when @@global.innodb_page_size>16384
then 'ROW_FORMAT=DYNAMIC' else 'ROW_FORMAT=COMPRESSED' end`; then 'ROW_FORMAT=DYNAMIC' else 'ROW_FORMAT=COMPRESSED' end`;
let $from = 3; eval create table tce(a serial, b blob, index(b(10))) engine=innodb
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
$row_format_compressed encrypted=yes; $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; $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; 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; 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; 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; page_compressed=yes encrypted=no;
begin; begin;
eval insert into tce_$checksum(b) values (repeat('secret',20)); eval insert into tce(b) values (repeat('secret',20));
eval insert into tc_$checksum(b) values (repeat('secret',20)); eval insert into tc(b) values (repeat('secret',20));
eval insert into te_$checksum(b) values (repeat('secret',20)); eval insert into te(b) values (repeat('secret',20));
eval insert into t_$checksum(b) values (repeat('secret',20)); eval insert into t(b) values (repeat('secret',20));
eval insert into tpe_$checksum(b) values (repeat('secret',20)); eval insert into tpe(b) values (repeat('secret',20));
eval insert into tp_$checksum(b) values (repeat('secret',20)); eval insert into tp(b) values (repeat('secret',20));
commit; commit;
eval FLUSH TABLES tce_$checksum, tc_$checksum, te_$checksum, eval FLUSH TABLES tce, tc, te, t, tpe, tp FOR EXPORT;
t_$checksum, tpe_$checksum, tp_$checksum FOR EXPORT;
perl; perl;
do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
my @tables = ("tce_", "tc_", "te_", "t_", "tpe_", "tp_"); ib_backup_tablespaces("test", ("tce", "tc", "te", "t", "tpe", "tp"));
ib_backup_tablespaces("test", map{ $_ . $ENV{checksum} } @tables);
EOF EOF
--list_files $MYSQLD_DATADIR/test --list_files $MYSQLD_DATADIR/test
UNLOCK TABLES; UNLOCK TABLES;
let $to = 3; ALTER TABLE tce DISCARD TABLESPACE;
while ($to) ALTER TABLE tc DISCARD TABLESPACE;
{ ALTER TABLE te DISCARD TABLESPACE;
dec $to; ALTER TABLE t DISCARD TABLESPACE;
let $tocksum = `select case $to ALTER TABLE tpe DISCARD TABLESPACE;
when 0 then 'none' ALTER TABLE tp DISCARD TABLESPACE;
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;
perl; perl;
do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
my @tables = ("tce_", "tc_", "te_", "t_", "tpe_", "tp_"); ib_restore_tablespaces("test", ("tce", "tc", "te", "t", "tpe", "tp"));
ib_restore_tablespaces("test", map{ $_ . $ENV{checksum} } @tables);
EOF EOF
eval ALTER TABLE tce_$checksum IMPORT TABLESPACE; ALTER TABLE tce IMPORT TABLESPACE;
eval update tce_$checksum set b=substr(b,1); update tce set b=substr(b,1);
eval ALTER TABLE tc_$checksum IMPORT TABLESPACE; ALTER TABLE tc IMPORT TABLESPACE;
eval update tc_$checksum set b=substr(b,1); update tc set b=substr(b,1);
eval ALTER TABLE te_$checksum IMPORT TABLESPACE; ALTER TABLE te IMPORT TABLESPACE;
eval update te_$checksum set b=substr(b,1); update te set b=substr(b,1);
eval ALTER TABLE t_$checksum IMPORT TABLESPACE; ALTER TABLE t IMPORT TABLESPACE;
eval update t_$checksum set b=substr(b,1); update t set b=substr(b,1);
eval ALTER TABLE tpe_$checksum IMPORT TABLESPACE; ALTER TABLE tpe IMPORT TABLESPACE;
eval update tpe_$checksum set b=substr(b,1); update tpe set b=substr(b,1);
eval ALTER TABLE tp_$checksum IMPORT TABLESPACE; ALTER TABLE tp IMPORT TABLESPACE;
eval update tp_$checksum set b=substr(b,1); update tp set b=substr(b,1);
}
eval CHECK TABLE tce_$checksum, tc_$checksum, te_$checksum, CHECK TABLE tce, tc, te, t, tpe, tp;
t_$checksum, tpe_$checksum, tp_$checksum; DROP TABLE tce, tc, te, t, tpe, tp;
eval DROP TABLE tce_$checksum, tc_$checksum, te_$checksum,
t_$checksum, tpe_$checksum, tp_$checksum;
}
SET GLOBAL innodb_file_per_table = @saved_file_per_table; 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_encrypt_tables = @saved_encrypt_tables;
SET GLOBAL innodb_encryption_threads = @saved_encryption_threads; SET GLOBAL innodb_encryption_threads = @saved_encryption_threads;
SET GLOBAL innodb_default_encryption_key_id = @saved_encryption_key_id; SET GLOBAL innodb_default_encryption_key_id = @saved_encryption_key_id;

View File

@ -1,4 +0,0 @@
[crc32]
loose-innodb-checksum-algorithm=crc32
[none]
loose-innodb-checksum-algorithm=none

View File

@ -54,7 +54,7 @@ close IBD_FILE;
EOF EOF
--error 1 --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_FILE = $MYSQLTEST_VARDIR/tmp/result.log;
let SEARCH_PATTERN=page id mismatch; let SEARCH_PATTERN=page id mismatch;

View File

@ -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;

View File

@ -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: 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"); 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 TABLE tab1(c1 INT PRIMARY KEY,c2 VARCHAR(20)) ENGINE=InnoDB;
CREATE INDEX idx1 ON tab1(c2(10)); CREATE INDEX idx1 ON tab1(c2(10));
INSERT INTO tab1 VALUES(1, 'Innochecksum InnoDB1'); 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 # Shutdown the Server
# Server Default checksum = innodb # Server Default checksum = innodb
[1b]: check the innochecksum without --strict-check [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 [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 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 [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 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 [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 [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 FOUND 1 /unknown option '-C'/ in my_restart.err
[8]: check the innochecksum with short & full form combination FOUND 1 /unknown variable 'write=crc32'/ in my_restart.err
# 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;
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 # restart
SELECT * FROM tab1;
c1 c2
1 Innochecksum InnoDB1
DROP TABLE tab1; DROP TABLE tab1;

View File

@ -25,10 +25,8 @@ count FALSE
start-page 0 start-page 0
end-page 0 end-page 0
page 0 page 0
strict-check crc32
no-check FALSE no-check FALSE
allow-mismatches 0 allow-mismatches 0
write crc32
page-type-summary FALSE page-type-summary FALSE
page-type-dump MYSQLTEST_VARDIR/tmp/dump.txt page-type-dump MYSQLTEST_VARDIR/tmp/dump.txt
per-page-details FALSE per-page-details FALSE
@ -42,7 +40,7 @@ innochecksum Ver #.#.#
Copyright (c) YEAR, YEAR , Oracle, MariaDB Corporation Ab and others. Copyright (c) YEAR, YEAR , Oracle, MariaDB Corporation Ab and others.
InnoDB offline file checksum utility. 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. See https://mariadb.com/kb/en/library/innochecksum/ for usage hints.
-?, --help Displays this help and exits. -?, --help Displays this help and exits.
-I, --info Synonym for --help. -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). -s, --start-page=# Start on this page number (0 based).
-e, --end-page=# End at this page number (0 based). -e, --end-page=# End at this page number (0 based).
-p, --page=# Check only this page (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. -n, --no-check Ignore the checksum verification.
-a, --allow-mismatches=# -a, --allow-mismatches=#
Maximum checksum mismatch allowed. 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 -S, --page-type-summary
Display a count of each page type in a tablespace. Display a count of each page type in a tablespace.
-D, --page-type-dump=name -D, --page-type-dump=name
@ -80,10 +73,8 @@ count FALSE
start-page 0 start-page 0
end-page 0 end-page 0
page 0 page 0
strict-check crc32
no-check FALSE no-check FALSE
allow-mismatches 0 allow-mismatches 0
write crc32
page-type-summary FALSE page-type-summary FALSE
page-type-dump (No default value) page-type-dump (No default value)
per-page-details FALSE per-page-details FALSE
@ -96,67 +87,3 @@ Number of pages:#
[4]:# Print the version of innochecksum and exit [4]:# Print the version of innochecksum and exit
innochecksum Ver #.#.## Restart the DB server innochecksum Ver #.#.## Restart the DB server
DROP TABLE t1; 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

View File

@ -1,7 +1,6 @@
# Set the environmental variables # 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: Unable to read tablespace .* page no .* into the buffer pool after 100 attempts");
call mtr.add_suppression("InnoDB: innodb_checksum_algorithm is set to.*"); 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, CREATE TABLE tab1 (pk INTEGER NOT NULL PRIMARY KEY,
linestring_key GEOMETRY NOT NULL, linestring_key GEOMETRY NOT NULL,
linestring_nokey 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); 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) 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); 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 # stop the server
[2]: Check the page type summary with shortform for tab1.ibd [2]: Check the page type summary with shortform for tab1.ibd
@ -184,10 +131,8 @@ count FALSE
start-page 0 start-page 0
end-page 0 end-page 0
page 0 page 0
strict-check crc32
no-check FALSE no-check FALSE
allow-mismatches 0 allow-mismatches 0
write crc32
page-type-summary FALSE page-type-summary FALSE
page-type-dump MYSQLTEST_VARDIR/tmp/dump.txt page-type-dump MYSQLTEST_VARDIR/tmp/dump.txt
per-page-details FALSE per-page-details FALSE

View File

@ -1,5 +0,0 @@
[crc32]
--innodb-checksum-algorithm=crc32
[full_crc32]
--innodb-checksum-algorithm=full_crc32

View File

@ -1 +0,0 @@
--skip-innodb-doublewrite

View File

@ -1,19 +1,12 @@
#************************************************************ #************************************************************
# WL6045:Improve Innochecksum # WL6045:Improve Innochecksum
#************************************************************ #************************************************************
--source include/innodb_page_size_small.inc --source include/have_innodb.inc
--source include/no_valgrind_without_big.inc --source include/no_valgrind_without_big.inc
# Embedded server does not support crashing.
--source include/not_embedded.inc --source include/not_embedded.inc
# Avoid CrashReporter popup on Mac. let $MYSQLD_DATADIR= `SELECT @@datadir`;
--source include/not_crashrep.inc
--echo # Set the environmental variables
let MYSQLD_BASEDIR= `SELECT @@basedir`;
let MYSQLD_DATADIR= `SELECT @@datadir`;
let SEARCH_FILE= $MYSQLTEST_VARDIR/log/my_restart.err; 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: 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"); 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 TABLE tab1(c1 INT PRIMARY KEY,c2 VARCHAR(20)) ENGINE=InnoDB;
CREATE INDEX idx1 ON tab1(c2(10)); CREATE INDEX idx1 ON tab1(c2(10));
INSERT INTO tab1 VALUES(1, 'Innochecksum InnoDB1'); 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 --echo # Shutdown the Server
--source include/shutdown_mysqld.inc --source include/shutdown_mysqld.inc
@ -42,12 +31,6 @@ insert into t1 values(3,"compressed table");
--echo [1b]: check the innochecksum without --strict-check --echo [1b]: check the innochecksum without --strict-check
--exec $INNOCHECKSUM $MYSQLD_DATADIR/test/tab1.ibd --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 --echo [4]: check the innochecksum with --no-check ignores algorithm check, warning is expected
--error 1 --error 1
--exec $INNOCHECKSUM --no-check $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE --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 --echo [6]: check the innochecksum with full form strict-check & no-check , an error is expected
--error 1 --error 1
--exec $INNOCHECKSUM --strict-check=innodb --no-check $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE --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 --source include/search_pattern_in_file.inc
--echo [7]: check the innochecksum with short form strict-check & no-check , an error is expected --echo [7]: check the innochecksum with short form strict-check & no-check , an error is expected
--error 1 --error 1
--exec $INNOCHECKSUM -C innodb -n $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE --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.; let SEARCH_PATTERN= unknown option '-C';
--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 --source include/search_pattern_in_file.inc
--error 1 --error 1
--exec $INNOCHECKSUM -C strict_innodb $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE --exec $INNOCHECKSUM --no-check --write=crc32 $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE
let SEARCH_PATTERN= Error while setting value \'strict_innodb\' to \'strict-check\'; let SEARCH_PATTERN= unknown variable 'write=crc32';
--source include/search_pattern_in_file.inc --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\';
--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 --source include/start_mysqld.inc
SELECT * FROM tab1; 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; DROP TABLE tab1;

View File

@ -3,7 +3,6 @@
#************************************************************ #************************************************************
--source include/innodb_page_size_small.inc --source include/innodb_page_size_small.inc
--source include/have_debug.inc --source include/have_debug.inc
--source include/no_valgrind_without_big.inc
# Avoid CrashReporter popup on Mac. # Avoid CrashReporter popup on Mac.
--source include/not_crashrep.inc --source include/not_crashrep.inc
@ -93,27 +92,3 @@ EOF
--source include/start_mysqld.inc --source include/start_mysqld.inc
DROP TABLE t1; 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

View File

@ -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: Unable to read tablespace .* page no .* into the buffer pool after 100 attempts");
call mtr.add_suppression("InnoDB: innodb_checksum_algorithm is set to.*"); 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, CREATE TABLE tab1 (pk INTEGER NOT NULL PRIMARY KEY,
linestring_key GEOMETRY NOT NULL, linestring_key GEOMETRY NOT NULL,
linestring_nokey GEOMETRY NOT NULL) linestring_nokey GEOMETRY NOT NULL)
@ -59,137 +57,6 @@ while ($i) {
dec $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 --echo # stop the server
--source include/shutdown_mysqld.inc --source include/shutdown_mysqld.inc

View File

@ -10,22 +10,6 @@ SET GLOBAL innodb_checksum_algorithm = 'strict_crc32';
SELECT @@global.innodb_checksum_algorithm; SELECT @@global.innodb_checksum_algorithm;
@@global.innodb_checksum_algorithm @@global.innodb_checksum_algorithm
strict_crc32 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'; SET GLOBAL innodb_checksum_algorithm = 'full_crc32';
SELECT @@global.innodb_checksum_algorithm; SELECT @@global.innodb_checksum_algorithm;
@@global.innodb_checksum_algorithm @@global.innodb_checksum_algorithm

View File

@ -294,7 +294,7 @@ VARIABLE_COMMENT The algorithm InnoDB uses for page checksumming. Possible value
NUMERIC_MIN_VALUE NULL NUMERIC_MIN_VALUE NULL
NUMERIC_MAX_VALUE NULL NUMERIC_MAX_VALUE NULL
NUMERIC_BLOCK_SIZE 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 READ_ONLY NO
COMMAND_LINE_ARGUMENT REQUIRED COMMAND_LINE_ARGUMENT REQUIRED
VARIABLE_NAME INNODB_CMP_PER_INDEX_ENABLED VARIABLE_NAME INNODB_CMP_PER_INDEX_ENABLED

View File

@ -10,18 +10,6 @@ SELECT @@global.innodb_checksum_algorithm;
SET GLOBAL innodb_checksum_algorithm = 'strict_crc32'; SET GLOBAL innodb_checksum_algorithm = 'strict_crc32';
SELECT @@global.innodb_checksum_algorithm; 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'; SET GLOBAL innodb_checksum_algorithm = 'full_crc32';
SELECT @@global.innodb_checksum_algorithm; SELECT @@global.innodb_checksum_algorithm;

View File

@ -500,6 +500,7 @@ decrypt_failed:
@param[in] checksum_field1 new checksum field @param[in] checksum_field1 new checksum field
@param[in] checksum_field2 old checksum field @param[in] checksum_field2 old checksum field
@return true if the page is in crc32 checksum format. */ @return true if the page is in crc32 checksum format. */
static
bool bool
buf_page_is_checksum_valid_crc32( buf_page_is_checksum_valid_crc32(
const byte* read_buf, const byte* read_buf,
@ -509,8 +510,9 @@ buf_page_is_checksum_valid_crc32(
const uint32_t crc32 = buf_calc_page_crc32(read_buf); const uint32_t crc32 = buf_calc_page_crc32(read_buf);
#ifdef UNIV_INNOCHECKSUM #ifdef UNIV_INNOCHECKSUM
if (log_file extern FILE* log_file;
&& srv_checksum_algorithm == SRV_CHECKSUM_ALGORITHM_STRICT_CRC32) { extern unsigned long long cur_page_num;
if (log_file) {
fprintf(log_file, "page::%llu;" fprintf(log_file, "page::%llu;"
" crc32 calculated = %u;" " crc32 calculated = %u;"
" recorded checksum field1 = " ULINTPF " recorded" " recorded checksum field1 = " ULINTPF " recorded"
@ -526,132 +528,6 @@ buf_page_is_checksum_valid_crc32(
return checksum_field1 == 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 /** Checks whether the lsn present in the page is lesser than the
peek current lsn. peek current lsn.
@param[in] check_lsn lsn to check @param[in] check_lsn lsn to check
@ -759,11 +635,10 @@ buf_page_is_corrupted(
return false; return false;
} }
size_t checksum_field1 = 0; #ifndef UNIV_INNOCHECKSUM
size_t checksum_field2 = 0;
uint32_t crc32 = 0; uint32_t crc32 = 0;
bool crc32_inited = false; bool crc32_inited = false;
bool crc32_chksum = false; #endif /* !UNIV_INNOCHECKSUM */
const ulint zip_size = fil_space_t::zip_size(fsp_flags); const ulint zip_size = fil_space_t::zip_size(fsp_flags);
const uint16_t page_type = fil_page_get_type(read_buf); 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 */ /* 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) { if (zip_size) {
return !page_zip_verify_checksum(read_buf, 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); 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); read_buf + srv_page_size - FIL_PAGE_END_LSN_OLD_CHKSUM);
static_assert(FIL_PAGE_LSN % 8 == 0, "alignment"); 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_FULL_CRC32:
case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32: case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32:
#endif /* !UNIV_INNOCHECKSUM */
return !buf_page_is_checksum_valid_crc32( return !buf_page_is_checksum_valid_crc32(
read_buf, checksum_field1, checksum_field2); read_buf, checksum_field1, checksum_field2);
case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB: #ifndef UNIV_INNOCHECKSUM
return !buf_page_is_checksum_valid_innodb( default:
read_buf, checksum_field1, checksum_field2); if (checksum_field1 == BUF_NO_CHECKSUM_MAGIC
case SRV_CHECKSUM_ALGORITHM_STRICT_NONE: && checksum_field2 == BUF_NO_CHECKSUM_MAGIC) {
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 */
return false; 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 /* Very old versions of InnoDB only stored 8 byte lsn to the
start and the end of the page. */ start and the end of the page. */
@ -900,43 +743,29 @@ buf_page_is_corrupted(
!= mach_read_from_4(read_buf + FIL_PAGE_LSN) != mach_read_from_4(read_buf + FIL_PAGE_LSN)
&& checksum_field2 != BUF_NO_CHECKSUM_MAGIC) { && checksum_field2 != BUF_NO_CHECKSUM_MAGIC) {
if (crc32_chksum) { crc32 = buf_calc_page_crc32(read_buf);
crc32 = buf_calc_page_crc32(read_buf); crc32_inited = true;
crc32_inited = true;
DBUG_EXECUTE_IF( DBUG_EXECUTE_IF(
"page_intermittent_checksum_mismatch", { "page_intermittent_checksum_mismatch", {
static int page_counter; static int page_counter;
if (page_counter++ == 2) { if (page_counter++ == 2) {
crc32++; crc32++;
} }
}); });
if (checksum_field2 != crc32 if (checksum_field2 != crc32
&& checksum_field2 && checksum_field2
!= buf_calc_page_old_checksum(read_buf)) { != buf_calc_page_old_checksum(read_buf)) {
return true; 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_field1 == 0 switch (checksum_field1) {
|| checksum_field1 == BUF_NO_CHECKSUM_MAGIC) { case 0:
} else if (crc32_chksum) { case BUF_NO_CHECKSUM_MAGIC:
break;
default:
if (!crc32_inited) { if (!crc32_inited) {
crc32 = buf_calc_page_crc32(read_buf); crc32 = buf_calc_page_crc32(read_buf);
crc32_inited = true; crc32_inited = true;
@ -947,38 +776,15 @@ buf_page_is_corrupted(
!= buf_calc_page_new_checksum(read_buf)) { != buf_calc_page_new_checksum(read_buf)) {
return true; 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 return crc32_inited
&& ((checksum_field1 == crc32 && ((checksum_field1 == crc32
&& checksum_field2 != crc32) && checksum_field2 != crc32)
|| (checksum_field1 != crc32 || (checksum_field1 != crc32
&& checksum_field2 == crc32))) { && checksum_field2 == crc32));
return true;
}
break;
case SRV_CHECKSUM_ALGORITHM_NONE:
/* should have returned false earlier */
break;
} }
#endif /* !UNIV_INNOCHECKSUM */
return false;
} }
#ifndef UNIV_INNOCHECKSUM #ifndef UNIV_INNOCHECKSUM
@ -1048,26 +854,10 @@ void buf_page_print(const byte* read_buf, ulint zip_size)
<< mach_read_from_4( << mach_read_from_4(
read_buf + FIL_PAGE_SPACE_OR_CHKSUM) read_buf + FIL_PAGE_SPACE_OR_CHKSUM)
<< "; calculated checksums for field1: " << "; calculated checksums for field1: "
<< buf_checksum_algorithm_name( << "crc32 "
SRV_CHECKSUM_ALGORITHM_CRC32) << page_zip_calc_checksum(read_buf, zip_size, false)
<< " " << ", adler32 "
<< page_zip_calc_checksum( << page_zip_calc_checksum(read_buf, zip_size, true)
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)
<< "; page LSN " << "; page LSN "
<< mach_read_from_8(read_buf + FIL_PAGE_LSN) << mach_read_from_8(read_buf + FIL_PAGE_LSN)
<< "; page number (if stored to page" << "; 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 " ib::info() << "Uncompressed page, stored checksum in field1 "
<< mach_read_from_4( << mach_read_from_4(
read_buf + FIL_PAGE_SPACE_OR_CHKSUM) read_buf + FIL_PAGE_SPACE_OR_CHKSUM)
<< ", calculated checksums for field1: " << ", calculated checksums for field1: crc32 "
<< buf_checksum_algorithm_name(
SRV_CHECKSUM_ALGORITHM_CRC32) << " "
<< crc32 << crc32
<< ", " << ", innodb "
<< buf_checksum_algorithm_name(
SRV_CHECKSUM_ALGORITHM_INNODB) << " "
<< buf_calc_page_new_checksum(read_buf) << buf_calc_page_new_checksum(read_buf)
<< ", " << ", page type " << page_type
<< " page type " << page_type << " == "
<< fil_get_page_type_name(page_type) << "."
<< buf_checksum_algorithm_name(
SRV_CHECKSUM_ALGORITHM_NONE) << " "
<< BUF_NO_CHECKSUM_MAGIC
<< ", stored checksum in field2 " << ", stored checksum in field2 "
<< mach_read_from_4(read_buf + srv_page_size << mach_read_from_4(read_buf + srv_page_size
- FIL_PAGE_END_LSN_OLD_CHKSUM) - FIL_PAGE_END_LSN_OLD_CHKSUM)
<< ", calculated checksums for field2: " << ", innodb checksum for field2: "
<< buf_checksum_algorithm_name(
SRV_CHECKSUM_ALGORITHM_CRC32) << " "
<< crc32
<< ", "
<< buf_checksum_algorithm_name(
SRV_CHECKSUM_ALGORITHM_INNODB) << " "
<< buf_calc_page_old_checksum(read_buf) << buf_calc_page_old_checksum(read_buf)
<< ", "
<< buf_checksum_algorithm_name(
SRV_CHECKSUM_ALGORITHM_NONE) << " "
<< BUF_NO_CHECKSUM_MAGIC
<< ", page LSN " << ", page LSN "
<< mach_read_from_4(read_buf + FIL_PAGE_LSN) << mach_read_from_4(read_buf + FIL_PAGE_LSN)
<< " " << " "
@ -2660,15 +2431,9 @@ buf_zip_decompress(
<< block->page.id() << ": stored: " << block->page.id() << ": stored: "
<< mach_read_from_4(frame + FIL_PAGE_SPACE_OR_CHKSUM) << mach_read_from_4(frame + FIL_PAGE_SPACE_OR_CHKSUM)
<< ", crc32: " << ", crc32: "
<< page_zip_calc_checksum( << page_zip_calc_checksum(frame, size, false)
frame, size, SRV_CHECKSUM_ALGORITHM_CRC32) << " adler32: "
<< " innodb: " << page_zip_calc_checksum(frame, size, true);
<< 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 << ")";
goto err_exit; goto err_exit;
} }

View File

@ -1,7 +1,7 @@
/***************************************************************************** /*****************************************************************************
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. 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 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 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" #include "srv0srv.h"
#endif /* !UNIV_INNOCHECKSUM */ #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 /** 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 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 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)); - (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 /** 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 to a file. Note that we must be careful to calculate the same value on
32-bit and 64-bit architectures. 32-bit and 64-bit architectures.
@ -98,32 +96,4 @@ buf_calc_page_old_checksum(const byte* page)
return(static_cast<uint32_t> return(static_cast<uint32_t>
(ut_fold_binary(page, FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION))); (ut_fold_binary(page, FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION)));
} }
#endif /* !UNIV_INNOCHECKSUM */
/** 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);
}

View File

@ -300,7 +300,7 @@ func_exit:
for (ulint i= 0; i < size * 2; i++, page += srv_page_size) for (ulint i= 0; i < size * 2; i++, page += srv_page_size)
{ {
memset(page + FIL_PAGE_SPACE_ID, 0, 4); 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 calculate new checksums for the pages because the field
.._SPACE_ID does not affect them. Write the page back to where .._SPACE_ID does not affect them. Write the page back to where
we read it from. */ we read it from. */

View File

@ -412,9 +412,7 @@ void buf_flush_update_zip_checksum(buf_frame_t *page, ulint size)
{ {
ut_ad(size > 0); ut_ad(size > 0);
mach_write_to_4(page + FIL_PAGE_SPACE_OR_CHKSUM, mach_write_to_4(page + FIL_PAGE_SPACE_OR_CHKSUM,
page_zip_calc_checksum(page, size, page_zip_calc_checksum(page, size, false));
static_cast<srv_checksum_algorithm_t>
(srv_checksum_algorithm)));
} }
/** Assign the full crc32 checksum for non-compressed page. /** 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; const uint32_t checksum = buf_calc_page_crc32(page);
mach_write_to_4(page + FIL_PAGE_SPACE_OR_CHKSUM, checksum);
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 */
}
mach_write_to_4(page + srv_page_size - FIL_PAGE_END_LSN_OLD_CHKSUM, mach_write_to_4(page + srv_page_size - FIL_PAGE_END_LSN_OLD_CHKSUM,
checksum); checksum);
} }

View File

@ -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 /* If stored checksum matches one of the calculated checksums
page is not corrupted. */ 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_FULL_CRC32:
case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32: case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32:
#endif /* !UNIV_INNOCHECKSUM */
if (zip_size) { if (zip_size) {
return checksum == page_zip_calc_checksum( return checksum == page_zip_calc_checksum(
page, zip_size, SRV_CHECKSUM_ALGORITHM_CRC32); page, zip_size, false);
} }
return checksum == buf_calc_page_crc32(page); return checksum == buf_calc_page_crc32(page);
case SRV_CHECKSUM_ALGORITHM_STRICT_NONE: #ifndef UNIV_INNOCHECKSUM
/* Starting with MariaDB 10.1.25, 10.2.7, 10.3.1, default:
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:
if (checksum == BUF_NO_CHECKSUM_MAGIC) { if (checksum == BUF_NO_CHECKSUM_MAGIC) {
return true; return true;
} }
if (zip_size) { if (zip_size) {
return checksum == page_zip_calc_checksum( return checksum == page_zip_calc_checksum(
page, zip_size, page, zip_size, false)
SRV_CHECKSUM_ALGORITHM_CRC32)
|| checksum == page_zip_calc_checksum( || checksum == page_zip_calc_checksum(
page, zip_size, page, zip_size, true);
SRV_CHECKSUM_ALGORITHM_INNODB);
} }
return checksum == buf_calc_page_crc32(page) return checksum == buf_calc_page_crc32(page)
|| checksum == buf_calc_page_new_checksum(page); || checksum == buf_calc_page_new_checksum(page);
} }
#endif /* !UNIV_INNOCHECKSUM */
ut_ad("unhandled innodb_checksum_algorithm" == 0);
return false;
} }

View File

@ -314,10 +314,6 @@ static TYPELIB innodb_stats_method_typelib = {
const char* innodb_checksum_algorithm_names[] = { const char* innodb_checksum_algorithm_names[] = {
"crc32", "crc32",
"strict_crc32", "strict_crc32",
"innodb",
"strict_innodb",
"none",
"strict_none",
"full_crc32", "full_crc32",
"strict_full_crc32", "strict_full_crc32",
NullS NullS

View File

@ -413,42 +413,6 @@ Decrements the bufferfix count. */
@return whether the buffer is all zeroes */ @return whether the buffer is all zeroes */
bool buf_is_zeroes(st_::span<const byte> buf); 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. /** Check if a page is corrupt.
@param[in] check_lsn whether the LSN should be checked @param[in] check_lsn whether the LSN should be checked
@param[in] read_buf database page @param[in] read_buf database page

View File

@ -1,7 +1,7 @@
/***************************************************************************** /*****************************************************************************
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. 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 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 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 Created Aug 11, 2011 Vasil Dimov
*******************************************************/ *******************************************************/
#ifndef buf0checksum_h #pragma once
#define buf0checksum_h
#include "buf0types.h" #include "buf0types.h"
/** Calculate the CRC32 checksum of a page. The value is stored to the page /** Calculate the CRC32 checksum of a page. The value is stored to the page
@ -37,6 +35,7 @@ architectures.
@return CRC-32C */ @return CRC-32C */
uint32_t buf_calc_page_crc32(const byte* page); 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 /** 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 to a file. Note that we must be careful to calculate the same value on
32-bit and 64-bit architectures. 32-bit and 64-bit architectures.
@ -55,13 +54,4 @@ because this takes that field as an input!
@return checksum */ @return checksum */
uint32_t uint32_t
buf_calc_page_old_checksum(const byte* page); buf_calc_page_old_checksum(const byte* page);
#endif /* !UNIV_INNOCHECKSUM */
/** 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 */

View File

@ -1,7 +1,7 @@
/***************************************************************************** /*****************************************************************************
Copyright (c) 1995, 2015, Oracle and/or its affiliates. All rights reserved. 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 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 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 /** Alternatives for srv_checksum_algorithm, which can be changed by
setting innodb_checksum_algorithm */ setting innodb_checksum_algorithm */
enum srv_checksum_algorithm_t { enum srv_checksum_algorithm_t {
SRV_CHECKSUM_ALGORITHM_CRC32, /*!< Write crc32, allow crc32, /** Write crc32; allow full_crc32,crc32,innodb,none when reading */
innodb or none when reading */ SRV_CHECKSUM_ALGORITHM_CRC32,
SRV_CHECKSUM_ALGORITHM_STRICT_CRC32, /*!< Write crc32, allow crc32 /** Write crc32; allow full_crc23,crc32 when reading */
when reading */ SRV_CHECKSUM_ALGORITHM_STRICT_CRC32,
SRV_CHECKSUM_ALGORITHM_INNODB, /*!< Write innodb, allow crc32, /** For new files, always compute CRC-32C for the whole page.
innodb or none when reading */ For old files, allow crc32, innodb or none when reading. */
SRV_CHECKSUM_ALGORITHM_STRICT_INNODB, /*!< Write innodb, allow SRV_CHECKSUM_ALGORITHM_FULL_CRC32,
innodb when reading */ /** For new files, always compute CRC-32C for the whole page.
SRV_CHECKSUM_ALGORITHM_NONE, /*!< Write none, allow crc32, For old files, allow crc32 when reading. */
innodb or none when reading */ SRV_CHECKSUM_ALGORITHM_STRICT_FULL_CRC32
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
}; };
inline inline bool is_checksum_strict(srv_checksum_algorithm_t algo)
bool
is_checksum_strict(srv_checksum_algorithm_t algo)
{ {
return(algo == SRV_CHECKSUM_ALGORITHM_STRICT_CRC32 return algo == SRV_CHECKSUM_ALGORITHM_STRICT_CRC32;
|| algo == SRV_CHECKSUM_ALGORITHM_STRICT_INNODB
|| algo == SRV_CHECKSUM_ALGORITHM_STRICT_NONE);
} }
inline inline bool is_checksum_strict(ulint algo)
bool
is_checksum_strict(ulint algo)
{ {
return(algo == SRV_CHECKSUM_ALGORITHM_STRICT_CRC32 return algo == SRV_CHECKSUM_ALGORITHM_STRICT_CRC32;
|| algo == SRV_CHECKSUM_ALGORITHM_STRICT_INNODB
|| algo == SRV_CHECKSUM_ALGORITHM_STRICT_NONE);
} }
/** Parameters of binary buddy system for compressed pages (buf0buddy.h) */ /** Parameters of binary buddy system for compressed pages (buf0buddy.h) */

View File

@ -2,7 +2,7 @@
Copyright (c) 2005, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2005, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc. 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 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 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 */ #endif /* !UNIV_INNOCHECKSUM */
/** Calculate the compressed page checksum. /** Calculate the compressed page checksum.
@param[in] data compressed page @param data compressed page
@param[in] size size of compressed page @param size size of compressed page
@param[in] algo algorithm to use @param use_adler whether to use Adler32 instead of a XOR of 3 CRC-32C
@return page checksum */ @return page checksum */
uint32_t uint32_t page_zip_calc_checksum(const void *data, size_t size, bool use_adler);
page_zip_calc_checksum(
const void* data,
ulint size,
srv_checksum_algorithm_t algo);
/** Validate the checksum on a ROW_FORMAT=COMPRESSED page. /** Validate the checksum on a ROW_FORMAT=COMPRESSED page.
@param data ROW_FORMAT=COMPRESSED page @param data ROW_FORMAT=COMPRESSED page

View File

@ -343,6 +343,9 @@ extern ulong srv_buf_pool_load_pages_abort;
/** Lock table size in bytes */ /** Lock table size in bytes */
extern ulint srv_lock_table_size; 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 uint srv_n_file_io_threads;
extern my_bool srv_random_read_ahead; extern my_bool srv_random_read_ahead;
extern ulong srv_read_ahead_threshold; extern ulong srv_read_ahead_threshold;

View File

@ -78,15 +78,7 @@ support cross-platform development and expose comonly used SQL names. */
#include <my_global.h> #include <my_global.h>
#include "my_counter.h" #include "my_counter.h"
#include <m_string.h> #include <m_string.h>
#include <mysqld_error.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 <sys/stat.h> to get S_I... macros defined for os0file.cc */ /* Include <sys/stat.h> to get S_I... macros defined for os0file.cc */
#include <sys/stat.h> #include <sys/stat.h>
@ -415,12 +407,6 @@ in both 32-bit and 64-bit environments. */
# define UINT64PFx "%016" PRIx64 # define UINT64PFx "%016" PRIx64
#endif #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 int64_t ib_int64_t;
typedef uint64_t ib_uint64_t; typedef uint64_t ib_uint64_t;
typedef uint32_t ib_uint32_t; typedef uint32_t ib_uint32_t;

View File

@ -2,7 +2,7 @@
Copyright (c) 2005, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2005, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc. 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 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 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 */ #endif /* !UNIV_INNOCHECKSUM */
/** Calculate the compressed page checksum. /** Calculate the compressed page checksum.
@param[in] data compressed page @param data compressed page
@param[in] size size of compressed page @param size size of compressed page
@param[in] algo algorithm to use @param use_adler whether to use Adler32 instead of a XOR of 3 CRC-32C
@return page checksum */ @return page checksum */
uint32_t uint32_t page_zip_calc_checksum(const void *data, size_t size, bool use_adler)
page_zip_calc_checksum(
const void* data,
ulint size,
srv_checksum_algorithm_t algo)
{ {
uLong adler; uLong adler;
const Bytef* s = static_cast<const byte*>(data); const Bytef* s = static_cast<const byte*>(data);
/* Exclude FIL_PAGE_SPACE_OR_CHKSUM, FIL_PAGE_LSN, /* Exclude FIL_PAGE_SPACE_OR_CHKSUM, FIL_PAGE_LSN,
and FIL_PAGE_FILE_FLUSH_LSN from the checksum. */ and FIL_PAGE_FILE_FLUSH_LSN from the checksum. */
ut_ad(size > FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID);
switch (algo) { if (!use_adler) {
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);
return ut_crc32(s + FIL_PAGE_OFFSET, return ut_crc32(s + FIL_PAGE_OFFSET,
FIL_PAGE_LSN - FIL_PAGE_OFFSET) FIL_PAGE_LSN - FIL_PAGE_OFFSET)
^ ut_crc32(s + FIL_PAGE_TYPE, 2) ^ ut_crc32(s + FIL_PAGE_TYPE, 2)
^ ut_crc32(s + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID, ^ ut_crc32(s + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID,
size - FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID); size - FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID);
case SRV_CHECKSUM_ALGORITHM_INNODB: } else {
case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB:
ut_ad(size > FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID);
adler = adler32(0L, s + FIL_PAGE_OFFSET, adler = adler32(0L, s + FIL_PAGE_OFFSET,
FIL_PAGE_LSN - FIL_PAGE_OFFSET); FIL_PAGE_LSN - FIL_PAGE_OFFSET);
adler = adler32(adler, s + FIL_PAGE_TYPE, 2); adler = adler32(adler, s + FIL_PAGE_TYPE, 2);
@ -4656,15 +4645,7 @@ page_zip_calc_checksum(
- FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID); - FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID);
return(uint32_t(adler)); 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. /** 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 */ @return whether the stored checksum matches innodb_checksum_algorithm */
bool page_zip_verify_checksum(const byte *data, size_t size) 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))) { if (buf_is_zeroes(span<const byte>(data, size))) {
return true; 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( const uint32_t stored = mach_read_from_4(
data + FIL_PAGE_SPACE_OR_CHKSUM); 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 #ifdef UNIV_INNOCHECKSUM
extern FILE* log_file;
extern unsigned long long cur_page_num;
if (log_file) { if (log_file) {
fprintf(log_file, "page::%llu;" fprintf(log_file, "page::%llu;"
" %s checksum: calculated = %u;" " checksum: calculated = %u;"
" recorded = %u\n", cur_page_num, " recorded = %u\n", cur_page_num,
buf_checksum_algorithm_name(
static_cast<srv_checksum_algorithm_t>(
srv_checksum_algorithm)),
calc, stored); 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 */ #endif /* UNIV_INNOCHECKSUM */
if (stored == calc) { if (stored == calc) {
return(TRUE); return(TRUE);
} }
switch (curr_algo) { #ifndef UNIV_INNOCHECKSUM
switch (srv_checksum_algorithm) {
case SRV_CHECKSUM_ALGORITHM_STRICT_FULL_CRC32: case SRV_CHECKSUM_ALGORITHM_STRICT_FULL_CRC32:
case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32: case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32:
case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB: break;
case SRV_CHECKSUM_ALGORITHM_STRICT_NONE: default:
return FALSE;
case SRV_CHECKSUM_ALGORITHM_FULL_CRC32:
case SRV_CHECKSUM_ALGORITHM_CRC32:
if (stored == BUF_NO_CHECKSUM_MAGIC) { if (stored == BUF_NO_CHECKSUM_MAGIC) {
return(TRUE); return(TRUE);
} }
return stored == page_zip_calc_checksum( return stored == page_zip_calc_checksum(data, size, true);
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;
} }
#endif /* !UNIV_INNOCHECKSUM */
return FALSE; return FALSE;
} }

View File

@ -40,9 +40,6 @@ Created 10/8/1995 Heikki Tuuri
*******************************************************/ *******************************************************/
#include "my_global.h" #include "my_global.h"
// JAN: TODO: MySQL 5.7 missing header
//#include "my_thread.h"
//
#include "mysql/psi/mysql_stage.h" #include "mysql/psi/mysql_stage.h"
#include "mysql/psi/psi.h" #include "mysql/psi/psi.h"
@ -219,6 +216,9 @@ ulong srv_buf_pool_load_pages_abort = LONG_MAX;
/** Lock table size in bytes */ /** Lock table size in bytes */
ulint srv_lock_table_size = ULINT_MAX; ulint srv_lock_table_size = ULINT_MAX;
/** the value of innodb_checksum_algorithm */
ulong srv_checksum_algorithm;
/** innodb_read_io_threads */ /** innodb_read_io_threads */
uint srv_n_read_io_threads; uint srv_n_read_io_threads;
/** innodb_write_io_threads */ /** innodb_write_io_threads */