Debian Codegraph @

mysql-test/suite/innodb/r/import_cfg_corrupt.result

raw
1 #
2 # MDEV-39278 Validate .cfg file parser string lengths
3 #
4 # Test that IMPORT TABLESPACE rejects .cfg files with
5 # invalid string lengths in the metadata header.
6 #
7 call mtr.add_suppression("InnoDB: Importing tablespace for table `test`\\.`t1`");
8 call mtr.add_suppression("Index for table 't1' is corrupt; try to repair it");
9 call mtr.add_suppression("InnoDB: Discarding tablespace of table `test`\\.`t1`");
10 # Export a valid .ibd/.cfg pair to reuse across tests.
11 CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
12 INSERT INTO t1 VALUES (1), (2), (3);
13 FLUSH TABLES t1 FOR EXPORT;
14 UNLOCK TABLES;
15 DROP TABLE t1;
16 #
17 # Test 1: Corrupt hostname length in .cfg
18 # .cfg format: [4 bytes version][4 bytes hostname_len]...
19 # Patch offset 4 to 0x00001000 (4096), exceeding
20 # HOSTNAME_LENGTH + 1 (256).
21 #
22 CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
23 ALTER TABLE t1 DISCARD TABLESPACE;
24 ALTER TABLE t1 IMPORT TABLESPACE;
25 ERROR HY000: IO Read error: (0, Invalid argument) while reading .cfg hostname length.
26 DROP TABLE t1;
27 #
28 # Test 2: Zero hostname length in .cfg
29 #
30 CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
31 ALTER TABLE t1 DISCARD TABLESPACE;
32 ALTER TABLE t1 IMPORT TABLESPACE;
33 ERROR HY000: IO Read error: (0, Invalid argument) while reading .cfg hostname length.
34 DROP TABLE t1;
35 #
36 # Test 3: Table name length zero in .cfg
37 #
38 CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
39 ALTER TABLE t1 DISCARD TABLESPACE;
40 ALTER TABLE t1 IMPORT TABLESPACE;
41 ERROR HY000: IO Read error: (0, Invalid argument) while reading .cfg table name length.
42 DROP TABLE t1;
43 #
44 # Test 4: Hostname length just over limit (257)
45 # HOSTNAME_LENGTH + 1 = 256 is the max valid value.
46 # 257 should be rejected.
47 #
48 CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
49 ALTER TABLE t1 DISCARD TABLESPACE;
50 ALTER TABLE t1 IMPORT TABLESPACE;
51 ERROR HY000: IO Read error: (0, Invalid argument) while reading .cfg hostname length.
52 DROP TABLE t1;
53 #
54 # Test 5: Hostname length 0xFFFFFFFF (max uint32)
55 #
56 CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
57 ALTER TABLE t1 DISCARD TABLESPACE;
58 ALTER TABLE t1 IMPORT TABLESPACE;
59 ERROR HY000: IO Read error: (0, Invalid argument) while reading .cfg hostname length.
60 DROP TABLE t1;
61 #
62 # Test 6: Corrupt table name length in .cfg
63 # The table name length field follows the hostname string.
64 # We need to find and patch it dynamically.
65 #
66 CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
67 ALTER TABLE t1 DISCARD TABLESPACE;
68 ALTER TABLE t1 IMPORT TABLESPACE;
69 ERROR HY000: IO Read error: (0, Invalid argument) while reading .cfg table name length.
70 DROP TABLE t1;
71 # End of 10.11 tests