| 1 |
--source include/have_innodb.inc |
| 2 |
--source include/not_embedded.inc |
| 3 |
--source include/innodb_checksum_algorithm.inc |
| 4 |
--echo # Set the environmental variables |
| 5 |
let MYSQLD_BASEDIR= `SELECT @@basedir`; |
| 6 |
let MYSQLD_DATADIR= `SELECT @@datadir`; |
| 7 |
let INNODB_PAGE_SIZE=`select @@innodb_page_size`; |
| 8 |
|
| 9 |
create table t1(f1 int not null)engine=innodb stats_persistent=0; |
| 10 |
insert into t1 values(1), (2), (3); |
| 11 |
let $resultlog=$MYSQLTEST_VARDIR/tmp/result.log; |
| 12 |
|
| 13 |
let $restart_noprint=2; |
| 14 |
--source include/shutdown_mysqld.inc |
| 15 |
--echo # Change the page offset |
| 16 |
perl; |
| 17 |
use strict; |
| 18 |
use warnings; |
| 19 |
use Fcntl qw(:DEFAULT :seek); |
| 20 |
do "$ENV{MTR_SUITE_DIR}/../innodb/include/crc32.pl"; |
| 21 |
|
| 22 |
my $page_size = $ENV{INNODB_PAGE_SIZE}; |
| 23 |
|
| 24 |
sysopen IBD_FILE, "$ENV{MYSQLD_DATADIR}/test/t1.ibd", O_RDWR |
| 25 |
|| die "Cannot open t1.ibd\n"; |
| 26 |
sysread(IBD_FILE, $_, 58) || die "Cannot read t1.ibd\n"; |
| 27 |
my ($space,$flags) = unpack("x[34]Nx[16]N", $_); |
| 28 |
my $full_crc32 = $flags & 0x10; |
| 29 |
sysseek(IBD_FILE, $page_size * 3, SEEK_SET) || die "Cannot seek t1.ibd\n"; |
| 30 |
|
| 31 |
my $page= pack("NNx[18]NNN", 0, 4, 1, 0, $space).(chr(0) x ($page_size - 38)); |
| 32 |
|
| 33 |
# Calculate innodb_checksum_algorithm=crc32 or full_crc32. |
| 34 |
my $polynomial = 0x82f63b78; # CRC-32C |
| 35 |
if ($full_crc32) |
| 36 |
{ |
| 37 |
my $ck = mycrc32(substr($page, 0, $page_size-4), 0, $polynomial); |
| 38 |
substr($page, $page_size-4, 4) = pack("N", $ck); |
| 39 |
} |
| 40 |
else |
| 41 |
{ |
| 42 |
# The following bytes are excluded: |
| 43 |
# 0..3 (the checksum is stored there) |
| 44 |
# 26..37 (encryption key version, post-encryption checksum, tablespace id) |
| 45 |
# $page_size-8..$page_size-1 (checksum, LSB of FIL_PAGE_LSN) |
| 46 |
my $ck= pack("N",mycrc32(substr($page, 4, 22), 0, $polynomial) ^ |
| 47 |
mycrc32(substr($page, 38, $page_size-38-8), 0, $polynomial)); |
| 48 |
substr($page,0,4)=$ck; |
| 49 |
substr($page,$page_size-8,4)=$ck; |
| 50 |
} |
| 51 |
|
| 52 |
die unless syswrite(IBD_FILE, $page, $page_size) == $page_size; |
| 53 |
close IBD_FILE; |
| 54 |
EOF |
| 55 |
|
| 56 |
--error 1 |
| 57 |
exec $INNOCHECKSUM -l $resultlog $MYSQLD_DATADIR/test/t1.ibd; |
| 58 |
|
| 59 |
let SEARCH_FILE = $MYSQLTEST_VARDIR/tmp/result.log; |
| 60 |
let SEARCH_PATTERN=page id mismatch; |
| 61 |
--source include/search_pattern_in_file.inc |
| 62 |
|
| 63 |
--remove_file $resultlog |
| 64 |
let $restart_parameters=--innodb-force-recovery=1; |
| 65 |
--source include/start_mysqld.inc |
| 66 |
--source include/wait_all_purged.inc |
| 67 |
drop table t1; |
| 68 |
call mtr.add_suppression("InnoDB: Failed to read page 3 from file '.*test/t1\\.ibd': Page read from tablespace is corrupted\\."); |
| 69 |
call mtr.add_suppression("InnoDB: File '.*t1\\.ibd' is corrupted"); |
| 70 |
let $restart_parameters=; |
| 71 |
--source include/restart_mysqld.inc |