File: page_id_innochecksum.test

package info (click to toggle)
mariadb 1%3A11.8.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 772,520 kB
  • sloc: ansic: 2,414,714; cpp: 1,791,394; asm: 381,336; perl: 62,905; sh: 49,647; pascal: 40,897; java: 39,363; python: 20,791; yacc: 20,432; sql: 17,907; xml: 12,344; ruby: 8,544; cs: 6,542; makefile: 6,145; ada: 1,879; lex: 1,193; javascript: 996; objc: 80; tcl: 73; awk: 46; php: 22
file content (71 lines) | stat: -rw-r--r-- 2,465 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
--source include/have_innodb.inc
--source include/not_embedded.inc
--source include/innodb_checksum_algorithm.inc
--echo # Set the environmental variables
let MYSQLD_BASEDIR= `SELECT @@basedir`;
let MYSQLD_DATADIR= `SELECT @@datadir`;
let INNODB_PAGE_SIZE=`select @@innodb_page_size`;

create table t1(f1 int not null)engine=innodb stats_persistent=0;
insert into t1 values(1), (2), (3);
let $resultlog=$MYSQLTEST_VARDIR/tmp/result.log;

let $restart_noprint=2;
--source include/shutdown_mysqld.inc
--echo # Change the page offset
perl;
use strict;
use warnings;
use Fcntl qw(:DEFAULT :seek);
do "$ENV{MTR_SUITE_DIR}/../innodb/include/crc32.pl";

my $page_size = $ENV{INNODB_PAGE_SIZE};

sysopen IBD_FILE, "$ENV{MYSQLD_DATADIR}/test/t1.ibd", O_RDWR
|| die "Cannot open t1.ibd\n";
sysread(IBD_FILE, $_, 58) || die "Cannot read t1.ibd\n";
my ($space,$flags) = unpack("x[34]Nx[16]N", $_);
my $full_crc32 = $flags & 0x10;
sysseek(IBD_FILE, $page_size * 3, SEEK_SET) || die "Cannot seek t1.ibd\n";

my $page= pack("NNx[18]NNN", 0, 4, 1, 0, $space).(chr(0) x ($page_size - 38));

# Calculate innodb_checksum_algorithm=crc32 or full_crc32.
my $polynomial = 0x82f63b78; # CRC-32C
if ($full_crc32)
{
    my $ck = mycrc32(substr($page, 0, $page_size-4), 0, $polynomial);
    substr($page, $page_size-4, 4) = pack("N", $ck);
}
else
{
    # The following bytes are excluded:
    # 0..3 (the checksum is stored there)
    # 26..37 (encryption key version, post-encryption checksum, tablespace id)
    # $page_size-8..$page_size-1 (checksum, LSB of FIL_PAGE_LSN)
    my $ck= pack("N",mycrc32(substr($page, 4, 22), 0, $polynomial) ^
		 mycrc32(substr($page, 38, $page_size-38-8), 0, $polynomial));
    substr($page,0,4)=$ck;
    substr($page,$page_size-8,4)=$ck;
}

die unless syswrite(IBD_FILE, $page, $page_size) == $page_size;
close IBD_FILE;
EOF

--error 1
exec $INNOCHECKSUM -l $resultlog $MYSQLD_DATADIR/test/t1.ibd;

let SEARCH_FILE = $MYSQLTEST_VARDIR/tmp/result.log;
let SEARCH_PATTERN=page id mismatch;
--source include/search_pattern_in_file.inc

--remove_file $resultlog
let $restart_parameters=--innodb-force-recovery=1;
--source include/start_mysqld.inc
--source include/wait_all_purged.inc
drop table t1;
call mtr.add_suppression("InnoDB: Failed to read page 3 from file '.*test/t1\\.ibd': Page read from tablespace is corrupted\\.");
call mtr.add_suppression("InnoDB: File '.*t1\\.ibd' is corrupted");
let $restart_parameters=;
--source include/restart_mysqld.inc