File: innodb_bug14147491.test

package info (click to toggle)
mariadb-10.1 10.1.45-0%2Bdeb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 476,916 kB
  • sloc: cpp: 1,124,656; ansic: 871,843; perl: 52,917; sh: 40,078; pascal: 35,370; javascript: 15,555; yacc: 14,728; ruby: 8,684; xml: 5,377; sql: 3,490; makefile: 2,934; python: 1,970; java: 1,691; asm: 837; lex: 757; php: 22; sed: 16
file content (80 lines) | stat: -rw-r--r-- 2,071 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#
# Test opening a corrupted table.
#

-- source include/not_encrypted.inc

call mtr.add_suppression("InnoDB: Table \"test\".\"t1\" is corrupted. Please drop the table and recreate.");
call mtr.add_suppression("InnoDB: Cannot open table test/t1 from the internal data dictionary of InnoDB though the .frm file for the table exists. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting.html for how you can resolve the problem.");
call mtr.add_suppression("InnoDB: Database page corruption on disk or a failed file read of tablespace test/t1 page  \[page id: space=[0-9]+, page number=[0-9]+\]. You may have to recover from a backup.");

# Don't test under embedded
source include/not_embedded.inc;
# Require InnoDB
source include/have_innodb.inc;

--echo # Create and populate the table to be corrupted

--disable_warnings
set global innodb_file_per_table=ON;
--enable_warnings

CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT) ENGINE=InnoDB;
INSERT INTO t1 (b) VALUES ('corrupt me');
--disable_query_log
--let $i = 10
while ($i)
{
  INSERT INTO t1 (b) VALUES (REPEAT('abcdefghijklmnopqrstuvwxyz', 100));
  dec $i;
}
--enable_query_log
INSERT INTO t1 (b) VALUES ('corrupt me');

let $MYSQLD_DATADIR=`select @@datadir`;
let t1_IBD = $MYSQLD_DATADIR/test/t1.ibd;

--source include/shutdown_mysqld.inc

--echo # Corrupt the table

perl;
use strict;
use warnings;
use Fcntl qw(:DEFAULT :seek);

my $ibd_file = $ENV{'t1_IBD'};

my $chunk;
my $len;

sysopen IBD_FILE, $ibd_file, O_RDWR || die "Unable to open $ibd_file";

while ($len = sysread IBD_FILE, $chunk, 1024)
{
  if ($chunk =~ s/corrupt me/korrupt me/)
  {
    print "Munged a string.\n";
    sysseek IBD_FILE, -$len, SEEK_CUR;
    syswrite IBD_FILE, $chunk, $len;
  }
}

close IBD_FILE;
EOF

--source include/start_mysqld.inc

--echo # Now t1 is corrupted but we should not crash

--error 1712,1932
SELECT * FROM t1;

--error 1034,1712,1932
INSERT INTO t1(b) VALUES('abcdef');

--error 1712,1932
UPDATE t1 set b = 'deadbeef' where a = 1;

--echo # Cleanup, this must be possible
DROP TABLE t1;