Debian Codegraph @

mysql-test/suite/innodb/t/trx_id_future.test

raw
1 --echo #
2 --echo # Bug #20445525 ADD A CONSISTENCY CHECK AGAINST DB_TRX_ID BEING
3 --echo # IN THE FUTURE
4 --echo #
5
6 --source include/have_nodebug.inc
7
8 let PAGE_SIZE=`select @@innodb_page_size`;
9
10 CREATE TABLE t1(a INT) row_format=redundant engine=innoDB;
11 INSERT INTO t1 VALUES(1);
12
13 let MYSQLD_DATADIR=`select @@datadir`;
14
15 --source include/shutdown_mysqld.inc
16
17 perl;
18
19 $page_size=$ENV{PAGE_SIZE};
20
21 my $file = "$ENV{MYSQLD_DATADIR}/test/t1.ibd";
22 open(FILE, "+<", $file) || die "Unable to open $file";
23
24 #Seek the the infimum record and get the offset to next record
25 #Infimum record exist at offset 101 for redundant format
26 #And offset to the next record is present 2 bytes prior to
27 #infimum record
28
29 seek(FILE, 4*$page_size+101-2, 0) || die "Unable to seek $file";
30 die unless read(FILE, $_, 2) == 2;
31 my $record_offset = unpack("n*", $_);
32
33 #In this case the first record should be at offset 135
34 die unless $record_offset == 135;
35
36 my $trx_id_of_rec = 4*$page_size + $record_offset + 6;
37
38 # Modify DB_TRX_ID of the record to a value which is greater than
39 # max_trx_id
40 seek(FILE, $trx_id_of_rec , 0) || die "Unable to seek $file";
41
42 my $corrupted_trx_id = "\xff" x 6;
43 syswrite(FILE, $corrupted_trx_id) || die "Unable to write";
44
45 #Modify the checksums of the page
46
47 seek(FILE, 4*$page_size, 0) || die "Unable to seek $file";
48 syswrite(FILE, pack("H*","deadbeef",4)) || die "Unable to write";
49
50 seek(FILE, 5*$page_size-8, 0) || die "Unable to seek $file";
51 syswrite(FILE, pack("H*","deadbeef",4)) || die "Unable to write";
52
53 close(FILE)
54 EOF
55
56 --source include/start_mysqld.inc
57
58 --disable_query_log
59 call mtr.add_suppression("\\[Warning\\] .*MY-\\d+.* A transaction id in a record of table `\.\.*`\.`\.\.*` is newer than the system-wide maximum.");
60 --enable_query_log
61
62 SELECT * FROM t1;
63 DROP TABLE t1;