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

71 lines
2.1 KiB
Plaintext

--echo #
--echo # Bug #20445525 ADD A CONSISTENCY CHECK AGAINST DB_TRX_ID BEING
--echo # IN THE FUTURE
--echo #
--source include/have_nodebug.inc
let PAGE_SIZE=`select @@innodb_page_size`;
CREATE TABLE t1(a INT) row_format=redundant engine=innoDB;
INSERT INTO t1 VALUES(1);
let MYSQLD_DATADIR=`select @@datadir`;
--source include/shutdown_mysqld.inc
perl;
$page_size=$ENV{PAGE_SIZE};
my $file = "$ENV{MYSQLD_DATADIR}/test/t1.ibd";
open(FILE, "+<", $file) || die "Unable to open $file";
#Seek the the infimum record and get the offset to next record
#Infimum record exist at offset 101 for redundant format
#And offset to the next record is present 2 bytes prior to
#infimum record
seek(FILE, 4*$page_size+101-2, 0) || die "Unable to seek $file";
die unless read(FILE, $_, 2) == 2;
my $record_offset = unpack("n*", $_);
#In this case the first record should be at offset 135
# die unless $record_offset == 135;
# Lizard fix: In redundant format, the offsets of all fields are recorded
# in the offset array, and every field takes up one byte of space. We add
# two fields so the $record_offset should be 137.
die unless $record_offset == 137;
my $trx_id_of_rec = 4*$page_size + $record_offset + 6;
# Modify DB_TRX_ID of the record to a value which is greater than
# max_trx_id
seek(FILE, $trx_id_of_rec , 0) || die "Unable to seek $file";
my $corrupted_trx_id = "\xff" x 6;
syswrite(FILE, $corrupted_trx_id) || die "Unable to write";
#Modify the checksums of the page
seek(FILE, 4*$page_size, 0) || die "Unable to seek $file";
syswrite(FILE, pack("H*","deadbeef",4)) || die "Unable to write";
seek(FILE, 5*$page_size-8, 0) || die "Unable to seek $file";
syswrite(FILE, pack("H*","deadbeef",4)) || die "Unable to write";
close(FILE)
EOF
--source include/start_mysqld.inc
--disable_query_log
call mtr.add_suppression("\\[Warning\\] .*MY-\\d+.* A transaction id in a record of table `\.\.*`\.`\.\.*` is newer than the system-wide maximum.");
--enable_query_log
# Lizard: In the past, trx_id was used to check visibility, so it shows
# nothing in the following SQL. For now, scn is used, so we can still see
# the record.
SELECT * FROM t1;
DROP TABLE t1;