diff options
-rw-r--r-- | mysql-test/suite/innodb/include/ibd_convert.pl | 23 | ||||
-rw-r--r-- | mysql-test/suite/innodb/r/alter_kill.result | 2 | ||||
-rw-r--r-- | mysql-test/suite/innodb/t/101_compatibility.test | 3 | ||||
-rw-r--r-- | mysql-test/suite/innodb/t/alter_kill.test | 33 | ||||
-rw-r--r-- | mysql-test/suite/innodb/t/doublewrite.test | 12 | ||||
-rw-r--r-- | mysql-test/suite/innodb/t/log_corruption.test | 75 | ||||
-rw-r--r-- | mysql-test/suite/innodb/t/row_format_redundant.test | 8 | ||||
-rw-r--r-- | mysql-test/suite/innodb/t/table_flags.test | 8 | ||||
-rw-r--r-- | mysql-test/suite/mariabackup/huge_lsn.test | 8 |
9 files changed, 118 insertions, 54 deletions
diff --git a/mysql-test/suite/innodb/include/ibd_convert.pl b/mysql-test/suite/innodb/include/ibd_convert.pl index 9327de6d79a..dfa29ee14d1 100644 --- a/mysql-test/suite/innodb/include/ibd_convert.pl +++ b/mysql-test/suite/innodb/include/ibd_convert.pl @@ -19,9 +19,26 @@ sub convert_to_mariadb_101 { warn "$file: changing $flags to $badflags\n"; substr ($_, 54, 4) = pack("N", $badflags); - # Replace the innodb_checksum_algorithm=none checksum - substr ($_, 0, 4) = pack("N", 0xdeadbeef); - substr ($_, $page_size - 8, 4) = pack("N", 0xdeadbeef); + # Compute and replace the innodb_checksum_algorithm=crc32 checksum + my $polynomial = 0x82f63b78; # CRC-32C + if ($page_size == 1024) + { + # ROW_FORMAT=COMPRESSED + substr($_,0,4)=pack("N", + mycrc32(substr($_, 4, 12), 0, $polynomial) ^ + mycrc32(substr($_, 24, 2), 0, $polynomial) ^ + mycrc32(substr($_, 34, $page_size - 34), 0, + $polynomial)); + } + else + { + my $ck=pack("N", + mycrc32(substr($_, 4, 22), 0, $polynomial) ^ + mycrc32(substr($_, 38, $page_size - 38 - 8), 0, + $polynomial)); + substr($_, 0, 4) = $ck; + substr ($_, $page_size - 8, 4) = $ck; + } syswrite(FILE, $_, $page_size)==$page_size||die "Unable to write $file\n"; } close(FILE); diff --git a/mysql-test/suite/innodb/r/alter_kill.result b/mysql-test/suite/innodb/r/alter_kill.result index 87c89834ec1..4188031eed9 100644 --- a/mysql-test/suite/innodb/r/alter_kill.result +++ b/mysql-test/suite/innodb/r/alter_kill.result @@ -12,7 +12,7 @@ connection default; # Cleanly shutdown mysqld disconnect con1; # Corrupt FIL_PAGE_OFFSET in bug16720368.ibd, -# and update the checksum to the "don't care" value. +# and recompute innodb_checksum_algorithm=crc32 # Restart mysqld # This will succeed after a clean shutdown, due to # fil_open_single_table_tablespace(check_space_id=FALSE). diff --git a/mysql-test/suite/innodb/t/101_compatibility.test b/mysql-test/suite/innodb/t/101_compatibility.test index 470f543cd91..eb1ec3b26ac 100644 --- a/mysql-test/suite/innodb/t/101_compatibility.test +++ b/mysql-test/suite/innodb/t/101_compatibility.test @@ -42,6 +42,7 @@ perl; do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; ib_discard_tablespaces("test", "ti"); ib_restore_tablespaces("test", "ti"); +do "$ENV{MTR_SUITE_DIR}/include/crc32.pl"; do "$ENV{MTR_SUITE_DIR}/include/ibd_convert.pl"; my $ps = $ENV{INNODB_PAGE_SIZE}; my $dd = $ENV{MYSQLD_DATADIR}; @@ -62,6 +63,7 @@ INSERT INTO ti VALUES(1); --source include/kill_mysqld.inc perl; +do "$ENV{MTR_SUITE_DIR}/include/crc32.pl"; do "$ENV{MTR_SUITE_DIR}/include/ibd_convert.pl"; my $ps = $ENV{INNODB_PAGE_SIZE}; my $dd = $ENV{MYSQLD_DATADIR}; @@ -81,6 +83,7 @@ CHECK TABLE tr,tc,td,tz,tdd,tp,ti; --source include/shutdown_mysqld.inc perl; +do "$ENV{MTR_SUITE_DIR}/include/crc32.pl"; do "$ENV{MTR_SUITE_DIR}/include/ibd_convert.pl"; my $ps = $ENV{INNODB_PAGE_SIZE}; my $dd = $ENV{MYSQLD_DATADIR}; diff --git a/mysql-test/suite/innodb/t/alter_kill.test b/mysql-test/suite/innodb/t/alter_kill.test index 8de9781c972..2a130a6ed2c 100644 --- a/mysql-test/suite/innodb/t/alter_kill.test +++ b/mysql-test/suite/innodb/t/alter_kill.test @@ -44,13 +44,23 @@ connection default; disconnect con1; -- echo # Corrupt FIL_PAGE_OFFSET in bug16720368.ibd, --- echo # and update the checksum to the "don't care" value. +-- echo # and recompute innodb_checksum_algorithm=crc32 perl; +do "$ENV{MTR_SUITE_DIR}/include/crc32.pl"; my $file = "$ENV{MYSQLD_DATADIR}/test/bug16720368.ibd"; open(FILE, "+<$file") || die "Unable to open $file"; -print FILE pack("H*","deadbeefc001cafe") || die "Unable to write $file"; -seek(FILE, $ENV{PAGE_SIZE}-8, 0) || die "Unable to seek $file"; -print FILE pack("H*","deadbeef") || die "Unable to write $file"; +binmode FILE; +my $ps= $ENV{PAGE_SIZE}; +my $page; +die "Unable to read $file" unless sysread(FILE, $page, $ps) == $ps; +substr($page,4,4)=pack("N",0xc001cafe); +my $polynomial = 0x82f63b78; # CRC-32C +my $ck= pack("N",mycrc32(substr($page, 4, 22), 0, $polynomial) ^ + mycrc32(substr($page, 38, $ps - 38 - 8), 0, $polynomial)); +substr($page,0,4)=$ck; +substr($page,$ps-8,4)=$ck; +sysseek(FILE, 0, 0) || die "Unable to rewind $file\n"; +syswrite(FILE, $page, $ps)==$ps || die "Unable to write $file\n"; close(FILE) || die "Unable to close $file"; EOF @@ -97,10 +107,21 @@ SELECT COUNT(*) FROM bug16720368; # Uncorrupt the FIL_PAGE_OFFSET. perl; +do "$ENV{MTR_SUITE_DIR}/include/crc32.pl"; my $file = "$ENV{MYSQLD_DATADIR}/test/bug16720368.ibd"; open(FILE, "+<$file") || die "Unable to open $file"; -# Uncorrupt FIL_PAGE_OFFSET. -print FILE pack("H*","deadbeef00000000") || die "Unable to write $file"; +binmode FILE; +my $ps= $ENV{PAGE_SIZE}; +my $page; +die "Unable to read $file" unless sysread(FILE, $page, $ps) == $ps; +substr($page,4,4)=pack("N",0); +my $polynomial = 0x82f63b78; # CRC-32C +my $ck= pack("N",mycrc32(substr($page, 4, 22), 0, $polynomial) ^ + mycrc32(substr($page, 38, $ps - 38 - 8), 0, $polynomial)); +substr($page,0,4)=$ck; +substr($page,$ps-8,4)=$ck; +sysseek(FILE, 0, 0) || die "Unable to rewind $file\n"; +syswrite(FILE, $page, $ps)==$ps || die "Unable to write $file\n"; close(FILE) || die "Unable to close $file"; EOF diff --git a/mysql-test/suite/innodb/t/doublewrite.test b/mysql-test/suite/innodb/t/doublewrite.test index bdeaba2dcec..a5b2ffef4c8 100644 --- a/mysql-test/suite/innodb/t/doublewrite.test +++ b/mysql-test/suite/innodb/t/doublewrite.test @@ -73,6 +73,9 @@ set global innodb_buf_flush_list_now = 1; perl; use IO::Handle; +do "$ENV{MTR_SUITE_DIR}/include/crc32.pl"; +my $polynomial = 0x82f63b78; # CRC-32C + my $fname= "$ENV{'MYSQLD_DATADIR'}test/t1.ibd"; my $page_size = $ENV{INNODB_PAGE_SIZE}; my $page; @@ -102,9 +105,12 @@ for (my $d = $d1; $d < $d2 + 64; $d++) $badflags |= ($flags & 15 << 6) << 7; # PAGE_SSIZE substr ($_, 54, 4) = pack("N", $badflags); - # Replace the innodb_checksum_algorithm=none checksum - substr ($_, 0, 4) = pack("N", 0xdeadbeef); - substr ($_, $page_size - 8, 4) = pack("N", 0xdeadbeef); + # Replace the innodb_checksum_algorithm=crc32 checksum + my $ck= pack("N", + mycrc32(substr($_, 4, 22), 0, $polynomial) ^ + mycrc32(substr($_, 38, $page_size - 38 - 8), 0, $polynomial)); + substr ($_, 0, 4) = $ck; + substr ($_, $page_size - 8, 4) = $ck; syswrite(FILE, $_, $page_size)==$page_size||die; close(FILE); exit 0; diff --git a/mysql-test/suite/innodb/t/log_corruption.test b/mysql-test/suite/innodb/t/log_corruption.test index e9b081cff76..3d68724f7a9 100644 --- a/mysql-test/suite/innodb/t/log_corruption.test +++ b/mysql-test/suite/innodb/t/log_corruption.test @@ -33,55 +33,60 @@ EOF --let $dirs= --innodb-data-home-dir=$bugdir --innodb-log-group-home-dir=$bugdir perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/crc32.pl"; # Create a dummy system tablespace file using the default innodb_page_size=16k die unless open OUT, ">", "$ENV{bugdir}/ibdata1"; binmode OUT; +# We calculate innodb_checksum_algorithm=crc32 for the pages. +# The following bytes are excluded: +# bytes 0..3 (the checksum is stored there) +# bytes 26..37 (encryption key version, post-encryption checksum, tablespace id) +# bytes $page_size-8..$page_size-1 (checksum, LSB of FIL_PAGE_LSN) +my $polynomial = 0x82f63b78; # CRC-32C + # Tablespace header page with valid FSP_SIZE=768 pages. # Also, write a dummy FSEG_MAGIC_N at offset 60 to keep fseg_inode_try_get() # happy when fseg_n_reserved_pages() is following an invalid pointer # from the all-zero change buffer header page (page 3). -print OUT pack("Nx[42]Nx[10]Nx[16312]Nx[4]", - 0xdeadbeef, # checksum - 768, # FSP_PAGE_SIZE - 97937874, # FSEG_MAGIC_N - 0xdeadbeef); # checksum +## FIL_PAGE_OFFSET +my $head = pack("Nx[18]", 0); +## FSP_PAGE_SIZE, # FSEG_MAGIC_N +my $body = pack("x[8]Nx[10]Nx[16312]", 768, 97937874); +my $ck = mycrc32($head, 0, $polynomial) ^ mycrc32($body, 0, $polynomial); +print OUT pack("N",$ck).$head.pack("x[12]").$body.pack("Nx[4]",$ck); # Dummy pages 1..6. print OUT chr(0) x (6 * 16384); -# Dictionary header page. -print OUT pack("NNx[62]Nx[8]Nx[16290]Nx[4]", - 0xdeadbeef, # checksum - 7, # FIL_PAGE_OFFSET - 8, # DICT_HDR_TABLES - 9, # DICT_HDR_INDEXES - 0xdeadbeef); # checksum +# Dictionary header page (page 7). +## FIL_PAGE_OFFSET +$head = pack("Nx[18]", 7); +## DICT_HDR_TABLES,DICT_HDR_INDEXES +$body = pack("x[32]Nx[8]Nx[16290]", 8, 9); +$ck = mycrc32($head, 0, $polynomial) ^ mycrc32($body, 0, $polynomial); +print OUT pack("N",$ck).$head.pack("x[12]").$body.pack("Nx[4]",$ck); # Empty SYS_TABLES page (page 8). -print OUT pack("NNNNx[8]nx[12]nnx[31]Cx[20]", - 0xdeadbeef, # checksum - 8, # FIL_PAGE_OFFSET - ~0, ~0, # FIL_PAGE_PREV, FIL_PAGE_NEXT - 17855, # FIL_PAGE_TYPE == FIL_PAGE_INDEX - 2, # PAGE_N_DIR_SLOTS - 124, # PAGE_HEAP_TOP - 1); # PAGE_INDEX_ID == DICT_TABLES_ID -print OUT pack("nxnn", 0x801, 3, 116), "infimum"; -print OUT pack("xnxnxx", 0x901, 0x803), "supremum"; -print OUT pack("x[16248]nnNx[4]", 116, 101, 0xdeadbeef); +## FIL_PAGE_OFFSET, FIL_PAGE_PREV, FIL_PAGE_NEXT, FIL_PAGE_TYPE +$head = pack("NNNx[8]n", 8, ~0, ~0, 17855); +## PAGE_N_DIR_SLOTS, PAGE_HEAP_TOP, PAGE_INDEX_ID == DICT_TABLES_ID +$body = pack("nnx[31]Cx[20]", 2, 124, 1); +$body .= pack("nxnn", 0x801, 3, 116) . "infimum"; +$body .= pack("xnxnxx", 0x901, 0x803) . "supremum"; +$body .= pack("x[16248]nn", 116, 101); +$ck = mycrc32($head, 0, $polynomial) ^ mycrc32($body, 0, $polynomial); +print OUT pack("N",$ck).$head.pack("x[12]").$body.pack("Nx[4]",$ck); # Empty SYS_INDEXES page (page 9). -print OUT pack("NNNNx[8]nx[12]nnx[31]Cx[20]", - 0xdeadbeef, # checksum - 9, # FIL_PAGE_OFFSET - ~0, ~0, # FIL_PAGE_PREV, FIL_PAGE_NEXT - 17855, # FIL_PAGE_TYPE == FIL_PAGE_INDEX - 2, # PAGE_N_DIR_SLOTS - 124, # PAGE_HEAP_TOP - 3); # PAGE_INDEX_ID == DICT_INDEXES_ID - -print OUT pack("nxnn", 0x801, 3, 116), "infimum"; -print OUT pack("xnxnxx", 0x901, 0x803), "supremum"; -print OUT pack("x[16248]nnNx[4]", 116, 101, 0xdeadbeef); +## FIL_PAGE_OFFSET, FIL_PAGE_PREV, FIL_PAGE_NEXT, FIL_PAGE_TYPE +$head = pack("NNNx[8]n", 9, ~0, ~0, 17855); +## PAGE_N_DIR_SLOTS, PAGE_HEAP_TOP, PAGE_INDEX_ID == DICT_INDEXES_ID +$body = pack("nnx[31]Cx[20]", 2, 124, 3); +$body .= pack("nxnn", 0x801, 3, 116) . "infimum"; +$body .= pack("xnxnxx", 0x901, 0x803) . "supremum"; +$body .= pack("x[16248]nn", 116, 101); +$ck = mycrc32($head, 0, $polynomial) ^ mycrc32($body, 0, $polynomial); +print OUT pack("N",$ck).$head.pack("x[12]").$body.pack("Nx[4]",$ck); + print OUT chr(0) x (759 * 16384); close OUT or die; diff --git a/mysql-test/suite/innodb/t/row_format_redundant.test b/mysql-test/suite/innodb/t/row_format_redundant.test index 81541fb0582..fc72e5c2664 100644 --- a/mysql-test/suite/innodb/t/row_format_redundant.test +++ b/mysql-test/suite/innodb/t/row_format_redundant.test @@ -92,6 +92,7 @@ TRUNCATE TABLE t3; --source include/shutdown_mysqld.inc --perl use strict; +do "$ENV{MTR_SUITE_DIR}/include/crc32.pl"; my $ps= $ENV{INNODB_PAGE_SIZE}; my $file= "$ENV{bugdir}/ibdata1"; open(FILE, "+<", $file) || die "Unable to open $file\n"; @@ -120,8 +121,11 @@ for (my $offset= 0x65; $offset; $start= $end & 0x7f; } } -substr($page,0,4)=pack("N",0xdeadbeef); -substr($page,$ps-8,4)=pack("N",0xdeadbeef); +my $polynomial = 0x82f63b78; # CRC-32C +my $ck= pack("N",mycrc32(substr($page, 4, 22), 0, $polynomial) ^ + mycrc32(substr($page, 38, $ps - 38 - 8), 0, $polynomial)); +substr($page,0,4)=$ck; +substr($page,$ps-8,4)=$ck; sysseek(FILE, $sys_tables_root*$ps, 0) || die "Unable to seek $file"; syswrite(FILE, $page, $ps)==$ps || die "Unable to write $file\n"; close(FILE) || die "Unable to close $file\n"; diff --git a/mysql-test/suite/innodb/t/table_flags.test b/mysql-test/suite/innodb/t/table_flags.test index e979b5fffe0..13e1fc01dc0 100644 --- a/mysql-test/suite/innodb/t/table_flags.test +++ b/mysql-test/suite/innodb/t/table_flags.test @@ -52,6 +52,7 @@ PAGE_COMPRESSED=1 PAGE_COMPRESSION_LEVEL=9; --source include/shutdown_mysqld.inc --perl use strict; +do "$ENV{MTR_SUITE_DIR}/include/crc32.pl"; my $ps= $ENV{INNODB_PAGE_SIZE}; my $file= "$ENV{bugdir}/ibdata1"; open(FILE, "+<", $file) || die "Unable to open $file\n"; @@ -127,8 +128,11 @@ for (my $offset= 0x65; $offset; } print ")\n"; } -substr($page,0,4)=pack("N",0xdeadbeef); -substr($page,$ps-8,4)=pack("N",0xdeadbeef); +my $polynomial = 0x82f63b78; # CRC-32C +my $ck= pack("N",mycrc32(substr($page, 4, 22), 0, $polynomial) ^ + mycrc32(substr($page, 38, $ps - 38 - 8), 0, $polynomial)); +substr($page,0,4)=$ck; +substr($page,$ps-8,4)=$ck; sysseek(FILE, $sys_tables_root*$ps, 0) || die "Unable to seek $file"; syswrite(FILE, $page, $ps)==$ps || die "Unable to write $file\n"; close(FILE) || die "Unable to close $file\n"; diff --git a/mysql-test/suite/mariabackup/huge_lsn.test b/mysql-test/suite/mariabackup/huge_lsn.test index 9e72f0ad8d0..dcdc118df6f 100644 --- a/mysql-test/suite/mariabackup/huge_lsn.test +++ b/mysql-test/suite/mariabackup/huge_lsn.test @@ -11,6 +11,7 @@ let MYSQLD_DATADIR=`select @@datadir`; --source include/shutdown_mysqld.inc perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/crc32.pl"; my $file= "$ENV{MYSQLD_DATADIR}/ibdata1"; open(FILE, "+<", $file) or die "Unable to open $file\n"; binmode FILE; @@ -18,8 +19,11 @@ my $ps= $ENV{INNODB_PAGE_SIZE}; my $page; die "Unable to read $file" unless sysread(FILE, $page, $ps) == $ps; substr($page,26,8) = pack("NN", 4096, ~1024); -substr($page,0,4)=pack("N",0xdeadbeef); -substr($page,$ps-8,4)=pack("N",0xdeadbeef); +my $polynomial = 0x82f63b78; # CRC-32C +my $ck= pack("N",mycrc32(substr($page, 4, 22), 0, $polynomial) ^ + mycrc32(substr($page, 38, $ps - 38 - 8), 0, $polynomial)); +substr($page,0,4)=$ck; +substr($page,$ps-8,4)=$ck; sysseek(FILE, 0, 0) || die "Unable to rewind $file\n"; syswrite(FILE, $page, $ps)==$ps || die "Unable to write $file\n"; close(FILE) || die "Unable to close $file\n"; |