mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 20:12:31 +01:00
e555540ab6
When using innodb_page_size=16k, InnoDB tables that were created in MariaDB 10.1.0 to 10.1.20 with PAGE_COMPRESSED=1 and PAGE_COMPRESSION_LEVEL=2 or PAGE_COMPRESSION_LEVEL=3 would fail to load. fsp_flags_is_valid(): When using innodb_page_size=16k, use a more strict check for .ibd files, with the assumption that nobody would try to use different-page-size files.
24 lines
998 B
Perl
24 lines
998 B
Perl
# Convert tablespace flags to the format understood by MariaDB 10.1.0..10.1.20,
|
|
# with the assumption that the flags were correct.
|
|
|
|
sub convert_to_mariadb_101
|
|
{
|
|
my ($file, $page_size) = @_;
|
|
open(FILE, "+<", $file) or die "Unable to open $file\n";
|
|
sysread(FILE, $_, $page_size)==$page_size||die "Unable to read $file\n";
|
|
sysseek(FILE, 0, 0)||die "Unable to seek $file\n";
|
|
|
|
# FIL_PAGE_DATA + FSP_SPACE_FLAGS = 38 + 16 = 54 bytes from the start
|
|
my($flags) = unpack "x[54]N", $_;
|
|
my $badflags = ($flags & 0x3f);
|
|
my $compression_level=3;
|
|
$badflags |= 1<<6|$compression_level<<7 if ($flags & 1 << 16);
|
|
$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);
|
|
syswrite(FILE, $_, $page_size)==$page_size||die "Unable to write $file\n";
|
|
close(FILE);
|
|
}
|