| 1 |
--source include/innodb_page_size.inc |
| 2 |
# Embedded server tests do not support restarting |
| 3 |
--source include/not_embedded.inc |
| 4 |
# Slow shutdown may take more than 120 seconds under Valgrind, |
| 5 |
# causing the server to be (silently) killed. |
| 6 |
# Due to that, crash recovery could "heal" the damage that our |
| 7 |
# Perl code is inflicting, and the SELECT statements could succeed |
| 8 |
# instead of failing with ER_NO_SUCH_TABLE_IN_ENGINE. |
| 9 |
--source include/not_valgrind.inc |
| 10 |
|
| 11 |
--disable_query_log |
| 12 |
call mtr.add_suppression("InnoDB: Table `mysql`\\.`innodb_table_stats` not found"); |
| 13 |
call mtr.add_suppression("InnoDB: incorrect flags in SYS_TABLES"); |
| 14 |
call mtr.add_suppression("InnoDB: Table test/t[cp] in InnoDB data dictionary contains invalid flags\\. SYS_TABLES\\.TYPE=(129|289|3873|1232[31]) SYS_TABLES\\.N_COLS=2147483649\\r?$"); |
| 15 |
call mtr.add_suppression("InnoDB: Table test/tr in InnoDB data dictionary contains invalid flags\\. SYS_TABLES\\.TYPE=65 SYS_TABLES\\.MIX_LEN=4294967295\\r?$"); |
| 16 |
call mtr.add_suppression("InnoDB: Refusing to load '\\..test.td\\.ibd' \\(id=3, flags=0x([2e]1)\\); dictionary contains id=3, flags=0x100\\1\\r?$"); |
| 17 |
call mtr.add_suppression("InnoDB: Refusing to load '\\..test.td\\.ibd' \\(id=3, flags=0x(1[2ae]1)\\); dictionary contains id=3, flags=0x10\\1\\r?$"); |
| 18 |
call mtr.add_suppression("InnoDB: Ignoring tablespace for `test`.`td` because it could not be opened\\."); |
| 19 |
# FIXME: Remove the following spam due to invalid flags for test.td |
| 20 |
call mtr.add_suppression("InnoDB: Operating system error number .* in a file operation"); |
| 21 |
call mtr.add_suppression("InnoDB: The error means the system cannot find the path specified"); |
| 22 |
call mtr.add_suppression("InnoDB: adjusting FSP_SPACE_FLAGS of file "); |
| 23 |
call mtr.add_suppression("InnoDB: Parent table of FTS auxiliary table .* not found."); |
| 24 |
FLUSH TABLES; |
| 25 |
--enable_query_log |
| 26 |
|
| 27 |
let INNODB_PAGE_SIZE=`select @@innodb_page_size`; |
| 28 |
let MYSQLD_DATADIR=`select @@datadir`; |
| 29 |
|
| 30 |
let bugdir= $MYSQLTEST_VARDIR/tmp/table_flags; |
| 31 |
--mkdir $bugdir |
| 32 |
let undodir= $MYSQLTEST_VARDIR/tmp/undo_dir; |
| 33 |
--mkdir $undodir |
| 34 |
|
| 35 |
--let SEARCH_FILE = $MYSQLTEST_VARDIR/log/mysqld.1.err |
| 36 |
|
| 37 |
--let $d=--innodb-data-home-dir=$bugdir --innodb-log-group-home-dir=$bugdir |
| 38 |
--let $d=$d --innodb-data-file-path=ibdata1:1M:autoextend |
| 39 |
--let $d=$d --innodb-undo-tablespaces=0 |
| 40 |
--let $d=$d --skip-innodb-fast-shutdown --innodb_undo_directory=$undodir |
| 41 |
--let $restart_noprint=1 |
| 42 |
--let $restart_parameters=$d --innodb-stats-persistent=0 |
| 43 |
--source include/restart_mysqld.inc |
| 44 |
|
| 45 |
CREATE TABLE tr(a INT PRIMARY KEY)ENGINE=InnoDB ROW_FORMAT=REDUNDANT; |
| 46 |
CREATE TABLE tc(a INT PRIMARY KEY)ENGINE=InnoDB ROW_FORMAT=COMPACT; |
| 47 |
CREATE TABLE td(a INT PRIMARY KEY)ENGINE=InnoDB ROW_FORMAT=DYNAMIC; |
| 48 |
SET innodb_strict_mode=OFF; |
| 49 |
CREATE TABLE tz(a INT PRIMARY KEY)ENGINE=InnoDB ROW_FORMAT=COMPRESSED |
| 50 |
KEY_BLOCK_SIZE=1; |
| 51 |
SET innodb_strict_mode=ON; |
| 52 |
# PAGE_COMPRESSED is supported starting with MariaDB 10.1.0 |
| 53 |
CREATE TABLE tp(a INT PRIMARY KEY)ENGINE=InnoDB ROW_FORMAT=DYNAMIC |
| 54 |
PAGE_COMPRESSED=1 PAGE_COMPRESSION_LEVEL=9; |
| 55 |
|
| 56 |
--source include/shutdown_mysqld.inc |
| 57 |
--perl |
| 58 |
use strict; |
| 59 |
do "$ENV{MTR_SUITE_DIR}/include/crc32.pl"; |
| 60 |
my $ps= $ENV{INNODB_PAGE_SIZE}; |
| 61 |
my $file= "$ENV{bugdir}/ibdata1"; |
| 62 |
open(FILE, "+<", $file) || die "Unable to open $file\n"; |
| 63 |
die "Unable to read $file" unless sysread(FILE, $_, 58) == 58; |
| 64 |
my $full_crc32 = unpack("N",substr($_,54,4)) & 0x10; # FIL_SPACE_FLAGS |
| 65 |
# Read DICT_HDR_TABLES, the root page number of CLUST_IND (SYS_TABLES.NAME). |
| 66 |
sysseek(FILE, 7*$ps+38+32, 0) || die "Unable to seek $file"; |
| 67 |
die "Unable to read $file" unless sysread(FILE, $_, 4) == 4; |
| 68 |
my $sys_tables_root = unpack("N", $_); |
| 69 |
my $page; |
| 70 |
print "SYS_TABLES clustered index root page ($sys_tables_root):\n"; |
| 71 |
sysseek(FILE, $sys_tables_root*$ps, 0) || die "Unable to seek $file"; |
| 72 |
die "Unable to read $file" unless sysread(FILE, $page, $ps) == $ps; |
| 73 |
open(BACKUP, ">$ENV{bugdir}/sys_tables.bin") || die "Unable to open backup\n"; |
| 74 |
syswrite(BACKUP, $page, $ps)==$ps || die "Unable to write backup\n"; |
| 75 |
close(BACKUP) || die "Unable to close backup\n"; |
| 76 |
print "N_RECS=", unpack("n", substr($page,38+16,2)); |
| 77 |
print "; LEVEL=", unpack("n", substr($page,38+26,2)); |
| 78 |
print "; INDEX_ID=0x", unpack("H*", substr($page,38+28,8)), "\n"; |
| 79 |
my @fields=("NAME","DB_TRX_ID","DB_ROLL_PTR", |
| 80 |
"ID","N_COLS","TYPE","MIX_ID","MIX_LEN","CLUSTER_NAME","SPACE"); |
| 81 |
for (my $offset= 0x65; $offset; |
| 82 |
$offset= unpack("n", substr($page,$offset-2,2))) |
| 83 |
{ |
| 84 |
print "header=0x", unpack("H*",substr($page,$offset-6,6)), " ("; |
| 85 |
my $n_fields= unpack("n", substr($page,$offset-4,2)) >> 1 & 0x3ff; |
| 86 |
my $start= 0; |
| 87 |
my $name; |
| 88 |
for (my $i= 0; $i < $n_fields; $i++) { |
| 89 |
my $end= unpack("C", substr($page, $offset-7-$i, 1)); |
| 90 |
print ",\n " if $i; |
| 91 |
print "$fields[$i]="; |
| 92 |
if ($i == 1 || $i == 2) { |
| 93 |
print "0x", "XX" x ($end-$start); |
| 94 |
} elsif ($end & 0x80) { |
| 95 |
print "NULL(", ($end & 0x7f) - $start, " bytes)" |
| 96 |
} elsif ($n_fields > 1 && $i == 0) { |
| 97 |
$name= substr($page,$offset+$start,$end-$start); |
| 98 |
print "'$name'" |
| 99 |
} else { |
| 100 |
print "0x", unpack("H*", substr($page,$offset+$start,$end-$start)) |
| 101 |
} |
| 102 |
# Corrupt SYS_TABLES.TYPE |
| 103 |
if ($i == 5) |
| 104 |
{ |
| 105 |
my $flags= 0; |
| 106 |
if ($name eq 'test/tr') { |
| 107 |
$flags= 0x40 # DATA_DIR (largely ignored by 10.1+) |
| 108 |
} elsif ($name eq 'test/tc') { |
| 109 |
$flags= 0x80 # 10.1 PAGE_COMPRESSED |
| 110 |
} elsif ($name eq 'test/td') { |
| 111 |
$flags= 0xf00 # PAGE_COMPRESSION_LEVEL=15 (0..9 is valid) |
| 112 |
# As part of the MDEV-12873 fix, because the |
| 113 |
# PAGE_COMPRESSED=YES flag was not set, we will assume that |
| 114 |
# this table was actually created with 10.2.2..10.2.6 |
| 115 |
# using PAGE_COMPRESSED=YES PAGE_COMPRESSION_LEVEL=7. |
| 116 |
} elsif ($name eq 'test/tz') { |
| 117 |
$flags= 0x3000 # 10.1 ATOMIC_WRITES=3 (0..2 is valid) |
| 118 |
} elsif ($name eq 'test/tp') { |
| 119 |
$flags= 0x880 # 10.1 PAGE_COMPRESSED, PAGE_COMPRESSION_LEVEL=8 |
| 120 |
# (in 10.2.2 through 10.2.6, this is interpreted as |
| 121 |
# PAGE_COMPRESSION_LEVEL=4 without PAGE_COMPRESSED |
| 122 |
# but with SHARED_SPACE, which should be invalid) |
| 123 |
} |
| 124 |
|
| 125 |
substr($page,$offset+$start,$end-$start)= pack( |
| 126 |
"N", $flags ^ |
| 127 |
unpack("N", substr($page,$offset+$start,$end-$start))) |
| 128 |
if $flags; |
| 129 |
} |
| 130 |
# Corrupt SYS_TABLES.MIX_LEN (ignored for ROW_FORMAT=REDUNDANT) |
| 131 |
if ($i == 7 && $name eq 'test/tr') |
| 132 |
{ |
| 133 |
substr($page,$offset+$start,$end-$start)= chr(255) x 4; |
| 134 |
} |
| 135 |
$start= $end & 0x7f; |
| 136 |
} |
| 137 |
print ")\n"; |
| 138 |
} |
| 139 |
my $polynomial = 0x82f63b78; # CRC-32C |
| 140 |
if ($full_crc32) |
| 141 |
{ |
| 142 |
my $ck = mycrc32(substr($page, 0, $ps-4), 0, $polynomial); |
| 143 |
substr($page, $ps-4, 4) = pack("N", $ck); |
| 144 |
} |
| 145 |
else |
| 146 |
{ |
| 147 |
my $ck= pack("N",mycrc32(substr($page, 4, 22), 0, $polynomial) ^ |
| 148 |
mycrc32(substr($page, 38, $ps - 38 - 8), 0, $polynomial)); |
| 149 |
substr($page,0,4)=$ck; |
| 150 |
substr($page,$ps-8,4)=$ck; |
| 151 |
} |
| 152 |
sysseek(FILE, $sys_tables_root*$ps, 0) || die "Unable to seek $file"; |
| 153 |
syswrite(FILE, $page, $ps)==$ps || die "Unable to write $file\n"; |
| 154 |
close(FILE) || die "Unable to close $file\n"; |
| 155 |
EOF |
| 156 |
--source include/start_mysqld.inc |
| 157 |
|
| 158 |
--error ER_NO_SUCH_TABLE_IN_ENGINE |
| 159 |
SHOW CREATE TABLE tr; |
| 160 |
--error ER_NO_SUCH_TABLE_IN_ENGINE |
| 161 |
SHOW CREATE TABLE tc; |
| 162 |
--error ER_NO_SUCH_TABLE_IN_ENGINE |
| 163 |
SELECT * FROM tc; |
| 164 |
--error ER_GET_ERRNO |
| 165 |
SHOW CREATE TABLE td; |
| 166 |
--error ER_GET_ERRNO |
| 167 |
SELECT * FROM td; |
| 168 |
# This table was converted to NO_ROLLBACK due to the SYS_TABLES.TYPE change. |
| 169 |
SHOW CREATE TABLE tz; |
| 170 |
BEGIN; |
| 171 |
INSERT INTO tz VALUES(42); |
| 172 |
ROLLBACK; |
| 173 |
SELECT * FROM tz; |
| 174 |
--error ER_NO_SUCH_TABLE_IN_ENGINE |
| 175 |
SHOW CREATE TABLE tp; |
| 176 |
|
| 177 |
--source include/shutdown_mysqld.inc |
| 178 |
|
| 179 |
let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err; |
| 180 |
--let SEARCH_PATTERN= InnoDB: Table test/t[cp] in InnoDB data dictionary contains invalid flags\. SYS_TABLES\.TYPE=(129|289|3873|1232[13]) SYS_TABLES\.N_COLS=2147483649 |
| 181 |
--source include/search_pattern_in_file.inc |
| 182 |
--let SEARCH_PATTERN= InnoDB: Table test/tr in InnoDB data dictionary contains invalid flags\. SYS_TABLES\.TYPE=65 SYS_TABLES\.MIX_LEN=4294967295\b |
| 183 |
--source include/search_pattern_in_file.inc |
| 184 |
|
| 185 |
# Restore the backup of the corrupted SYS_TABLES clustered index root page |
| 186 |
--perl |
| 187 |
use strict; |
| 188 |
my $ps= $ENV{INNODB_PAGE_SIZE}; |
| 189 |
my $file= "$ENV{bugdir}/ibdata1"; |
| 190 |
open(FILE, "+<", $file) || die "Unable to open $file\n"; |
| 191 |
open(BACKUP, "<$ENV{bugdir}/sys_tables.bin") || die "Unable to open backup\n"; |
| 192 |
# Read DICT_HDR_TABLES, the root page number of CLUST_IND (SYS_TABLES.NAME). |
| 193 |
sysseek(FILE, 7*$ps+38+32, 0) || die "Unable to seek $file"; |
| 194 |
die "Unable to read $file\n" unless sysread(FILE, $_, 4) == 4; |
| 195 |
my $sys_tables_root = unpack("N", $_); |
| 196 |
print "Restoring SYS_TABLES clustered index root page ($sys_tables_root)\n"; |
| 197 |
sysseek(FILE, $sys_tables_root*$ps, 0) || die "Unable to seek $file"; |
| 198 |
die "Unable to read backup\n" unless sysread(BACKUP, $_, $ps) == $ps; |
| 199 |
die "Unable to restore backup\n" unless syswrite(FILE, $_, $ps) == $ps; |
| 200 |
close(BACKUP); |
| 201 |
close(FILE) || die "Unable to close $file\n"; |
| 202 |
EOF |
| 203 |
--source include/start_mysqld.inc |
| 204 |
|
| 205 |
SHOW CREATE TABLE tr; |
| 206 |
SHOW CREATE TABLE tc; |
| 207 |
SHOW CREATE TABLE td; |
| 208 |
SHOW CREATE TABLE tz; |
| 209 |
SHOW CREATE TABLE tp; |
| 210 |
|
| 211 |
BEGIN; |
| 212 |
INSERT INTO tr VALUES(1); |
| 213 |
INSERT INTO tc VALUES(1); |
| 214 |
INSERT INTO td VALUES(1); |
| 215 |
INSERT INTO tz VALUES(1); |
| 216 |
INSERT INTO tp VALUES(1); |
| 217 |
ROLLBACK; |
| 218 |
|
| 219 |
SELECT * FROM tr; |
| 220 |
SELECT * FROM tc; |
| 221 |
SELECT * FROM td; |
| 222 |
# SELECT * FROM tz; |
| 223 |
SELECT * FROM tp; |
| 224 |
|
| 225 |
DROP TABLE tr,tc,td,tz,tp; |
| 226 |
|
| 227 |
--let $restart_parameters= |
| 228 |
--source include/restart_mysqld.inc |
| 229 |
|
| 230 |
--error 0,1 |
| 231 |
--remove_file $bugdir/ibtmp1 |
| 232 |
--error 0,1 |
| 233 |
--remove_file $bugdir/ib_buffer_pool |
| 234 |
|
| 235 |
--list_files $bugdir |
| 236 |
--remove_files_wildcard $bugdir |
| 237 |
--rmdir $bugdir |
| 238 |
--rmdir $undodir |
| 239 |
|
| 240 |
call mtr.add_suppression("ERROR HY000: Can't create table `test`.`t1`"); |
| 241 |
--error ER_CANT_CREATE_TABLE |
| 242 |
CREATE TABLE t1(f1 INT, f2 VARCHAR(1), KEY k1(f2), |
| 243 |
FULLTEXT KEY(f2), |
| 244 |
FOREIGN KEY (f2) REFERENCES t1(f3))ENGINE=InnoDB; |
| 245 |
|
| 246 |
--echo # |
| 247 |
--echo # MDEV-23199 page_compression flag is missing |
| 248 |
--echo # for full_crc32 tablespace |
| 249 |
--echo # |
| 250 |
|
| 251 |
CREATE TABLE t1(f1 BIGINT PRIMARY KEY)ENGINE=InnoDB; |
| 252 |
INSERT INTO t1 VALUES(1); |
| 253 |
ALTER TABLE t1 PAGE_COMPRESSED = 1; |
| 254 |
INSERT INTO t1 VALUES(2); |
| 255 |
let $shutdown_timeout = 0; |
| 256 |
--source include/restart_mysqld.inc |
| 257 |
DROP TABLE t1; |
| 258 |
|
| 259 |
--echo # |
| 260 |
--echo # MDEV-38079 Crash recovery fails after ALTER TABLEā¦PAGE_COMPRESSED=1 |
| 261 |
--echo # |
| 262 |
SET @df_row = @@global.INNODB_DEFAULT_ROW_FORMAT; |
| 263 |
SET GLOBAL INNODB_DEFAULT_ROW_FORMAT=REDUNDANT; |
| 264 |
CREATE TABLE t1 (c CHAR(1)) ENGINE=InnoDB; |
| 265 |
--error ER_ILLEGAL_HA_CREATE_OPTION |
| 266 |
ALTER TABLE t1 PAGE_COMPRESSED=1, ALGORITHM=INPLACE; |
| 267 |
--error ER_CANT_CREATE_TABLE |
| 268 |
ALTER TABLE t1 PAGE_COMPRESSED=1, ALGORITHM=COPY; |
| 269 |
SET GLOBAL INNODB_DEFAULT_ROW_FORMAT=compact; |
| 270 |
ALTER TABLE t1 PAGE_COMPRESSED=1, ALGORITHM=COPY; |
| 271 |
DROP TABLE t1; |
| 272 |
SET @@global.INNODB_DEFAULT_ROW_FORMAT = @df_row; |