Commit 34eef269 authored by Jan Lindström's avatar Jan Lindström

MDEV-11939: innochecksum mistakes a file for an encrypted one (page 0 invalid)

Always read full page 0 to determine does tablespace contain
encryption metadata. Tablespaces that are page compressed or
page compressed and encrypted do not compare checksum as
it does not exists. For encrypted tables use checksum
verification written for encrypted tables and normal tables
use normal method.

buf_page_is_checksum_valid_crc32
buf_page_is_checksum_valid_innodb
buf_page_is_checksum_valid_none
        Modify Innochecksum logging to file to avoid compilation
	warnings.

fil0crypt.cc fil0crypt.h
        Modify to be able to use in innochecksum compilation and
        move fil_space_verify_crypt_checksum to end of the file.
        Add innochecksum logging to file.

univ.i
        Add innochecksum strict_verify, log_file and cur_page_num
        variables as extern.

page_zip_verify_checksum
        Add innochecksum logging to file and remove unnecessary code.

innochecksum.cc
        Lot of changes most notable able to read encryption
        metadata from page 0 of the tablespace.

Added test case where we corrupt intentionally
FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION (encryption key version)
FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION+4 (post encryption checksum)
FIL_DATA+10 (data)
parent 36e81a23
...@@ -79,7 +79,6 @@ IF(WITH_INNOBASE_STORAGE_ENGINE OR WITH_XTRADB_STORAGE_ENGINE) ...@@ -79,7 +79,6 @@ IF(WITH_INNOBASE_STORAGE_ENGINE OR WITH_XTRADB_STORAGE_ENGINE)
../storage/innobase/ut/ut0ut.cc ../storage/innobase/ut/ut0ut.cc
../storage/innobase/buf/buf0buf.cc ../storage/innobase/buf/buf0buf.cc
../storage/innobase/page/page0zip.cc ../storage/innobase/page/page0zip.cc
../storage/innobase/os/os0file.cc
../storage/innobase/fil/fil0crypt.cc ../storage/innobase/fil/fil0crypt.cc
) )
......
This diff is collapsed.
SET GLOBAL innodb_file_format = `Barracuda`;
SET GLOBAL innodb_file_per_table = ON;
set global innodb_compression_algorithm = 1; set global innodb_compression_algorithm = 1;
# Create and populate a tables # Create and populate a tables
CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT) ENGINE=InnoDB ENCRYPTED=YES ENCRYPTION_KEY_ID=4; CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT) ENGINE=InnoDB ENCRYPTED=YES ENCRYPTION_KEY_ID=4;
...@@ -5,6 +7,7 @@ CREATE TABLE t2 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT) ENGINE=InnoDB ROW_FOR ...@@ -5,6 +7,7 @@ CREATE TABLE t2 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT) ENGINE=InnoDB ROW_FOR
CREATE TABLE t3 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT) ENGINE=InnoDB ROW_FORMAT=COMPRESSED ENCRYPTED=NO; CREATE TABLE t3 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT) ENGINE=InnoDB ROW_FORMAT=COMPRESSED ENCRYPTED=NO;
CREATE TABLE t4 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT) ENGINE=InnoDB PAGE_COMPRESSED=1; CREATE TABLE t4 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT) ENGINE=InnoDB PAGE_COMPRESSED=1;
CREATE TABLE t5 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT) ENGINE=InnoDB PAGE_COMPRESSED=1 ENCRYPTED=YES ENCRYPTION_KEY_ID=4; CREATE TABLE t5 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT) ENGINE=InnoDB PAGE_COMPRESSED=1 ENCRYPTED=YES ENCRYPTION_KEY_ID=4;
CREATE TABLE t6 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT) ENGINE=InnoDB;
# Write file to make mysql-test-run.pl expect the "crash", but don't # Write file to make mysql-test-run.pl expect the "crash", but don't
# start it until it's told to # start it until it's told to
# We give 30 seconds to do a clean shutdown because we do not want # We give 30 seconds to do a clean shutdown because we do not want
...@@ -16,6 +19,27 @@ CREATE TABLE t5 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT) ENGINE=InnoDB PAGE_CO ...@@ -16,6 +19,27 @@ CREATE TABLE t5 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT) ENGINE=InnoDB PAGE_CO
# Run innochecksum on t3 # Run innochecksum on t3
# Run innochecksum on t4 # Run innochecksum on t4
# Run innochecksum on t4 # Run innochecksum on t4
# Run innochecksum on t5
# Run innochecksum on t6
# Backup tables before corrupting
# Corrupt FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION
# Run innochecksum on t2
# Run innochecksum on t3
# no encryption corrupting the field should not have effect
# Run innochecksum on t6
# no encryption corrupting the field should not have effect
# Restore the original tables
# Corrupt FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION+4 (post encryption checksum)
# Run innochecksum on t2
# Run innochecksum on t3
# Run innochecksum on t6
# no encryption corrupting the field should not have effect
# Restore the original tables
# Corrupt FIL_DATA+10 (data)
# Run innochecksum on t2
# Run innochecksum on t3
# Run innochecksum on t6
# Restore the original tables
# Write file to make mysql-test-run.pl start up the server again # Write file to make mysql-test-run.pl start up the server again
# Cleanup # Cleanup
DROP TABLE t1, t2, t3, t4, t5; DROP TABLE t1, t2, t3, t4, t5, t6;
...@@ -2,21 +2,25 @@ ...@@ -2,21 +2,25 @@
# MDEV-8773: InnoDB innochecksum does not work with encrypted or page compressed tables # MDEV-8773: InnoDB innochecksum does not work with encrypted or page compressed tables
# #
# Don't test under embedded --source include/innodb_page_size_small.inc
# Don't test under embedded as we restart server
-- source include/not_embedded.inc -- source include/not_embedded.inc
# Require InnoDB # Require InnoDB
-- source include/have_innodb.inc -- source include/have_innodb.inc
-- source include/have_file_key_management_plugin.inc -- source include/have_file_key_management_plugin.inc
-- source include/innodb_page_size_small.inc
if (!$INNOCHECKSUM) { if (!$INNOCHECKSUM) {
--echo Need innochecksum binary --echo Need innochecksum binary
--die Need innochecksum binary --die Need innochecksum binary
} }
let $innodb_compression_algorithm_orig=`SELECT @@innodb_compression_algorithm`; --disable_warnings
SET GLOBAL innodb_file_format = `Barracuda`;
SET GLOBAL innodb_file_per_table = ON;
# zlib # zlib
set global innodb_compression_algorithm = 1; set global innodb_compression_algorithm = 1;
--enable_warnings
--echo # Create and populate a tables --echo # Create and populate a tables
CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT) ENGINE=InnoDB ENCRYPTED=YES ENCRYPTION_KEY_ID=4; CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT) ENGINE=InnoDB ENCRYPTED=YES ENCRYPTION_KEY_ID=4;
...@@ -24,9 +28,11 @@ CREATE TABLE t2 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT) ENGINE=InnoDB ROW_FOR ...@@ -24,9 +28,11 @@ CREATE TABLE t2 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT) ENGINE=InnoDB ROW_FOR
CREATE TABLE t3 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT) ENGINE=InnoDB ROW_FORMAT=COMPRESSED ENCRYPTED=NO; CREATE TABLE t3 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT) ENGINE=InnoDB ROW_FORMAT=COMPRESSED ENCRYPTED=NO;
CREATE TABLE t4 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT) ENGINE=InnoDB PAGE_COMPRESSED=1; CREATE TABLE t4 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT) ENGINE=InnoDB PAGE_COMPRESSED=1;
CREATE TABLE t5 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT) ENGINE=InnoDB PAGE_COMPRESSED=1 ENCRYPTED=YES ENCRYPTION_KEY_ID=4; CREATE TABLE t5 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT) ENGINE=InnoDB PAGE_COMPRESSED=1 ENCRYPTED=YES ENCRYPTION_KEY_ID=4;
CREATE TABLE t6 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT) ENGINE=InnoDB;
--disable_query_log --disable_query_log
--let $i = 1000 --let $i = 1000
begin;
while ($i) while ($i)
{ {
INSERT INTO t1 (b) VALUES (REPEAT('abcdefghijklmnopqrstuvwxyz', 100)); INSERT INTO t1 (b) VALUES (REPEAT('abcdefghijklmnopqrstuvwxyz', 100));
...@@ -36,6 +42,8 @@ INSERT INTO t2 SELECT * FROM t1; ...@@ -36,6 +42,8 @@ INSERT INTO t2 SELECT * FROM t1;
INSERT INTO t3 SELECT * FROM t1; INSERT INTO t3 SELECT * FROM t1;
INSERT INTO t4 SELECT * FROM t1; INSERT INTO t4 SELECT * FROM t1;
INSERT INTO t5 SELECT * FROM t1; INSERT INTO t5 SELECT * FROM t1;
INSERT INTO t6 SELECT * FROM t1;
commit;
--enable_query_log --enable_query_log
let $MYSQLD_DATADIR=`select @@datadir`; let $MYSQLD_DATADIR=`select @@datadir`;
...@@ -44,6 +52,10 @@ let t2_IBD = $MYSQLD_DATADIR/test/t2.ibd; ...@@ -44,6 +52,10 @@ let t2_IBD = $MYSQLD_DATADIR/test/t2.ibd;
let t3_IBD = $MYSQLD_DATADIR/test/t3.ibd; let t3_IBD = $MYSQLD_DATADIR/test/t3.ibd;
let t4_IBD = $MYSQLD_DATADIR/test/t4.ibd; let t4_IBD = $MYSQLD_DATADIR/test/t4.ibd;
let t5_IBD = $MYSQLD_DATADIR/test/t5.ibd; let t5_IBD = $MYSQLD_DATADIR/test/t5.ibd;
let t6_IBD = $MYSQLD_DATADIR/test/t6.ibd;
let INNODB_PAGE_SIZE=`select @@innodb_page_size`;
let MYSQLD_DATADIR=`select @@datadir`;
--echo # Write file to make mysql-test-run.pl expect the "crash", but don't --echo # Write file to make mysql-test-run.pl expect the "crash", but don't
--echo # start it until it's told to --echo # start it until it's told to
...@@ -77,17 +89,198 @@ shutdown_server 30; ...@@ -77,17 +89,198 @@ shutdown_server 30;
--exec $INNOCHECKSUM $t4_IBD --exec $INNOCHECKSUM $t4_IBD
--echo # Run innochecksum on t5
--exec $INNOCHECKSUM $t5_IBD
--echo # Run innochecksum on t6
--exec $INNOCHECKSUM $t6_IBD
--enable_result_log
--echo # Backup tables before corrupting
--copy_file $MYSQLD_DATADIR/test/t1.ibd $MYSQLD_DATADIR/test/t1.ibd.backup
--copy_file $MYSQLD_DATADIR/test/t2.ibd $MYSQLD_DATADIR/test/t2.ibd.backup
--copy_file $MYSQLD_DATADIR/test/t3.ibd $MYSQLD_DATADIR/test/t3.ibd.backup
--copy_file $MYSQLD_DATADIR/test/t4.ibd $MYSQLD_DATADIR/test/t4.ibd.backup
--copy_file $MYSQLD_DATADIR/test/t5.ibd $MYSQLD_DATADIR/test/t5.ibd.backup
--copy_file $MYSQLD_DATADIR/test/t6.ibd $MYSQLD_DATADIR/test/t6.ibd.backup
#
# MDEV-11939: innochecksum mistakes a file for an encrypted one
#
--echo # Corrupt FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION
perl;
open(FILE, "+<", "$ENV{MYSQLD_DATADIR}/test/t1.ibd") or die "open";
binmode FILE;
seek(FILE, $ENV{'INNODB_PAGE_SIZE'} * 3 + 26, SEEK_SET) or die "seek";
print FILE pack("H*", "c00lcafedeadb017");
close FILE or die "close";
open(FILE, "+<", "$ENV{MYSQLD_DATADIR}/test/t2.ibd") or die "open";
binmode FILE;
seek(FILE, $ENV{'INNODB_PAGE_SIZE'} * 3 + 26, SEEK_SET) or die "seek";
print FILE pack("H*", "c00lcafedeadb017");
close FILE or die "close";
open(FILE, "+<", "$ENV{MYSQLD_DATADIR}/test/t3.ibd") or die "open";
binmode FILE;
seek(FILE, $ENV{'INNODB_PAGE_SIZE'} * 3 + 26, SEEK_SET) or die "seek";
print FILE pack("H*", "c00lcafedeadb017");
close FILE or die "close";
open(FILE, "+<", "$ENV{MYSQLD_DATADIR}/test/t6.ibd") or die "open";
binmode FILE;
seek(FILE, $ENV{'INNODB_PAGE_SIZE'} * 3 + 26, SEEK_SET) or die "seek";
print FILE pack("H*", "c00lcafedeadb017");
close FILE or die "close";
EOF
-- disable_result_log
--error 1
--exec $INNOCHECKSUM $t1_IBD
--echo # Run innochecksum on t2
--error 1
--exec $INNOCHECKSUM $t2_IBD
--echo # Run innochecksum on t3
--echo # no encryption corrupting the field should not have effect
--exec $INNOCHECKSUM $t3_IBD
--echo # Run innochecksum on t6
--echo # no encryption corrupting the field should not have effect
--exec $INNOCHECKSUM $t6_IBD
--enable_result_log --enable_result_log
--echo # Restore the original tables
--remove_file $MYSQLD_DATADIR/test/t1.ibd
--remove_file $MYSQLD_DATADIR/test/t2.ibd
--remove_file $MYSQLD_DATADIR/test/t3.ibd
--remove_file $MYSQLD_DATADIR/test/t4.ibd
--remove_file $MYSQLD_DATADIR/test/t5.ibd
--remove_file $MYSQLD_DATADIR/test/t6.ibd
--copy_file $MYSQLD_DATADIR/test/t1.ibd.backup $MYSQLD_DATADIR/test/t1.ibd
--copy_file $MYSQLD_DATADIR/test/t2.ibd.backup $MYSQLD_DATADIR/test/t2.ibd
--copy_file $MYSQLD_DATADIR/test/t3.ibd.backup $MYSQLD_DATADIR/test/t3.ibd
--copy_file $MYSQLD_DATADIR/test/t4.ibd.backup $MYSQLD_DATADIR/test/t4.ibd
--copy_file $MYSQLD_DATADIR/test/t5.ibd.backup $MYSQLD_DATADIR/test/t5.ibd
--copy_file $MYSQLD_DATADIR/test/t6.ibd.backup $MYSQLD_DATADIR/test/t6.ibd
--echo # Corrupt FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION+4 (post encryption checksum)
perl;
open(FILE, "+<", "$ENV{MYSQLD_DATADIR}/test/t1.ibd") or die "open";
binmode FILE;
seek(FILE, $ENV{'INNODB_PAGE_SIZE'} * 3 + 30, SEEK_SET) or die "seek";
print FILE pack("H*", "c00lcafedeadb017");
close FILE or die "close";
open(FILE, "+<", "$ENV{MYSQLD_DATADIR}/test/t2.ibd") or die "open";
binmode FILE;
seek(FILE, $ENV{'INNODB_PAGE_SIZE'} * 3 + 30, SEEK_SET) or die "seek";
print FILE pack("H*", "c00lcafedeadb017");
close FILE or die "close";
open(FILE, "+<", "$ENV{MYSQLD_DATADIR}/test/t3.ibd") or die "open";
binmode FILE;
seek(FILE, $ENV{'INNODB_PAGE_SIZE'} * 3 + 30, SEEK_SET) or die "seek";
print FILE pack("H*", "c00lcafedeadb017");
close FILE or die "close";
open(FILE, "+<", "$ENV{MYSQLD_DATADIR}/test/t6.ibd") or die "open";
binmode FILE;
seek(FILE, $ENV{'INNODB_PAGE_SIZE'} * 3 + 30, SEEK_SET) or die "seek";
print FILE pack("H*", "c00lcafedeadb017");
close FILE or die "close";
EOF
-- disable_result_log
--error 1
--exec $INNOCHECKSUM $t1_IBD
--echo # Run innochecksum on t2
--error 1
--exec $INNOCHECKSUM $t2_IBD
--echo # Run innochecksum on t3
--error 1
--exec $INNOCHECKSUM $t3_IBD
--echo # Run innochecksum on t6
--echo # no encryption corrupting the field should not have effect
--exec $INNOCHECKSUM $t6_IBD
--enable_result_log
--echo # Restore the original tables
--remove_file $MYSQLD_DATADIR/test/t1.ibd
--remove_file $MYSQLD_DATADIR/test/t2.ibd
--remove_file $MYSQLD_DATADIR/test/t3.ibd
--remove_file $MYSQLD_DATADIR/test/t4.ibd
--remove_file $MYSQLD_DATADIR/test/t5.ibd
--remove_file $MYSQLD_DATADIR/test/t6.ibd
--copy_file $MYSQLD_DATADIR/test/t1.ibd.backup $MYSQLD_DATADIR/test/t1.ibd
--copy_file $MYSQLD_DATADIR/test/t2.ibd.backup $MYSQLD_DATADIR/test/t2.ibd
--copy_file $MYSQLD_DATADIR/test/t3.ibd.backup $MYSQLD_DATADIR/test/t3.ibd
--copy_file $MYSQLD_DATADIR/test/t4.ibd.backup $MYSQLD_DATADIR/test/t4.ibd
--copy_file $MYSQLD_DATADIR/test/t5.ibd.backup $MYSQLD_DATADIR/test/t5.ibd
--copy_file $MYSQLD_DATADIR/test/t6.ibd.backup $MYSQLD_DATADIR/test/t6.ibd
--echo # Corrupt FIL_DATA+10 (data)
perl;
open(FILE, "+<", "$ENV{MYSQLD_DATADIR}/test/t1.ibd") or die "open";
binmode FILE;
seek(FILE, $ENV{'INNODB_PAGE_SIZE'} * 3 + 48, SEEK_SET) or die "seek";
print FILE pack("H*", "c00lcafedeadb017");
close FILE or die "close";
open(FILE, "+<", "$ENV{MYSQLD_DATADIR}/test/t2.ibd") or die "open";
binmode FILE;
seek(FILE, $ENV{'INNODB_PAGE_SIZE'} * 3 + 48, SEEK_SET) or die "seek";
print FILE pack("H*", "c00lcafedeadb017");
close FILE or die "close";
open(FILE, "+<", "$ENV{MYSQLD_DATADIR}/test/t3.ibd") or die "open";
binmode FILE;
seek(FILE, $ENV{'INNODB_PAGE_SIZE'} * 3 + 48, SEEK_SET) or die "seek";
print FILE pack("H*", "c00lcafedeadb017");
close FILE or die "close";
open(FILE, "+<", "$ENV{MYSQLD_DATADIR}/test/t6.ibd") or die "open";
binmode FILE;
seek(FILE, $ENV{'INNODB_PAGE_SIZE'} * 3 + 48, SEEK_SET) or die "seek";
print FILE pack("H*", "c00lcafedeadb017");
close FILE or die "close";
EOF
-- disable_result_log
--error 1
--exec $INNOCHECKSUM $t1_IBD
--echo # Run innochecksum on t2
--error 1
--exec $INNOCHECKSUM $t2_IBD
--echo # Run innochecksum on t3
--error 1
--exec $INNOCHECKSUM $t3_IBD
--echo # Run innochecksum on t6
--error 1
--exec $INNOCHECKSUM $t6_IBD
--enable_result_log
--echo # Restore the original tables
--move_file $MYSQLD_DATADIR/test/t1.ibd.backup $MYSQLD_DATADIR/test/t1.ibd
--move_file $MYSQLD_DATADIR/test/t2.ibd.backup $MYSQLD_DATADIR/test/t2.ibd
--move_file $MYSQLD_DATADIR/test/t3.ibd.backup $MYSQLD_DATADIR/test/t3.ibd
--move_file $MYSQLD_DATADIR/test/t4.ibd.backup $MYSQLD_DATADIR/test/t4.ibd
--move_file $MYSQLD_DATADIR/test/t5.ibd.backup $MYSQLD_DATADIR/test/t5.ibd
--move_file $MYSQLD_DATADIR/test/t6.ibd.backup $MYSQLD_DATADIR/test/t6.ibd
--echo # Write file to make mysql-test-run.pl start up the server again --echo # Write file to make mysql-test-run.pl start up the server again
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--enable_reconnect --enable_reconnect
--source include/wait_until_connected_again.inc --source include/wait_until_connected_again.inc
--echo # Cleanup --echo # Cleanup
DROP TABLE t1, t2, t3, t4, t5; DROP TABLE t1, t2, t3, t4, t5, t6;
# reset system
--disable_query_log
EVAL SET GLOBAL innodb_compression_algorithm = $innodb_compression_algorithm_orig;
--enable_query_log
...@@ -31,6 +31,7 @@ allow-mismatches 0 ...@@ -31,6 +31,7 @@ allow-mismatches 0
write crc32 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
log (No default value) log (No default value)
leaf FALSE leaf FALSE
merge 0 merge 0
...@@ -41,7 +42,7 @@ innochecksum Ver #.#.# ...@@ -41,7 +42,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>] [-v] [-a <allow mismatches>] [-n] [-C <strict-check>] [-w <write>] [-S] [-D <page type dump>] [-l <log>] [-e] <filename or [-]> 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 [-]>
-?, --help Displays this help and exits. -?, --help Displays this help and exits.
-I, --info Synonym for --help. -I, --info Synonym for --help.
-V, --version Displays version information and exits. -V, --version Displays version information and exits.
...@@ -62,8 +63,10 @@ Usage: innochecksum [-c] [-s <start page>] [-e <end page>] [-p <page>] [-v] [-a ...@@ -62,8 +63,10 @@ Usage: innochecksum [-c] [-s <start page>] [-e <end page>] [-p <page>] [-v] [-a
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
Dump the page type info for each page in a tablespace. Dump the page type info for each page in a tablespace.
-i, --per-page-details
Print out per-page detail information.
-l, --log=name log output. -l, --log=name log output.
-e, --leaf Examine leaf index pages -f, --leaf Examine leaf index pages
-m, --merge=# leaf page count if merge given number of consecutive -m, --merge=# leaf page count if merge given number of consecutive
pages pages
...@@ -81,6 +84,7 @@ allow-mismatches 0 ...@@ -81,6 +84,7 @@ allow-mismatches 0
write crc32 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
log (No default value) log (No default value)
leaf FALSE leaf FALSE
merge 0 merge 0
......
# 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.*");
[1]: Further Test are for rewrite checksum (innodb|crc32|none) for all ibd file & start the server. [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,
...@@ -105,6 +106,7 @@ File::tab#.ibd ...@@ -105,6 +106,7 @@ File::tab#.ibd
# Page compressed page # Page compressed page
# Page compressed encrypted page # Page compressed encrypted page
# Other type of page # Other type of page
=============================================== ===============================================
Additional information: Additional information:
Undo page type: # insert, # update, # other Undo page type: # insert, # update, # other
...@@ -139,6 +141,7 @@ File::tab#.ibd ...@@ -139,6 +141,7 @@ File::tab#.ibd
# Page compressed page # Page compressed page
# Page compressed encrypted page # Page compressed encrypted page
# Other type of page # Other type of page
=============================================== ===============================================
Additional information: Additional information:
Undo page type: # insert, # update, # other Undo page type: # insert, # update, # other
...@@ -160,14 +163,14 @@ Filename::tab#.ibd ...@@ -160,14 +163,14 @@ Filename::tab#.ibd
============================================================================== ==============================================================================
PAGE_NO | PAGE_TYPE | EXTRA INFO PAGE_NO | PAGE_TYPE | EXTRA INFO
============================================================================== ==============================================================================
#:: # | File Space Header | - #::# | File Space Header | -
#:: # | Insert Buffer Bitmap | - #::# | Insert Buffer Bitmap | -
#:: # | Inode page | - #::# | Inode page | -
#:: # | Index page | index id=#, page level=# leaf #, No. of records=#, garbage=#, n_recs=#, - #::# | Index page | index id=#, page level=#, No. of records=#, garbage=#, -
#:: # | Index page | index id=#, page level=# leaf #, No. of records=#, garbage=#, n_recs=#, - #::# | Index page | index id=#, page level=#, No. of records=#, garbage=#, -
#:: # | Index page | index id=#, page level=# leaf #, No. of records=#, garbage=#, n_recs=#, - #::# | Index page | index id=#, page level=#, No. of records=#, garbage=#, -
#:: # | Index page | index id=#, page level=# leaf #, No. of records=#, garbage=#, n_recs=#, - #::# | Index page | index id=#, page level=#, No. of records=#, garbage=#, -
#:: # | Freshly allocated page | - #::# | Freshly allocated page | -
# Variables used by page type dump for ibdata1 # Variables used by page type dump for ibdata1
Variables (--variable-name=value) Variables (--variable-name=value)
...@@ -184,6 +187,7 @@ allow-mismatches 0 ...@@ -184,6 +187,7 @@ allow-mismatches 0
write crc32 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
log (No default value) log (No default value)
leaf FALSE leaf FALSE
merge 0 merge 0
...@@ -194,14 +198,14 @@ Filename::tab#.ibd ...@@ -194,14 +198,14 @@ Filename::tab#.ibd
============================================================================== ==============================================================================
PAGE_NO | PAGE_TYPE | EXTRA INFO PAGE_NO | PAGE_TYPE | EXTRA INFO
============================================================================== ==============================================================================
#:: # | File Space Header | - #::# | File Space Header | -
#:: # | Insert Buffer Bitmap | - #::# | Insert Buffer Bitmap | -
#:: # | Inode page | - #::# | Inode page | -
#:: # | Index page | index id=#, page level=# leaf #, No. of records=#, garbage=#, n_recs=#, - #::# | Index page | index id=#, page level=#, No. of records=#, garbage=#, -
#:: # | Index page | index id=#, page level=# leaf #, No. of records=#, garbage=#, n_recs=#, - #::# | Index page | index id=#, page level=#, No. of records=#, garbage=#, -
#:: # | Index page | index id=#, page level=# leaf #, No. of records=#, garbage=#, n_recs=#, - #::# | Index page | index id=#, page level=#, No. of records=#, garbage=#, -
#:: # | Index page | index id=#, page level=# leaf #, No. of records=#, garbage=#, n_recs=#, - #::# | Index page | index id=#, page level=#, No. of records=#, garbage=#, -
#:: # | Freshly allocated page | - #::# | Freshly allocated page | -
[6]: check the valid lower bound values for option [6]: check the valid lower bound values for option
# allow-mismatches,page,start-page,end-page # allow-mismatches,page,start-page,end-page
[9]: check the both short and long options "page" and "start-page" when [9]: check the both short and long options "page" and "start-page" when
......
...@@ -15,7 +15,9 @@ ...@@ -15,7 +15,9 @@
let MYSQLD_BASEDIR= `SELECT @@basedir`; let MYSQLD_BASEDIR= `SELECT @@basedir`;
let MYSQLD_DATADIR= `SELECT @@datadir`; let MYSQLD_DATADIR= `SELECT @@datadir`;
let SEARCH_FILE= $MYSQLTEST_VARDIR/log/my_restart.err; let 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.*");
--echo [1]: Further Test are for rewrite checksum (innodb|crc32|none) for all ibd file & start the server. --echo [1]: Further Test are for rewrite checksum (innodb|crc32|none) for all ibd file & start the server.
......
...@@ -31,16 +31,17 @@ The database buffer buf_pool ...@@ -31,16 +31,17 @@ The database buffer buf_pool
Created 11/5/1995 Heikki Tuuri Created 11/5/1995 Heikki Tuuri
*******************************************************/ *******************************************************/
#include "ha_prototypes.h" #include "univ.i"
#include "mtr0types.h"
#include "mach0data.h"
#include "page0size.h" #include "page0size.h"
#include "buf0buf.h" #include "buf0buf.h"
#include "os0api.h" #include <string.h>
#ifdef UNIV_NONINL
#include "buf0buf.ic"
#endif
#ifdef UNIV_INNOCHECKSUM
#include "string.h"
#include "mach0data.h"
#endif /* UNIV_INNOCHECKSUM */
#ifndef UNIV_INNOCHECKSUM #ifndef UNIV_INNOCHECKSUM
#include "mem0mem.h" #include "mem0mem.h"
#include "btr0btr.h" #include "btr0btr.h"
...@@ -64,7 +65,6 @@ Created 11/5/1995 Heikki Tuuri ...@@ -64,7 +65,6 @@ Created 11/5/1995 Heikki Tuuri
#include "fsp0sysspace.h" #include "fsp0sysspace.h"
#endif /* !UNIV_INNOCHECKSUM */ #endif /* !UNIV_INNOCHECKSUM */
#include "page0zip.h" #include "page0zip.h"
#include "buf0checksum.h"
#include "sync0sync.h" #include "sync0sync.h"
#include "buf0dump.h" #include "buf0dump.h"
#include "ut0new.h" #include "ut0new.h"
...@@ -645,10 +645,10 @@ buf_page_is_checksum_valid_crc32( ...@@ -645,10 +645,10 @@ buf_page_is_checksum_valid_crc32(
#ifdef UNIV_INNOCHECKSUM #ifdef UNIV_INNOCHECKSUM
if (log_file if (log_file
&& srv_checksum_algorithm == SRV_CHECKSUM_ALGORITHM_STRICT_CRC32) { && srv_checksum_algorithm == SRV_CHECKSUM_ALGORITHM_STRICT_CRC32) {
fprintf(log_file, "page::%lu;" fprintf(log_file, "page::%llu;"
" crc32 calculated = %u;" " crc32 calculated = %u;"
" recorded checksum field1 = %lu recorded" " recorded checksum field1 = " ULINTPF " recorded"
" checksum field2 =%lu\n", cur_page_num, " checksum field2 =" ULINTPF "\n", cur_page_num,
crc32, checksum_field1, checksum_field2); crc32, checksum_field1, checksum_field2);
} }
#endif /* UNIV_INNOCHECKSUM */ #endif /* UNIV_INNOCHECKSUM */
...@@ -702,33 +702,34 @@ buf_page_is_checksum_valid_innodb( ...@@ -702,33 +702,34 @@ buf_page_is_checksum_valid_innodb(
#ifdef UNIV_INNOCHECKSUM #ifdef UNIV_INNOCHECKSUM
if (log_file if (log_file
&& srv_checksum_algorithm == SRV_CHECKSUM_ALGORITHM_INNODB) { && srv_checksum_algorithm == SRV_CHECKSUM_ALGORITHM_INNODB) {
fprintf(log_file, "page::%lu;" fprintf(log_file, "page::%llu;"
" old style: calculated =" " old style: calculated ="
" %lu; recorded = %lu\n", " " ULINTPF "; recorded = " ULINTPF "\n",
cur_page_num, old_checksum, cur_page_num, old_checksum,
checksum_field2); checksum_field2);
fprintf(log_file, "page::%lu;" fprintf(log_file, "page::%llu;"
" new style: calculated =" " new style: calculated ="
" %lu; crc32 = %u; recorded = %lu\n", " " ULINTPF "; crc32 = %u; recorded = " ULINTPF "\n",
cur_page_num, new_checksum, cur_page_num, new_checksum,
buf_calc_page_crc32(read_buf), checksum_field1); buf_calc_page_crc32(read_buf), checksum_field1);
} }
if (log_file if (log_file
&& srv_checksum_algorithm == SRV_CHECKSUM_ALGORITHM_STRICT_INNODB) { && srv_checksum_algorithm == SRV_CHECKSUM_ALGORITHM_STRICT_INNODB) {
fprintf(log_file, "page::%lu;" fprintf(log_file, "page::%llu;"
" old style: calculated =" " old style: calculated ="
" %lu; recorded checksum = %lu\n", " " ULINTPF "; recorded checksum = " ULINTPF "\n",
cur_page_num, old_checksum, cur_page_num, old_checksum,
checksum_field2); checksum_field2);
fprintf(log_file, "page::%lu;" fprintf(log_file, "page::%llu;"
" new style: calculated =" " new style: calculated ="
" %lu; recorded checksum = %lu\n", " " ULINTPF "; recorded checksum = " ULINTPF "\n",
cur_page_num, new_checksum, cur_page_num, new_checksum,
checksum_field1); checksum_field1);
} }
#endif /* UNIV_INNOCHECKSUM */ #endif /* UNIV_INNOCHECKSUM */
if (checksum_field2 != mach_read_from_4(read_buf + FIL_PAGE_LSN) if (checksum_field2 != mach_read_from_4(read_buf + FIL_PAGE_LSN)
&& checksum_field2 != old_checksum) { && checksum_field2 != old_checksum) {
DBUG_LOG("checksum", DBUG_LOG("checksum",
...@@ -788,9 +789,9 @@ buf_page_is_checksum_valid_none( ...@@ -788,9 +789,9 @@ buf_page_is_checksum_valid_none(
if (log_file if (log_file
&& srv_checksum_algorithm == SRV_CHECKSUM_ALGORITHM_STRICT_NONE) { && srv_checksum_algorithm == SRV_CHECKSUM_ALGORITHM_STRICT_NONE) {
fprintf(log_file, fprintf(log_file,
"page::%lu; none checksum: calculated" "page::%llu; none checksum: calculated"
" = %lu; recorded checksum_field1 = %lu" " = " ULINTPF "; recorded checksum_field1 = " ULINTPF
" recorded checksum_field2 = %lu\n", " recorded checksum_field2 = " ULINTPF "\n",
cur_page_num, BUF_NO_CHECKSUM_MAGIC, cur_page_num, BUF_NO_CHECKSUM_MAGIC,
checksum_field1, checksum_field2); checksum_field1, checksum_field2);
} }
...@@ -811,16 +812,18 @@ buf_page_is_corrupted( ...@@ -811,16 +812,18 @@ buf_page_is_corrupted(
bool check_lsn, bool check_lsn,
const byte* read_buf, const byte* read_buf,
const page_size_t& page_size, const page_size_t& page_size,
#ifndef UNIV_INNOCHECKSUM
const fil_space_t* space) const fil_space_t* space)
#else
const void* space)
#endif
{ {
ulint checksum_field1; size_t checksum_field1 = 0;
ulint checksum_field2; size_t checksum_field2 = 0;
#ifndef UNIV_INNOCHECKSUM #ifndef UNIV_INNOCHECKSUM
DBUG_EXECUTE_IF("buf_page_import_corrupt_failure", return(true); ); DBUG_EXECUTE_IF("buf_page_import_corrupt_failure", return(true); );
#endif
ulint page_type = mach_read_from_2( ulint page_type = mach_read_from_2(read_buf + FIL_PAGE_TYPE);
read_buf + FIL_PAGE_TYPE);
/* We can trust page type if page compression is set on tablespace /* We can trust page type if page compression is set on tablespace
flags because page compression flag means file must have been flags because page compression flag means file must have been
...@@ -833,15 +836,12 @@ buf_page_is_corrupted( ...@@ -833,15 +836,12 @@ buf_page_is_corrupted(
decompressed at this stage). */ decompressed at this stage). */
if ((page_type == FIL_PAGE_PAGE_COMPRESSED || if ((page_type == FIL_PAGE_PAGE_COMPRESSED ||
page_type == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED) page_type == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED)
&& space && FSP_FLAGS_HAS_PAGE_COMPRESSION(space->flags)) { #ifndef UNIV_INNOCHECKSUM
return(false); && space && FSP_FLAGS_HAS_PAGE_COMPRESSION(space->flags)
} #endif
#else ) {
if (mach_read_from_4(read_buf+FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION) != 0
|| mach_read_from_2(read_buf+FIL_PAGE_TYPE) == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED) {
return(false); return(false);
} }
#endif
if (!page_size.is_compressed() if (!page_size.is_compressed()
&& memcmp(read_buf + FIL_PAGE_LSN + 4, && memcmp(read_buf + FIL_PAGE_LSN + 4,
...@@ -850,14 +850,13 @@ buf_page_is_corrupted( ...@@ -850,14 +850,13 @@ buf_page_is_corrupted(
/* Stored log sequence numbers at the start and the end /* Stored log sequence numbers at the start and the end
of page do not match */ of page do not match */
#ifndef UNIV_INNOCHECKSUM #ifndef UNIV_INNOCHECKSUM
ib::info() << "Log sequence number at the start " ib::info() << "Log sequence number at the start "
<< mach_read_from_4(read_buf + FIL_PAGE_LSN + 4) << mach_read_from_4(read_buf + FIL_PAGE_LSN + 4)
<< " and the end " << " and the end "
<< mach_read_from_4(read_buf + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM + 4) << mach_read_from_4(read_buf + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM + 4)
<< " do not match"; << " do not match";
#endif #endif /* UNIV_INNOCHECKSUM */
return(true); return(true);
} }
...@@ -920,10 +919,9 @@ buf_page_is_corrupted( ...@@ -920,10 +919,9 @@ buf_page_is_corrupted(
&& *reinterpret_cast<const ib_uint64_t*>( && *reinterpret_cast<const ib_uint64_t*>(
read_buf + FIL_PAGE_LSN) == 0) { read_buf + FIL_PAGE_LSN) == 0) {
/* make sure that the page is really empty */ ulint i;
ulint i;
/* make sure that the page is really empty */
for (i = 0; i < page_size.logical(); ++i) { for (i = 0; i < page_size.logical(); ++i) {
/* The FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID has been /* The FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID has been
...@@ -944,7 +942,7 @@ buf_page_is_corrupted( ...@@ -944,7 +942,7 @@ buf_page_is_corrupted(
#ifdef UNIV_INNOCHECKSUM #ifdef UNIV_INNOCHECKSUM
if (i >= page_size.logical()) { if (i >= page_size.logical()) {
if (log_file) { if (log_file) {
fprintf(log_file, "Page::%lu" fprintf(log_file, "Page::%llu"
" is empty and uncorrupted\n", " is empty and uncorrupted\n",
cur_page_num); cur_page_num);
} }
...@@ -978,31 +976,34 @@ buf_page_is_corrupted( ...@@ -978,31 +976,34 @@ buf_page_is_corrupted(
if (buf_page_is_checksum_valid_none(read_buf, if (buf_page_is_checksum_valid_none(read_buf,
checksum_field1, checksum_field2)) { checksum_field1, checksum_field2)) {
#ifndef UNIV_INNOCHECKSUM
if (curr_algo if (curr_algo
== SRV_CHECKSUM_ALGORITHM_STRICT_CRC32) { == SRV_CHECKSUM_ALGORITHM_STRICT_CRC32) {
#ifndef UNIV_INNOCHECKSUM
page_warn_strict_checksum( page_warn_strict_checksum(
curr_algo, curr_algo,
SRV_CHECKSUM_ALGORITHM_NONE, SRV_CHECKSUM_ALGORITHM_NONE,
page_id); page_id);
#endif /* !UNIV_INNOCHECKSUM */
} }
#else /* !UNIV_INNOCHECKSUM */
#ifdef UNIV_INNOCHECKSUM
if (log_file) { if (log_file) {
fprintf(log_file, "page::%lu;" fprintf(log_file, "page::%llu;"
" old style: calculated = %u;" " old style: calculated = %u;"
" recorded = " ULINTPF "\n", " recorded = " ULINTPF ";\n",
cur_page_num, cur_page_num,
buf_calc_page_old_checksum(read_buf), buf_calc_page_old_checksum(read_buf),
checksum_field2); checksum_field2);
fprintf(log_file, "page::%lu;" fprintf(log_file, "page::%llu;"
" new style: calculated = %u;" " new style: calculated = %u;"
" crc32 = %u; recorded = " ULINTPF "\n", " crc32 = %u; recorded = " ULINTPF ";\n",
cur_page_num, cur_page_num,
buf_calc_page_new_checksum(read_buf), buf_calc_page_new_checksum(read_buf),
buf_calc_page_crc32(read_buf), buf_calc_page_crc32(read_buf),
checksum_field1); checksum_field1);
} }
#endif /* !UNIV_INNOCHECKSUM */ #endif /* UNIV_INNOCHECKSUM */
return(false); return(false);
} }
...@@ -1022,15 +1023,16 @@ buf_page_is_corrupted( ...@@ -1022,15 +1023,16 @@ buf_page_is_corrupted(
if (buf_page_is_checksum_valid_innodb(read_buf, if (buf_page_is_checksum_valid_innodb(read_buf,
checksum_field1, checksum_field2)) { checksum_field1, checksum_field2)) {
#ifndef UNIV_INNOCHECKSUM
if (curr_algo if (curr_algo
== SRV_CHECKSUM_ALGORITHM_STRICT_CRC32) { == SRV_CHECKSUM_ALGORITHM_STRICT_CRC32) {
#ifndef UNIV_INNOCHECKSUM
page_warn_strict_checksum( page_warn_strict_checksum(
curr_algo, curr_algo,
SRV_CHECKSUM_ALGORITHM_INNODB, SRV_CHECKSUM_ALGORITHM_INNODB,
page_id); page_id);
#endif
} }
#endif /* !UNIV_INNOCHECKSUM */
return(false); return(false);
} }
...@@ -1038,13 +1040,13 @@ buf_page_is_corrupted( ...@@ -1038,13 +1040,13 @@ buf_page_is_corrupted(
if (!legacy_checksum_checked && buf_page_is_checksum_valid_crc32( if (!legacy_checksum_checked && buf_page_is_checksum_valid_crc32(
read_buf, checksum_field1, checksum_field2, true)) { read_buf, checksum_field1, checksum_field2, true)) {
legacy_big_endian_checksum = true; legacy_big_endian_checksum = true;
return(false); return(false);
} }
#ifdef UNIV_INNOCHECKSUM #ifdef UNIV_INNOCHECKSUM
if (log_file) { if (log_file) {
fprintf(log_file, "Fail; page %lu" fprintf(log_file, "Fail; page::%llu;"
" invalid (fails crc32 checksum)\n", " invalid (fails crc32 checksum)\n",
cur_page_num); cur_page_num);
} }
...@@ -1061,30 +1063,32 @@ buf_page_is_corrupted( ...@@ -1061,30 +1063,32 @@ buf_page_is_corrupted(
if (buf_page_is_checksum_valid_none(read_buf, if (buf_page_is_checksum_valid_none(read_buf,
checksum_field1, checksum_field2)) { checksum_field1, checksum_field2)) {
#ifndef UNIV_INNOCHECKSUM
if (curr_algo if (curr_algo
== SRV_CHECKSUM_ALGORITHM_STRICT_INNODB) { == SRV_CHECKSUM_ALGORITHM_STRICT_INNODB) {
#ifndef UNIV_INNOCHECKSUM
page_warn_strict_checksum( page_warn_strict_checksum(
curr_algo, curr_algo,
SRV_CHECKSUM_ALGORITHM_NONE, SRV_CHECKSUM_ALGORITHM_NONE,
page_id); page_id);
#endif
} }
#else /* !UNIV_INNOCHECKSUM */ #ifdef UNIV_INNOCHECKSUM
if (log_file) { if (log_file) {
fprintf(log_file, "page::%lu;" fprintf(log_file, "page::%llu;"
" old style: calculated = %u;" " old style: calculated = %u;"
" recorded = %lu\n", cur_page_num, " recorded = %zu;\n", cur_page_num,
buf_calc_page_old_checksum(read_buf), buf_calc_page_old_checksum(read_buf),
checksum_field2); checksum_field2);
fprintf(log_file, "page::%lu;" fprintf(log_file, "page::%llu;"
" new style: calculated = %u;" " new style: calculated = %u;"
" crc32 = %u; recorded = %lu\n", " crc32 = %u; recorded = %zu;\n",
cur_page_num, cur_page_num,
buf_calc_page_new_checksum(read_buf), buf_calc_page_new_checksum(read_buf),
buf_calc_page_crc32(read_buf), buf_calc_page_crc32(read_buf),
checksum_field1); checksum_field1);
} }
#endif /* !UNIV_INNOCHECKSUM */ #endif /* UNIV_INNOCHECKSUM */
return(false); return(false);
} }
...@@ -1092,26 +1096,28 @@ buf_page_is_corrupted( ...@@ -1092,26 +1096,28 @@ buf_page_is_corrupted(
checksum_field1, checksum_field2, false) checksum_field1, checksum_field2, false)
|| buf_page_is_checksum_valid_crc32(read_buf, || buf_page_is_checksum_valid_crc32(read_buf,
checksum_field1, checksum_field2, true)) { checksum_field1, checksum_field2, true)) {
#ifndef UNIV_INNOCHECKSUM
if (curr_algo if (curr_algo
== SRV_CHECKSUM_ALGORITHM_STRICT_INNODB) { == SRV_CHECKSUM_ALGORITHM_STRICT_INNODB) {
#ifndef UNIV_INNOCHECKSUM
page_warn_strict_checksum( page_warn_strict_checksum(
curr_algo, curr_algo,
SRV_CHECKSUM_ALGORITHM_CRC32, SRV_CHECKSUM_ALGORITHM_CRC32,
page_id); page_id);
#endif
} }
#endif /* !UNIV_INNOCHECKSUM */
return(false); return(false);
} }
#ifdef UNIV_INNOCHECKSUM #ifdef UNIV_INNOCHECKSUM
if (log_file) { if (log_file) {
fprintf(log_file, "Fail; page %lu" fprintf(log_file, "Fail; page::%llu;"
" invalid (fails innodb checksum)\n", " invalid (fails innodb checksum)\n",
cur_page_num); cur_page_num);
} }
#endif /* UNIV_INNOCHECKSUM */ #endif /* UNIV_INNOCHECKSUM */
return(true); return(true);
case SRV_CHECKSUM_ALGORITHM_STRICT_NONE: case SRV_CHECKSUM_ALGORITHM_STRICT_NONE:
...@@ -1147,11 +1153,12 @@ buf_page_is_corrupted( ...@@ -1147,11 +1153,12 @@ buf_page_is_corrupted(
#ifdef UNIV_INNOCHECKSUM #ifdef UNIV_INNOCHECKSUM
if (log_file) { if (log_file) {
fprintf(log_file, "Fail; page %lu" fprintf(log_file, "Fail; page::%llu;"
" invalid (fails none checksum)\n", " invalid (fails none checksum)\n",
cur_page_num); cur_page_num);
} }
#endif /* UNIV_INNOCHECKSUM */ #endif /* UNIV_INNOCHECKSUM */
return(true); return(true);
case SRV_CHECKSUM_ALGORITHM_NONE: case SRV_CHECKSUM_ALGORITHM_NONE:
......
...@@ -24,6 +24,7 @@ Modified Jan Lindström jan.lindstrom@mariadb.com ...@@ -24,6 +24,7 @@ Modified Jan Lindström jan.lindstrom@mariadb.com
*******************************************************/ *******************************************************/
#include "fil0fil.h" #include "fil0fil.h"
#include "mtr0types.h"
#include "mach0data.h" #include "mach0data.h"
#include "page0size.h" #include "page0size.h"
#include "page0zip.h" #include "page0zip.h"
......
...@@ -211,6 +211,7 @@ struct buf_pools_list_size_t { ...@@ -211,6 +211,7 @@ struct buf_pools_list_size_t {
ulint unzip_LRU_bytes; /*!< unzip_LRU size in bytes */ ulint unzip_LRU_bytes; /*!< unzip_LRU size in bytes */
ulint flush_list_bytes; /*!< flush_list size in bytes */ ulint flush_list_bytes; /*!< flush_list size in bytes */
}; };
#endif /* !UNIV_INNOCHECKSUM */
/** Page identifier. */ /** Page identifier. */
class page_id_t { class page_id_t {
...@@ -333,6 +334,7 @@ operator<<( ...@@ -333,6 +334,7 @@ operator<<(
std::ostream& out, std::ostream& out,
const page_id_t& page_id); const page_id_t& page_id);
#ifndef UNIV_INNOCHECKSUM
/********************************************************************//** /********************************************************************//**
Acquire mutex on all buffer pool instances */ Acquire mutex on all buffer pool instances */
UNIV_INLINE UNIV_INLINE
...@@ -823,9 +825,16 @@ buf_page_is_corrupted( ...@@ -823,9 +825,16 @@ buf_page_is_corrupted(
bool check_lsn, bool check_lsn,
const byte* read_buf, const byte* read_buf,
const page_size_t& page_size, const page_size_t& page_size,
#ifndef UNIV_INNOCHECKSUM
const fil_space_t* space = NULL) const fil_space_t* space = NULL)
#else
const void* space = NULL)
#endif
MY_ATTRIBUTE((warn_unused_result)); MY_ATTRIBUTE((warn_unused_result));
#ifndef UNIV_INNOCHECKSUM #ifndef UNIV_INNOCHECKSUM
/**********************************************************************//** /**********************************************************************//**
Gets the space id, page offset, and byte offset within page of a Gets the space id, page offset, and byte offset within page of a
pointer pointing to a buffer frame containing a file page. */ pointer pointing to a buffer frame containing a file page. */
......
...@@ -30,6 +30,7 @@ Created 04/01/2015 Jan Lindström ...@@ -30,6 +30,7 @@ Created 04/01/2015 Jan Lindström
#include "os0event.h" #include "os0event.h"
#include "my_crypt.h" #include "my_crypt.h"
#endif /*! UNIV_INNOCHECKSUM */
/** /**
* Magic pattern in start of crypt data on page 0 * Magic pattern in start of crypt data on page 0
...@@ -101,6 +102,8 @@ struct fil_space_rotate_state_t ...@@ -101,6 +102,8 @@ struct fil_space_rotate_state_t
} scrubbing; } scrubbing;
}; };
#ifndef UNIV_INNOCHECKSUM
struct fil_space_crypt_t : st_encryption_scheme struct fil_space_crypt_t : st_encryption_scheme
{ {
public: public:
......
...@@ -28,8 +28,6 @@ Created 10/25/1995 Heikki Tuuri ...@@ -28,8 +28,6 @@ Created 10/25/1995 Heikki Tuuri
#define fil0fil_h #define fil0fil_h
#include "univ.i" #include "univ.i"
struct fil_space_t;
#ifndef UNIV_INNOCHECKSUM #ifndef UNIV_INNOCHECKSUM
#include "log0recv.h" #include "log0recv.h"
...@@ -281,22 +279,23 @@ but in the MySQL Embedded Server Library and mysqlbackup it is not the default ...@@ -281,22 +279,23 @@ but in the MySQL Embedded Server Library and mysqlbackup it is not the default
directory, and we must set the base file path explicitly */ directory, and we must set the base file path explicitly */
extern const char* fil_path_to_mysql_datadir; extern const char* fil_path_to_mysql_datadir;
/** Initial size of a single-table tablespace in pages */
#define FIL_IBD_FILE_INITIAL_SIZE 4
/** 'null' (undefined) page offset in the context of file spaces */
#define FIL_NULL ULINT32_UNDEFINED
/* Space address data type; this is intended to be used when /* Space address data type; this is intended to be used when
addresses accurate to a byte are stored in file pages. If the page part addresses accurate to a byte are stored in file pages. If the page part
of the address is FIL_NULL, the address is considered undefined. */ of the address is FIL_NULL, the address is considered undefined. */
typedef byte fil_faddr_t; /*!< 'type' definition in C: an address typedef byte fil_faddr_t; /*!< 'type' definition in C: an address
stored in a file page is a string of bytes */ stored in a file page is a string of bytes */
#endif /* !UNIV_INNOCHECKSUM */
/** Initial size of a single-table tablespace in pages */
#define FIL_IBD_FILE_INITIAL_SIZE 4
/** 'null' (undefined) page offset in the context of file spaces */
#define FIL_NULL ULINT32_UNDEFINED
#define FIL_ADDR_PAGE 0 /* first in address is the page offset */ #define FIL_ADDR_PAGE 0 /* first in address is the page offset */
#define FIL_ADDR_BYTE 4 /* then comes 2-byte byte offset within page*/ #define FIL_ADDR_BYTE 4 /* then comes 2-byte byte offset within page*/
#endif /* !UNIV_INNOCHECKSUM */
#define FIL_ADDR_SIZE 6 /* address size is 6 bytes */ #define FIL_ADDR_SIZE 6 /* address size is 6 bytes */
#ifndef UNIV_INNOCHECKSUM #ifndef UNIV_INNOCHECKSUM
...@@ -431,8 +430,6 @@ index */ ...@@ -431,8 +430,6 @@ index */
#define fil_page_index_page_check(page) \ #define fil_page_index_page_check(page) \
fil_page_type_is_index(fil_page_get_type(page)) fil_page_type_is_index(fil_page_get_type(page))
#ifndef UNIV_INNOCHECKSUM
/** Enum values for encryption table option */ /** Enum values for encryption table option */
enum fil_encryption_t { enum fil_encryption_t {
/** Encrypted if innodb_encrypt_tables=ON (srv_encrypt_tables) */ /** Encrypted if innodb_encrypt_tables=ON (srv_encrypt_tables) */
...@@ -454,6 +451,8 @@ extern ulint fil_n_pending_tablespace_flushes; ...@@ -454,6 +451,8 @@ extern ulint fil_n_pending_tablespace_flushes;
/** Number of files currently open */ /** Number of files currently open */
extern ulint fil_n_file_opened; extern ulint fil_n_file_opened;
#ifndef UNIV_INNOCHECKSUM
/** Look up a tablespace. /** Look up a tablespace.
The caller should hold an InnoDB table lock or a MDL that prevents The caller should hold an InnoDB table lock or a MDL that prevents
the tablespace from being dropped during the operation, the tablespace from being dropped during the operation,
...@@ -1315,6 +1314,7 @@ fil_page_reset_type( ...@@ -1315,6 +1314,7 @@ fil_page_reset_type(
byte* page, byte* page,
ulint type, ulint type,
mtr_t* mtr); mtr_t* mtr);
/** Get the file page type. /** Get the file page type.
@param[in] page file page @param[in] page file page
@return page type */ @return page type */
...@@ -1325,6 +1325,7 @@ fil_page_get_type( ...@@ -1325,6 +1325,7 @@ fil_page_get_type(
{ {
return(mach_read_from_2(page + FIL_PAGE_TYPE)); return(mach_read_from_2(page + FIL_PAGE_TYPE));
} }
/** Check (and if needed, reset) the page type. /** Check (and if needed, reset) the page type.
Data files created before MySQL 5.1 may contain Data files created before MySQL 5.1 may contain
garbage in the FIL_PAGE_TYPE field. garbage in the FIL_PAGE_TYPE field.
......
...@@ -158,8 +158,6 @@ descriptor page, but used only in the first. */ ...@@ -158,8 +158,6 @@ descriptor page, but used only in the first. */
FSP_FREE_LIMIT at a time */ FSP_FREE_LIMIT at a time */
/* @} */ /* @} */
#ifndef UNIV_INNOCHECKSUM
/* @defgroup File Segment Inode Constants (moved from fsp0fsp.c) @{ */ /* @defgroup File Segment Inode Constants (moved from fsp0fsp.c) @{ */
/* FILE SEGMENT INODE /* FILE SEGMENT INODE
...@@ -293,6 +291,7 @@ the extent are free and which contain old tuple version to clean. */ ...@@ -293,6 +291,7 @@ the extent are free and which contain old tuple version to clean. */
/** Offset of the descriptor array on a descriptor page */ /** Offset of the descriptor array on a descriptor page */
#define XDES_ARR_OFFSET (FSP_HEADER_OFFSET + FSP_HEADER_SIZE) #define XDES_ARR_OFFSET (FSP_HEADER_OFFSET + FSP_HEADER_SIZE)
#ifndef UNIV_INNOCHECKSUM
/* @} */ /* @} */
/**********************************************************************//** /**********************************************************************//**
......
...@@ -53,6 +53,7 @@ xdes_calc_descriptor_index( ...@@ -53,6 +53,7 @@ xdes_calc_descriptor_index(
return(ut_2pow_remainder(offset, page_size.physical()) return(ut_2pow_remainder(offset, page_size.physical())
/ FSP_EXTENT_SIZE); / FSP_EXTENT_SIZE);
} }
#endif /*!UNIV_INNOCHECKSUM */
/**********************************************************************//** /**********************************************************************//**
Gets a descriptor bit of a page. Gets a descriptor bit of a page.
...@@ -80,6 +81,7 @@ xdes_get_bit( ...@@ -80,6 +81,7 @@ xdes_get_bit(
bit_index)); bit_index));
} }
#ifndef UNIV_INNOCHECKSUM
/** Calculates the page where the descriptor of a page resides. /** Calculates the page where the descriptor of a page resides.
@param[in] page_size page size @param[in] page_size page size
@param[in] offset page offset @param[in] offset page offset
......
...@@ -63,6 +63,7 @@ mach_write_to_2( ...@@ -63,6 +63,7 @@ mach_write_to_2(
/*============*/ /*============*/
byte* b, /*!< in: pointer to two bytes where to store */ byte* b, /*!< in: pointer to two bytes where to store */
ulint n); /*!< in: ulint integer to be stored, >= 0, < 64k */ ulint n); /*!< in: ulint integer to be stored, >= 0, < 64k */
#endif /* !UNIV_INNOCHECKSUM */
/** The following function is used to fetch data from 2 consecutive /** The following function is used to fetch data from 2 consecutive
bytes. The most significant byte is at the lowest address. bytes. The most significant byte is at the lowest address.
@param[in] b pointer to 2 bytes where to store @param[in] b pointer to 2 bytes where to store
...@@ -72,6 +73,8 @@ uint16_t ...@@ -72,6 +73,8 @@ uint16_t
mach_read_from_2( mach_read_from_2(
const byte* b) const byte* b)
MY_ATTRIBUTE((warn_unused_result)); MY_ATTRIBUTE((warn_unused_result));
#ifndef UNIV_INNOCHECKSUM
/********************************************************//** /********************************************************//**
The following function is used to convert a 16-bit data item The following function is used to convert a 16-bit data item
to the canonical format, for fast bytewise equality test to the canonical format, for fast bytewise equality test
...@@ -362,6 +365,8 @@ mach_write_ulonglong( ...@@ -362,6 +365,8 @@ mach_write_ulonglong(
ulint len, /*!< in: length of dest */ ulint len, /*!< in: length of dest */
bool usign); /*!< in: signed or unsigned flag */ bool usign); /*!< in: signed or unsigned flag */
#endif /* !UNIV_INNOCHECKSUM */
/** Read 1 to 4 bytes from a file page buffered in the buffer pool. /** Read 1 to 4 bytes from a file page buffered in the buffer pool.
@param[in] ptr pointer where to read @param[in] ptr pointer where to read
@param[in] type MLOG_1BYTE, MLOG_2BYTES, or MLOG_4BYTES @param[in] type MLOG_1BYTE, MLOG_2BYTES, or MLOG_4BYTES
...@@ -373,8 +378,6 @@ mach_read_ulint( ...@@ -373,8 +378,6 @@ mach_read_ulint(
mlog_id_t type) mlog_id_t type)
MY_ATTRIBUTE((warn_unused_result)); MY_ATTRIBUTE((warn_unused_result));
#endif /* !UNIV_INNOCHECKSUM */
#include "mach0data.ic" #include "mach0data.ic"
#endif #endif
...@@ -865,6 +865,8 @@ mach_write_ulonglong( ...@@ -865,6 +865,8 @@ mach_write_ulonglong(
} }
} }
#endif /* !UNIV_INNOCHECKSUM */
/** Read 1 to 4 bytes from a file page buffered in the buffer pool. /** Read 1 to 4 bytes from a file page buffered in the buffer pool.
@param[in] ptr pointer where to read @param[in] ptr pointer where to read
@param[in] type MLOG_1BYTE, MLOG_2BYTES, or MLOG_4BYTES @param[in] type MLOG_1BYTE, MLOG_2BYTES, or MLOG_4BYTES
...@@ -889,5 +891,3 @@ mach_read_ulint( ...@@ -889,5 +891,3 @@ mach_read_ulint(
ut_error; ut_error;
return(0); return(0);
} }
#endif /* !UNIV_INNOCHECKSUM */
...@@ -85,8 +85,6 @@ Otherwise written as 0. @see PAGE_ROOT_AUTO_INC */ ...@@ -85,8 +85,6 @@ Otherwise written as 0. @see PAGE_ROOT_AUTO_INC */
This field should not be written to after This field should not be written to after
page creation. */ page creation. */
#ifndef UNIV_INNOCHECKSUM
#define PAGE_BTR_SEG_LEAF 36 /* file segment header for the leaf pages in #define PAGE_BTR_SEG_LEAF 36 /* file segment header for the leaf pages in
a B-tree: defined only on the root page of a a B-tree: defined only on the root page of a
B-tree, but not in the root of an ibuf tree */ B-tree, but not in the root of an ibuf tree */
...@@ -141,6 +139,8 @@ Otherwise written as 0. @see PAGE_ROOT_AUTO_INC */ ...@@ -141,6 +139,8 @@ Otherwise written as 0. @see PAGE_ROOT_AUTO_INC */
#define PAGE_SAME_PAGE 4 #define PAGE_SAME_PAGE 4
#define PAGE_NO_DIRECTION 5 #define PAGE_NO_DIRECTION 5
#ifndef UNIV_INNOCHECKSUM
/* PAGE DIRECTORY /* PAGE DIRECTORY
============== ==============
*/ */
......
...@@ -27,8 +27,8 @@ Created 2/2/1994 Heikki Tuuri ...@@ -27,8 +27,8 @@ Created 2/2/1994 Heikki Tuuri
#ifndef page0page_ic #ifndef page0page_ic
#define page0page_ic #define page0page_ic
#include "mach0data.h"
#ifndef UNIV_INNOCHECKSUM #ifndef UNIV_INNOCHECKSUM
#include "mach0data.h"
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
# include "log0recv.h" # include "log0recv.h"
#endif /* !UNIV_DEBUG */ #endif /* !UNIV_DEBUG */
...@@ -40,6 +40,7 @@ Created 2/2/1994 Heikki Tuuri ...@@ -40,6 +40,7 @@ Created 2/2/1994 Heikki Tuuri
#undef UNIV_INLINE #undef UNIV_INLINE
#define UNIV_INLINE #define UNIV_INLINE
#endif #endif
#endif /* !UNIV_INNOCHECKSUM */
/************************************************************//** /************************************************************//**
Gets the start of a page. Gets the start of a page.
...@@ -53,6 +54,7 @@ page_align( ...@@ -53,6 +54,7 @@ page_align(
return((page_t*) ut_align_down(ptr, UNIV_PAGE_SIZE)); return((page_t*) ut_align_down(ptr, UNIV_PAGE_SIZE));
} }
#ifndef UNIV_INNOCHECKSUM
/************************************************************//** /************************************************************//**
Gets the offset within a page. Gets the offset within a page.
@return offset from the start of the page */ @return offset from the start of the page */
...@@ -181,7 +183,6 @@ page_header_get_field( ...@@ -181,7 +183,6 @@ page_header_get_field(
} }
#ifndef UNIV_INNOCHECKSUM #ifndef UNIV_INNOCHECKSUM
/*************************************************************//** /*************************************************************//**
Sets the given header field. */ Sets the given header field. */
UNIV_INLINE UNIV_INLINE
...@@ -285,6 +286,8 @@ page_header_reset_last_insert( ...@@ -285,6 +286,8 @@ page_header_reset_last_insert(
} }
} }
#endif /* !UNIV_INNOCHECKSUM */
/************************************************************//** /************************************************************//**
Determine whether the page is in new-style compact format. Determine whether the page is in new-style compact format.
@return nonzero if the page is in compact format, zero if it is in @return nonzero if the page is in compact format, zero if it is in
...@@ -298,6 +301,7 @@ page_is_comp( ...@@ -298,6 +301,7 @@ page_is_comp(
return(page[PAGE_HEADER + PAGE_N_HEAP] & 0x80); return(page[PAGE_HEADER + PAGE_N_HEAP] & 0x80);
} }
#ifndef UNIV_INNOCHECKSUM
/************************************************************//** /************************************************************//**
TRUE if the record is on a page in compact format. TRUE if the record is on a page in compact format.
@return nonzero if in compact format */ @return nonzero if in compact format */
...@@ -326,6 +330,8 @@ page_rec_get_heap_no( ...@@ -326,6 +330,8 @@ page_rec_get_heap_no(
} }
} }
#endif /* !UNIV_INNOCHECKSUM */
/************************************************************//** /************************************************************//**
Determine whether the page is a B-tree leaf. Determine whether the page is a B-tree leaf.
@return true if the page is a B-tree leaf (PAGE_LEVEL = 0) */ @return true if the page is a B-tree leaf (PAGE_LEVEL = 0) */
...@@ -338,6 +344,7 @@ page_is_leaf( ...@@ -338,6 +344,7 @@ page_is_leaf(
return(!*(const uint16*) (page + (PAGE_HEADER + PAGE_LEVEL))); return(!*(const uint16*) (page + (PAGE_HEADER + PAGE_LEVEL)));
} }
#ifndef UNIV_INNOCHECKSUM
/************************************************************//** /************************************************************//**
Determine whether the page is empty. Determine whether the page is empty.
@return true if the page is empty (PAGE_N_RECS = 0) */ @return true if the page is empty (PAGE_N_RECS = 0) */
...@@ -627,6 +634,8 @@ page_get_middle_rec( ...@@ -627,6 +634,8 @@ page_get_middle_rec(
return(page_rec_get_nth(page, middle)); return(page_rec_get_nth(page, middle));
} }
#endif /* !UNIV_INNOCHECKSUM */
/*************************************************************//** /*************************************************************//**
Gets the page number. Gets the page number.
@return page number */ @return page number */
...@@ -640,6 +649,7 @@ page_get_page_no( ...@@ -640,6 +649,7 @@ page_get_page_no(
return(mach_read_from_4(page + FIL_PAGE_OFFSET)); return(mach_read_from_4(page + FIL_PAGE_OFFSET));
} }
#ifndef UNIV_INNOCHECKSUM
/*************************************************************//** /*************************************************************//**
Gets the tablespace identifier. Gets the tablespace identifier.
@return space id */ @return space id */
...@@ -653,6 +663,8 @@ page_get_space_id( ...@@ -653,6 +663,8 @@ page_get_space_id(
return(mach_read_from_4(page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID)); return(mach_read_from_4(page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID));
} }
#endif /* !UNIV_INNOCHECKSUM */
/*************************************************************//** /*************************************************************//**
Gets the number of user records on page (infimum and supremum records Gets the number of user records on page (infimum and supremum records
are not user records). are not user records).
...@@ -666,6 +678,7 @@ page_get_n_recs( ...@@ -666,6 +678,7 @@ page_get_n_recs(
return(page_header_get_field(page, PAGE_N_RECS)); return(page_header_get_field(page, PAGE_N_RECS));
} }
#ifndef UNIV_INNOCHECKSUM
/*************************************************************//** /*************************************************************//**
Gets the number of dir slots in directory. Gets the number of dir slots in directory.
@return number of slots */ @return number of slots */
...@@ -1054,6 +1067,8 @@ page_rec_get_base_extra_size( ...@@ -1054,6 +1067,8 @@ page_rec_get_base_extra_size(
return(REC_N_NEW_EXTRA_BYTES + (ulint) !page_rec_is_comp(rec)); return(REC_N_NEW_EXTRA_BYTES + (ulint) !page_rec_is_comp(rec));
} }
#endif /* UNIV_INNOCHECKSUM */
/************************************************************//** /************************************************************//**
Returns the sum of the sizes of the records in the record list, excluding Returns the sum of the sizes of the records in the record list, excluding
the infimum and supremum records. the infimum and supremum records.
...@@ -1077,6 +1092,7 @@ page_get_data_size( ...@@ -1077,6 +1092,7 @@ page_get_data_size(
return(ret); return(ret);
} }
#ifndef UNIV_INNOCHECKSUM
/************************************************************//** /************************************************************//**
Allocates a block of memory from the free list of an index page. */ Allocates a block of memory from the free list of an index page. */
UNIV_INLINE UNIV_INLINE
......
...@@ -27,12 +27,14 @@ Created 5/30/1994 Heikki Tuuri ...@@ -27,12 +27,14 @@ Created 5/30/1994 Heikki Tuuri
#ifndef rem0rec_h #ifndef rem0rec_h
#define rem0rec_h #define rem0rec_h
#ifndef UNIV_INNOCHECKSUM
#include "univ.i" #include "univ.i"
#include "data0data.h" #include "data0data.h"
#include "rem0types.h" #include "rem0types.h"
#include "mtr0types.h" #include "mtr0types.h"
#include "page0types.h" #include "page0types.h"
#include "trx0types.h" #include "trx0types.h"
#endif /*! UNIV_INNOCHECKSUM */
#include <ostream> #include <ostream>
#include <sstream> #include <sstream>
...@@ -92,6 +94,7 @@ offsets[] array, first passed to rec_get_offsets() */ ...@@ -92,6 +94,7 @@ offsets[] array, first passed to rec_get_offsets() */
#define REC_OFFS_NORMAL_SIZE OFFS_IN_REC_NORMAL_SIZE #define REC_OFFS_NORMAL_SIZE OFFS_IN_REC_NORMAL_SIZE
#define REC_OFFS_SMALL_SIZE 10 #define REC_OFFS_SMALL_SIZE 10
#ifndef UNIV_INNOCHECKSUM
/******************************************************//** /******************************************************//**
The following function is used to get the pointer of the next chained record The following function is used to get the pointer of the next chained record
on the same page. on the same page.
...@@ -1112,4 +1115,5 @@ int wsrep_rec_get_foreign_key( ...@@ -1112,4 +1115,5 @@ int wsrep_rec_get_foreign_key(
#include "rem0rec.ic" #include "rem0rec.ic"
#endif /* !UNIV_INNOCHECKSUM */
#endif /* rem0rec_h */ #endif /* rem0rec_h */
...@@ -108,13 +108,8 @@ support cross-platform development and expose comonly used SQL names. */ ...@@ -108,13 +108,8 @@ support cross-platform development and expose comonly used SQL names. */
#include <unistd.h> #include <unistd.h>
#endif #endif
#ifdef UNIV_INNOCHECKSUM
extern bool strict_verify;
extern FILE* log_file;
extern uintmax_t cur_page_num;
#endif /* UNIV_INNOCHECKSUM */
#include "my_pthread.h" #include "my_pthread.h"
/* Following defines are to enable performance schema /* Following defines are to enable performance schema
instrumentation in each of five InnoDB modules if instrumentation in each of five InnoDB modules if
HAVE_PSI_INTERFACE is defined. */ HAVE_PSI_INTERFACE is defined. */
...@@ -487,6 +482,12 @@ in both 32-bit and 64-bit environments. */ ...@@ -487,6 +482,12 @@ 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;
......
...@@ -4980,24 +4980,19 @@ page_zip_verify_checksum( ...@@ -4980,24 +4980,19 @@ page_zip_verify_checksum(
const void* data, /*!< in: compressed page */ const void* data, /*!< in: compressed page */
ulint size) /*!< in: size of compressed page */ ulint size) /*!< in: size of compressed page */
{ {
const unsigned char* p = static_cast<const unsigned char*>(data) ib_uint32_t stored;
+ FIL_PAGE_SPACE_OR_CHKSUM; ib_uint32_t calc;
const uint32_t stored = static_cast<uint32_t>( stored = static_cast<ib_uint32_t>(mach_read_from_4(
mach_read_from_4(p)); static_cast<const unsigned char*>(data) + FIL_PAGE_SPACE_OR_CHKSUM));
#ifdef UNIV_INNOCHECKSUM ulint page_no MY_ATTRIBUTE((unused)) =
p = static_cast<const unsigned char*>(data) + FIL_PAGE_TYPE; mach_read_from_4(static_cast<const unsigned char*>
bool no_checksum = (mach_read_from_2(p) == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED); (data) + FIL_PAGE_OFFSET);
p = static_cast<const unsigned char*>(data) + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION; ulint space_id MY_ATTRIBUTE((unused)) =
bool encrypted = (mach_read_from_4(p) != 0); mach_read_from_4(static_cast<const unsigned char*>
p = static_cast<const unsigned char*>(data) + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION + 4; (data) + FIL_PAGE_SPACE_ID);
const uint32_t checksum = static_cast<uint32_t>(mach_read_from_4(p)); const page_id_t page_id(space_id, page_no);
if (no_checksum) {
return (TRUE);
}
#endif
#if FIL_PAGE_LSN % 8 #if FIL_PAGE_LSN % 8
#error "FIL_PAGE_LSN must be 64 bit aligned" #error "FIL_PAGE_LSN must be 64 bit aligned"
...@@ -5017,7 +5012,7 @@ page_zip_verify_checksum( ...@@ -5017,7 +5012,7 @@ page_zip_verify_checksum(
} }
if (i >= size) { if (i >= size) {
if (log_file) { if (log_file) {
fprintf(log_file, "Page::%lu is empty and" fprintf(log_file, "Page::%llu is empty and"
" uncorrupted\n", cur_page_num); " uncorrupted\n", cur_page_num);
} }
...@@ -5041,21 +5036,12 @@ page_zip_verify_checksum( ...@@ -5041,21 +5036,12 @@ page_zip_verify_checksum(
return(TRUE); return(TRUE);
} }
#ifndef UNIV_INNOCHECKSUM calc = static_cast<ib_uint32_t>(page_zip_calc_checksum(
ulint page_no = mach_read_from_4(static_cast< data, size, curr_algo));
const unsigned char*>
(data) + FIL_PAGE_OFFSET);
ulint space_id = mach_read_from_4(static_cast<
const unsigned char*>
(data) + FIL_PAGE_SPACE_ID);
const page_id_t page_id(space_id, page_no);
#endif /* UNIV_INNOCHECKSUM */
const uint32_t calc = page_zip_calc_checksum(data, size, curr_algo);
#ifdef UNIV_INNOCHECKSUM #ifdef UNIV_INNOCHECKSUM
if (log_file) { if (log_file) {
fprintf(log_file, "page::%lu;" fprintf(log_file, "page::%llu;"
" %s checksum: calculated = %u;" " %s checksum: calculated = %u;"
" recorded = %u\n", cur_page_num, " recorded = %u\n", cur_page_num,
buf_checksum_algorithm_name( buf_checksum_algorithm_name(
...@@ -5070,21 +5056,17 @@ page_zip_verify_checksum( ...@@ -5070,21 +5056,17 @@ page_zip_verify_checksum(
data, size, SRV_CHECKSUM_ALGORITHM_CRC32); data, size, SRV_CHECKSUM_ALGORITHM_CRC32);
if (log_file) { if (log_file) {
fprintf(log_file, "page::%lu: crc32 checksum:" fprintf(log_file, "page::%llu: crc32 checksum:"
" calculated = %u; recorded = %u\n", " calculated = %u; recorded = %u\n",
cur_page_num, crc32, stored); cur_page_num, crc32, stored);
fprintf(log_file, "page::%lu: none checksum:" fprintf(log_file, "page::%llu: none checksum:"
" calculated = %lu; recorded = %u\n", " calculated = %lu; recorded = %u\n",
cur_page_num, BUF_NO_CHECKSUM_MAGIC, stored); cur_page_num, BUF_NO_CHECKSUM_MAGIC, stored);
} }
} }
#endif /* UNIV_INNOCHECKSUM */ #endif /* UNIV_INNOCHECKSUM */
if (stored == calc if (stored == calc) {
#ifdef UNIV_INNOCHECKSUM
|| ( encrypted == true && stored == checksum)
#endif
) {
return(TRUE); return(TRUE);
} }
...@@ -5116,11 +5098,7 @@ page_zip_verify_checksum( ...@@ -5116,11 +5098,7 @@ page_zip_verify_checksum(
if (legacy_big_endian_checksum) { if (legacy_big_endian_checksum) {
const uint32_t calculated = const uint32_t calculated =
page_zip_calc_checksum(data, size, curr_algo, true); page_zip_calc_checksum(data, size, curr_algo, true);
if (stored == calculated if (stored == calculated) {
#ifdef UNIV_INNOCHECKSUM
|| ( encrypted == true && calculated == checksum)
#endif
) {
return(TRUE); return(TRUE);
} }
...@@ -5130,11 +5108,7 @@ page_zip_verify_checksum( ...@@ -5130,11 +5108,7 @@ page_zip_verify_checksum(
uint32_t calculated = uint32_t calculated =
page_zip_calc_checksum(data, size, SRV_CHECKSUM_ALGORITHM_INNODB); page_zip_calc_checksum(data, size, SRV_CHECKSUM_ALGORITHM_INNODB);
if (stored == calculated if (stored == calculated) {
#ifdef UNIV_INNOCHECKSUM
|| ( encrypted == true && stored == checksum)
#endif
) {
#ifndef UNIV_INNOCHECKSUM #ifndef UNIV_INNOCHECKSUM
if (curr_algo if (curr_algo
...@@ -5154,11 +5128,7 @@ page_zip_verify_checksum( ...@@ -5154,11 +5128,7 @@ page_zip_verify_checksum(
/* If legacy checksum is not checked, do it now. */ /* If legacy checksum is not checked, do it now. */
if ((legacy_checksum_checked if ((legacy_checksum_checked
&& stored == calculated) && stored == calculated)) {
#ifdef UNIV_INNOCHECKSUM
|| ( encrypted == true && calculated == checksum)
#endif
) {
legacy_big_endian_checksum = true; legacy_big_endian_checksum = true;
return(TRUE); return(TRUE);
} }
...@@ -5168,11 +5138,7 @@ page_zip_verify_checksum( ...@@ -5168,11 +5138,7 @@ page_zip_verify_checksum(
case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB: case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB:
case SRV_CHECKSUM_ALGORITHM_INNODB: { case SRV_CHECKSUM_ALGORITHM_INNODB: {
if (stored == BUF_NO_CHECKSUM_MAGIC if (stored == BUF_NO_CHECKSUM_MAGIC) {
#ifdef UNIV_INNOCHECKSUM
|| ( encrypted == true && checksum == BUF_NO_CHECKSUM_MAGIC)
#endif
) {
#ifndef UNIV_INNOCHECKSUM #ifndef UNIV_INNOCHECKSUM
if (curr_algo if (curr_algo
== SRV_CHECKSUM_ALGORITHM_STRICT_INNODB) { == SRV_CHECKSUM_ALGORITHM_STRICT_INNODB) {
...@@ -5191,14 +5157,8 @@ page_zip_verify_checksum( ...@@ -5191,14 +5157,8 @@ page_zip_verify_checksum(
uint32_t calculated1; uint32_t calculated1;
if (stored == calculated if (stored == calculated
#ifdef UNIV_INNOCHECKSUM || stored == (calculated1 =
|| ( encrypted == true && checksum == calculated)
#endif
|| stored == (calculated1 =
page_zip_calc_checksum(data, size, SRV_CHECKSUM_ALGORITHM_CRC32, true)) page_zip_calc_checksum(data, size, SRV_CHECKSUM_ALGORITHM_CRC32, true))
#ifdef UNIV_INNOCHECKSUM
|| ( encrypted == true && checksum == calculated1)
#endif
) { ) {
#ifndef UNIV_INNOCHECKSUM #ifndef UNIV_INNOCHECKSUM
if (curr_algo if (curr_algo
...@@ -5222,12 +5182,7 @@ page_zip_verify_checksum( ...@@ -5222,12 +5182,7 @@ page_zip_verify_checksum(
data, size, SRV_CHECKSUM_ALGORITHM_CRC32, true); data, size, SRV_CHECKSUM_ALGORITHM_CRC32, true);
if (stored == calculated if (stored == calculated
|| stored == calculated1 || stored == calculated1) {
#ifdef UNIV_INNOCHECKSUM
|| ( encrypted == true && checksum == calculated)
|| ( encrypted == true && checksum == calculated1)
#endif
) {
#ifndef UNIV_INNOCHECKSUM #ifndef UNIV_INNOCHECKSUM
page_warn_strict_checksum( page_warn_strict_checksum(
curr_algo, curr_algo,
...@@ -5240,11 +5195,7 @@ page_zip_verify_checksum( ...@@ -5240,11 +5195,7 @@ page_zip_verify_checksum(
calculated = page_zip_calc_checksum( calculated = page_zip_calc_checksum(
data, size, SRV_CHECKSUM_ALGORITHM_INNODB); data, size, SRV_CHECKSUM_ALGORITHM_INNODB);
if (stored == calculated if (stored == calculated) {
#ifdef UNIV_INNOCHECKSUM
|| ( encrypted == true && checksum == calculated)
#endif
) {
#ifndef UNIV_INNOCHECKSUM #ifndef UNIV_INNOCHECKSUM
page_warn_strict_checksum( page_warn_strict_checksum(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment