| 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_innodb.inc |
| 7 |
--source include/not_embedded.inc |
| 8 |
|
| 9 |
let PAGE_SIZE=`select @@innodb_page_size`; |
| 10 |
|
| 11 |
CREATE TABLE t1(a INT) row_format=redundant engine=innoDB stats_persistent=0; |
| 12 |
INSERT INTO t1 VALUES(1); |
| 13 |
|
| 14 |
let MYSQLD_DATADIR=`select @@datadir`; |
| 15 |
--source include/wait_all_purged.inc |
| 16 |
let $restart_noprint=2; |
| 17 |
--source include/shutdown_mysqld.inc |
| 18 |
|
| 19 |
perl; |
| 20 |
do "$ENV{MTR_SUITE_DIR}/include/crc32.pl"; |
| 21 |
my $file = "$ENV{MYSQLD_DATADIR}/test/t1.ibd"; |
| 22 |
open(FILE, "+<", $file) || die "Unable to open $file"; |
| 23 |
binmode FILE; |
| 24 |
|
| 25 |
#Seek the the infimum record and get the offset to next record |
| 26 |
#Infimum record exist at offset 101 for redundant format |
| 27 |
#And offset to the next record is present 2 bytes prior to |
| 28 |
#infimum record |
| 29 |
|
| 30 |
my $ps= $ENV{PAGE_SIZE}; |
| 31 |
my $page; |
| 32 |
die "Unable to read $file" unless sysread(FILE, $page, $ps) == $ps; |
| 33 |
my $full_crc32 = unpack("N",substr($page,54,4)) & 0x10; # FIL_SPACE_FLAGS |
| 34 |
sysseek(FILE, 3*$ps, 0) || die "Unable to seek $file\n"; |
| 35 |
die "Unable to read $file" unless sysread(FILE, $page, $ps) == $ps; |
| 36 |
#In this case the first record should be at offset 135 |
| 37 |
die unless unpack("n", substr($page, 99, 2)) == 135; |
| 38 |
|
| 39 |
substr($page,135+6,6) = "\xff" x 6; |
| 40 |
|
| 41 |
my $polynomial = 0x82f63b78; # CRC-32C |
| 42 |
if ($full_crc32) |
| 43 |
{ |
| 44 |
my $ck = mycrc32(substr($page, 0, $ps - 4), 0, $polynomial); |
| 45 |
substr($page, $ps - 4, 4) = pack("N", $ck); |
| 46 |
} |
| 47 |
else |
| 48 |
{ |
| 49 |
my $ck= pack("N",mycrc32(substr($page, 4, 22), 0, $polynomial) ^ |
| 50 |
mycrc32(substr($page, 38, $ps - 38 - 8), 0, $polynomial)); |
| 51 |
substr($page,0,4)=$ck; |
| 52 |
substr($page,$ps-8,4)=$ck; |
| 53 |
} |
| 54 |
sysseek(FILE, 3*$ps, 0) || die "Unable to rewind $file\n"; |
| 55 |
syswrite(FILE, $page, $ps)==$ps || die "Unable to write $file\n"; |
| 56 |
close(FILE) || die "Unable to close $file"; |
| 57 |
EOF |
| 58 |
|
| 59 |
--source include/start_mysqld.inc |
| 60 |
call mtr.add_suppression("\\[Warning\\] InnoDB: A transaction id in a record of table `test`\\.`t1` is newer than the system-wide maximum"); |
| 61 |
call mtr.add_suppression("\\[ERROR\\] InnoDB: We detected index corruption"); |
| 62 |
call mtr.add_suppression("Index for table 't1' is corrupt; try to repair it"); |
| 63 |
|
| 64 |
--error ER_NOT_KEYFILE |
| 65 |
SELECT * FROM t1; |
| 66 |
DROP TABLE t1; |