Debian Codegraph @

mysql-test/suite/innodb/t/row_format_redundant.test

raw
1 --source include/have_innodb.inc
2 # Embedded mode doesn't allow restarting
3 --source include/not_embedded.inc
4 --source include/have_sequence.inc
5
6 --disable_query_log
7 call mtr.add_suppression("InnoDB: Table `mysql`\\.`innodb_table_stats` not found");
8 call mtr.add_suppression("InnoDB: Table test/t1 in InnoDB data dictionary contains invalid flags. SYS_TABLES\\.TYPE=1 SYS_TABLES\\.MIX_LEN=511\\r?$");
9 call mtr.add_suppression("InnoDB: Parent table of FTS auxiliary table test/FTS_.* not found");
10 call mtr.add_suppression("InnoDB: Cannot open table test/t1 from the internal data dictionary");
11 call mtr.add_suppression("InnoDB: Table `test`.`t1` does not exist in the InnoDB internal data dictionary though MariaDB is trying to (rename|drop)");
12 FLUSH TABLES;
13 --enable_query_log
14
15 let INNODB_PAGE_SIZE=`select @@innodb_page_size`;
16
17 let bugdir= $MYSQLTEST_VARDIR/tmp/row_format_redundant;
18 --mkdir $bugdir
19 let undodir= $MYSQLTEST_VARDIR/tmp/undo_dir;
20 --mkdir $undodir
21
22 --let SEARCH_FILE = $MYSQLTEST_VARDIR/log/mysqld.1.err
23
24 --let $d=--innodb-data-home-dir=$bugdir --innodb-log-group-home-dir=$bugdir
25 --let $d=$d --innodb-data-file-path=ibdata1:1M:autoextend
26 --let $d=$d --innodb_undo_directory=$undodir --innodb-undo-tablespaces=0 --innodb-stats-persistent=0
27 --let $restart_parameters= $d
28 # Ensure that any DDL records from previous tests have been purged.
29 SET GLOBAL innodb_fast_shutdown=0;
30 --source include/restart_mysqld.inc
31
32 --echo #
33 --echo # Bug#21644827 - FTS, ASSERT !SRV_READ_ONLY_MODE || M_IMPL.M_LOG_MODE ==
34 --echo # MTR_LOG_NO_REDO
35 --echo #
36
37 create table t1 (a int not null, d varchar(15) not null, b
38 varchar(198) not null, c char(156)) engine=InnoDB
39 row_format=redundant;
40
41 create temporary table t like t1;
42
43 insert into t values(123, 'abcdef', 'jghikl', 'mnop');
44 insert into t values(456, 'abcdef', 'jghikl', 'mnop');
45 insert into t values(789, 'abcdef', 'jghikl', 'mnop');
46 insert into t values(134, 'kasdfsdsadf', 'adfjlasdkfjasd', 'adfsadflkasdasdfljasdf');
47
48 insert into t1 select a,d,b,c from t, seq_1_to_1024;
49
50 SET GLOBAL innodb_file_per_table=OFF;
51 create table t2 (a int not null, d varchar(15) not null, b
52 varchar(198) not null, c char(156), fulltext ftsic(c)) engine=InnoDB
53 row_format=redundant;
54
55 insert into t2 select a,d,b,c from t, seq_1_to_1024;
56
57 create table t3 (a int not null, d varchar(15) not null, b varchar(198),
58 c varchar(150), index k1(c(99), b(56)), index k2(b(5), c(10))) engine=InnoDB
59 row_format=redundant;
60
61 insert into t3 values(444, 'dddd', 'bbbbb', 'aaaaa');
62 insert into t3 values(555, 'eeee', 'ccccc', 'aaaaa');
63
64 --let $restart_parameters= $d --innodb-read-only
65 --source include/restart_mysqld.inc
66
67 SELECT COUNT(*) FROM t1;
68 SELECT COUNT(*) FROM t2;
69 SELECT COUNT(*) FROM t3;
70
71 --error ER_OPEN_AS_READONLY
72 TRUNCATE TABLE t1;
73 --error ER_OPEN_AS_READONLY
74 TRUNCATE TABLE t2;
75 --error ER_OPEN_AS_READONLY
76 TRUNCATE TABLE t3;
77
78 --let $restart_parameters= $d --skip-innodb-fast-shutdown
79 --source include/restart_mysqld.inc
80
81 TRUNCATE TABLE t1;
82 TRUNCATE TABLE t2;
83 TRUNCATE TABLE t3;
84
85 --source include/shutdown_mysqld.inc
86 --perl
87 use strict;
88 do "$ENV{MTR_SUITE_DIR}/include/crc32.pl";
89 my $ps= $ENV{INNODB_PAGE_SIZE};
90 my $file= "$ENV{bugdir}/ibdata1";
91 open(FILE, "+<", $file) || die "Unable to open $file\n";
92 die "Unable to read $file" unless sysread(FILE, $_, $ps) == $ps;
93 my $full_crc32 = unpack("N",substr($_,54,4)) & 0x10; # FIL_SPACE_FLAGS;
94 sysseek(FILE, 0, 0) || die "Unable to seek $file";
95 # Read DICT_HDR_TABLES, the root page number of CLUST_IND (SYS_TABLES.NAME).
96 sysseek(FILE, 7*$ps+38+32, 0) || die "Unable to seek $file";
97 die "Unable to read $file" unless sysread(FILE, $_, 4) == 4;
98 my $sys_tables_root = unpack("N", $_);
99 my $page;
100 sysseek(FILE, $sys_tables_root*$ps, 0) || die "Unable to seek $file";
101 die "Unable to read $file" unless sysread(FILE, $page, $ps) == $ps;
102 for (my $offset= 0x65; $offset;
103 $offset= unpack("n", substr($page,$offset-2,2)))
104 {
105 my $n_fields= unpack("n", substr($page,$offset-4,2)) >> 1 & 0x3ff;
106 my $start= 0;
107 my $end= unpack("C", substr($page, $offset-7, 1));
108 my $name= substr($page,$offset+$start,$end-$start);
109 for (my $i= 0; $i < $n_fields; $i++) {
110 my $end= unpack("C", substr($page, $offset-7-$i, 1));
111 # Corrupt SYS_TABLES.MIX_LEN (ignored for ROW_FORMAT=REDUNDANT)
112 if ($i == 7 && $name =~ '^test/t[123]')
113 {
114 print "corrupted SYS_TABLES.MIX_LEN for $name\n";
115 substr($page,$offset+$start,$end-$start)= pack("N", 511);
116 }
117 $start= $end & 0x7f;
118 }
119 }
120 my $polynomial = 0x82f63b78; # CRC-32C
121 if ($full_crc32) {
122 my $ck = mycrc32(substr($page, 0, $ps-4), 0, $polynomial);
123 substr($page, $ps-4, 4) = pack("N", $ck);
124 } else {
125 my $ck= pack("N",mycrc32(substr($page, 4, 22), 0, $polynomial) ^
126 mycrc32(substr($page, 38, $ps - 38 - 8), 0, $polynomial));
127 substr($page,0,4)=$ck;
128 substr($page,$ps-8,4)=$ck;
129 }
130
131 sysseek(FILE, $sys_tables_root*$ps, 0) || die "Unable to seek $file";
132 syswrite(FILE, $page, $ps)==$ps || die "Unable to write $file\n";
133 close(FILE) || die "Unable to close $file\n";
134 EOF
135
136 --source include/start_mysqld.inc
137 --error ER_NO_SUCH_TABLE_IN_ENGINE
138 TRUNCATE TABLE t1;
139 TRUNCATE TABLE t2;
140 TRUNCATE TABLE t3;
141 --error ER_NO_SUCH_TABLE_IN_ENGINE
142 SELECT COUNT(*) FROM t1;
143 SELECT COUNT(*) FROM t2;
144 SELECT COUNT(*) FROM t3;
145 --error ER_ERROR_ON_RENAME
146 RENAME TABLE t1 TO tee_one;
147 DROP TABLE t1;
148 DROP TABLE t2,t3;
149
150 --let SEARCH_PATTERN= \[ERROR\] InnoDB: Table test/t1 in InnoDB data dictionary contains invalid flags\. SYS_TABLES\.TYPE=1 SYS_TABLES\.MIX_LEN=511\b.*
151 --source include/search_pattern_in_file.inc
152
153 --let $restart_parameters=
154 --source include/restart_mysqld.inc
155
156 --list_files $bugdir
157 --remove_files_wildcard $bugdir
158 --rmdir $bugdir
159 --rmdir $undodir
160
161 # Remove the data file, because DROP TABLE skipped it for the "corrupted" table
162 --let MYSQLD_DATADIR=`select @@datadir`
163 --remove_file $MYSQLD_DATADIR/test/t1.ibd
164 --list_files $MYSQLD_DATADIR/test