Debian Codegraph @

mysql-test/suite/innodb_zip/t/innochecksum_3.test

raw
1 #************************************************************
2 # WL6045:Improve Innochecksum
3 #************************************************************
4 # Run this a as big test, otherwise MTR's check-warnings times out
5 --source include/big_test.inc
6 --source include/have_innodb_max_16k.inc
7
8 # Valgrind would complain about memory leaks when we crash on purpose.
9 --source include/not_valgrind.inc
10
11 # Avoid CrashReporter popup on Mac.
12 --source include/not_crashrep.inc
13
14 --echo # Set the environmental variables
15 let MYSQLD_BASEDIR= `SELECT @@basedir`;
16 let MYSQLD_DATADIR= `SELECT @@datadir`;
17 let SEARCH_FILE= $MYSQLTEST_VARDIR/log/my_restart.err;
18 call mtr.add_suppression("Unable to read tablespace .* page no .* into the buffer pool after 100 attempts");
19 call mtr.add_suppression("innodb_checksum_algorithm is set to");
20
21 SET GLOBAL innodb_file_per_table=on;
22
23 --echo [1]: Further Test are for rewrite checksum (innodb|crc32|none) for all ibd file & start the server.
24
25 CREATE TABLE tab1 (pk INTEGER NOT NULL PRIMARY KEY,
26 linestring_key GEOMETRY NOT NULL,
27 linestring_nokey GEOMETRY NOT NULL)
28 ENGINE=InnoDB ;
29
30 INSERT INTO tab1 (pk, linestring_key, linestring_nokey)
31 VALUES (1, ST_GeomFromText('POINT(10 10) '), ST_GeomFromText('POINT(10 10) '));
32
33 --error ER_WRONG_SUB_KEY
34 CREATE INDEX linestring_index ON tab1(linestring_nokey(5));
35 --error ER_WRONG_SUB_KEY
36 ALTER TABLE tab1 ADD KEY (linestring_key(5));
37
38 --echo # create a compressed table
39 CREATE TABLE tab2(col_1 CHAR (255) ,
40 col_2 VARCHAR (255), col_3 longtext,
41 col_4 longtext,col_5 longtext,
42 col_6 longtext , col_7 int )
43 engine = innodb row_format=compressed key_block_size=4;
44
45 CREATE INDEX idx1 ON tab2(col_3(10));
46 CREATE INDEX idx2 ON tab2(col_4(10));
47 CREATE INDEX idx3 ON tab2(col_5(10));
48
49 # load the with repeat function
50 SET @col_1 = repeat('a', 5);
51 SET @col_2 = repeat('b', 20);
52 SET @col_3 = repeat('c', 100);
53 SET @col_4 = repeat('d', 100);
54 SET @col_5 = repeat('e', 100);
55 SET @col_6 = repeat('f', 100);
56
57 # insert 5 records
58 let $i = 5;
59 while ($i) {
60 eval INSERT INTO tab2(col_1,col_2,col_3,col_4,col_5,col_6,col_7)
61 VALUES (@col_1,@col_2,@col_3,@col_4,@cl_5,@col_6,$i);
62 dec $i;
63 }
64
65 --disable_result_log
66 SELECT * FROM tab2 ORDER BY col_7;
67
68 --echo # stop the server
69 --source include/shutdown_mysqld.inc
70
71 --echo [1(a)]: Rewrite into new checksum=InnoDB for all *.ibd file and ibdata1
72 --exec $INNOCHECKSUM --write=InnoDB $MYSQLD_DATADIR/test/tab1.ibd
73 --exec $INNOCHECKSUM --write=InnoDB $MYSQLD_DATADIR/test/tab2.ibd
74 --exec $INNOCHECKSUM --write=InnoDB $MYSQLD_DATADIR/ibdata1
75 perl;
76 foreach (glob("$ENV{MYSQLD_DATADIR}/*/*.ibd")) {
77 system("$ENV{INNOCHECKSUM} --no-check --write=InnoDB $_")
78 }
79 EOF
80
81 --echo : start the server with innodb_checksum_algorithm=strict_innodb
82 --let restart_parameters=restart: --innodb_checksum_algorithm=strict_innodb --default_storage_engine=InnoDB
83 --source include/start_mysqld.inc
84
85 INSERT INTO tab1 (pk, linestring_key, linestring_nokey)
86 VALUES (2, ST_GeomFromText('LINESTRING(10 10,20 20,30 30)'), ST_GeomFromText('LINESTRING(10 10,20 20,30 30)'));
87
88 # load the with repeat function
89 SET @col_1 = repeat('a', 5);
90 SET @col_2 = repeat('b', 20);
91 SET @col_3 = repeat('c', 100);
92 SET @col_4 = repeat('d', 100);
93 SET @col_5 = repeat('e', 100);
94 SET @col_6 = repeat('f', 100);
95
96 # check the table status is GOOD with DML
97 let $i = 6;
98 eval INSERT INTO tab2(col_1,col_2,col_3,col_4,col_5,col_6,col_7)
99 VALUES (@col_1,@col_2,@col_3,@col_4,@cl_5,@col_6,$i);
100
101 -- disable_result_log
102 SELECT pk,ST_AsText(linestring_key),ST_AsText(linestring_nokey)
103 FROM tab1 ORDER BY pk;
104
105 -- disable_result_log
106 SELECT * FROM tab2 ORDER BY col_7;
107
108 --echo # stop the server
109 --source include/shutdown_mysqld.inc
110
111 --echo [1(b)]: Rewrite into new checksum=crc32 for all *.ibd file and ibdata1
112 --exec $INNOCHECKSUM --write=CRC32 $MYSQLD_DATADIR/test/tab1.ibd
113 --exec $INNOCHECKSUM --write=CRC32 $MYSQLD_DATADIR/test/tab2.ibd
114 --exec $INNOCHECKSUM --write=CRC32 $MYSQLD_DATADIR/ibdata1
115 perl;
116 foreach (glob("$ENV{MYSQLD_DATADIR}/*/*.ibd")) {
117 system("$ENV{INNOCHECKSUM} --no-check --write=crc32 $_")
118 }
119 EOF
120
121 --echo # start the server with innodb_checksum_algorithm=strict_crc32
122 --let restart_parameters=restart: --innodb_checksum_algorithm=strict_crc32 --default_storage_engine=InnoDB
123 --source include/start_mysqld.inc
124
125 # check the table status is GOOD with DML
126 INSERT INTO tab1 (pk, linestring_key, linestring_nokey)
127 VALUES (3, ST_GeomFromText('POLYGON((0 0,5 5,10 10,15 15,0 0),(10 10,20 20,30 30,40 40,10 10))'),
128 ST_GeomFromText('POLYGON((0 0,5 5,10 10,15 15,0 0),(10 10,20 20,30 30,40 40,10 10))'));
129
130 # load the with repeat function
131 SET @col_1 = repeat('g', 5);
132 SET @col_2 = repeat('h', 20);
133 SET @col_3 = repeat('i', 100);
134 SET @col_4 = repeat('j', 100);
135 SET @col_5 = repeat('k', 100);
136 SET @col_6 = repeat('l', 100);
137
138 # check the table status is GOOD with DML
139 let $i = 7;
140 eval INSERT INTO tab2(col_1,col_2,col_3,col_4,col_5,col_6,col_7)
141 VALUES (@col_1,@col_2,@col_3,@col_4,@cl_5,@col_6,$i);
142
143 # check the records from table
144 -- disable_result_log
145 SELECT pk,ST_AsText(linestring_key),ST_AsText(linestring_nokey)
146 FROM tab1 ORDER BY pk;
147
148 -- disable_result_log
149 SELECT * FROM tab2 ORDER BY col_7;
150
151 --echo # stop the server
152 --source include/shutdown_mysqld.inc
153
154 --echo [1(c)]: Rewrite into new checksum=none for all *.ibd file, ibdata1 and mysql.ibd
155 --exec $INNOCHECKSUM --write=none $MYSQLD_DATADIR/test/tab1.ibd
156 --exec $INNOCHECKSUM --write=none $MYSQLD_DATADIR/test/tab2.ibd
157 --exec $INNOCHECKSUM --write=none $MYSQLD_DATADIR/ibdata1
158 --exec $INNOCHECKSUM --write=none $MYSQLD_DATADIR/mysql.ibd
159 perl;
160 foreach (glob("$ENV{MYSQLD_DATADIR}/undo*")) {
161 system("$ENV{INNOCHECKSUM} --no-check --write=NONE $_")
162 }
163 foreach (glob("$ENV{MYSQLD_DATADIR}/*/*.ibd")) {
164 system("$ENV{INNOCHECKSUM} --no-check --write=NONE $_")
165 }
166 EOF
167
168 let $restart_parameters = restart: --innodb_checksum_algorithm=strict_none --default_storage_engine=InnoDB;
169 --source include/start_mysqld.inc
170
171 # check the table status is GOOD with DML
172 INSERT INTO tab1 (pk, linestring_key, linestring_nokey)
173 VALUES (4, ST_GeomFromText('MULTIPOINT(0 0,5 5,10 10,20 20) '), ST_GeomFromText('MULTIPOINT(0 0,5 5,10 10,20 20) '));
174
175 # load the with repeat function
176 SET @col_1 = repeat('m', 5);
177 SET @col_2 = repeat('n', 20);
178 SET @col_3 = repeat('o', 100);
179 SET @col_4 = repeat('p', 100);
180 SET @col_5 = repeat('q', 100);
181 SET @col_6 = repeat('r', 100);
182
183 # check the table status is GOOD with DML
184 let $i = 8;
185 eval INSERT INTO tab2(col_1,col_2,col_3,col_4,col_5,col_6,col_7)
186 VALUES (@col_1,@col_2,@col_3,@col_4,@cl_5,@col_6,$i);
187
188 # check the records from table
189 -- disable_result_log
190 SELECT pk,ST_AsText(linestring_key),ST_AsText(linestring_nokey)
191 FROM tab1 ORDER BY pk;
192
193 --disable_result_log
194 SELECT * FROM tab2 ORDER BY col_7;
195 --enable_result_log
196
197 --echo # stop the server
198 --source include/shutdown_mysqld.inc
199
200 --echo [2]: Check the page type summary with shortform for tab1.ibd
201 --replace_regex /File.*.ibd/File::tab1.ibd/ /[0-9]+/#/
202 --exec $INNOCHECKSUM -S $MYSQLD_DATADIR/test/tab1.ibd 2>$MYSQLTEST_VARDIR/tmp/page_summary_short.txt
203
204 --echo [3]: Check the page type summary with longform for tab1.ibd
205 --replace_regex /File.*.ibd/File::tab1.ibd/ /[0-9]+/#/
206 --exec $INNOCHECKSUM --page-type-summary $MYSQLD_DATADIR/test/tab1.ibd 2>$MYSQLTEST_VARDIR/tmp/page_summary_long.txt
207
208 --remove_file $MYSQLTEST_VARDIR/tmp/page_summary_short.txt
209 --remove_file $MYSQLTEST_VARDIR/tmp/page_summary_long.txt
210 --echo [4]: Page type dump for with longform for tab1.ibd
211 --replace_result $MYSQLD_DATADIR MYSQL_DATADIR
212 --exec $INNOCHECKSUM --page-type-dump $MYSQLTEST_VARDIR/tmp/dump.txt $MYSQLD_DATADIR/test/tab1.ibd
213
214 perl;
215 use strict;
216 use warnings;
217 use File::Copy;
218 my $dir = $ENV{'MYSQLTEST_VARDIR'} or die $!;
219 my $datadir=$ENV{'MYSQLD_DATADIR'};
220 $datadir =~ s/\\/\//g;
221 opendir(DIR, $dir) or die $!;
222 my $file= 'dump.txt';
223 # open file in write mode
224 open IN_FILE,"<", "$dir/tmp/$file" or die $!;
225 open OUT_FILE, ">", "$dir/tmp/tmpfile" or die $!;
226 while(<IN_FILE>)
227 {
228 # Replace the integers to # and complete file path to file name only.
229 # We exclude Inode Page here because this will cause result content
230 # mismatch on 4k page size
231 unless (/Inode page/) {
232 s/\\/\//g;
233 s/$datadir/MYSQLD_DATADIR/g;
234 s/\s*[1-9][0-9]*\s*/#/g;
235 s/\s+0\s+/0/g;
236 print OUT_FILE;
237 }
238 }
239 close(IN_FILE);
240 close(OUT_FILE);
241 # move the new content from tmp file to the orginal file.
242 move ("$dir/tmp/tmpfile", "$dir/tmp/$file");
243 closedir(DIR);
244 EOF
245
246 --echo # Print the contents stored in dump.txt
247 cat_file $MYSQLTEST_VARDIR/tmp/dump.txt;
248 --remove_file $MYSQLTEST_VARDIR/tmp/dump.txt
249
250 # Page type dump for ibdata1
251 --exec $INNOCHECKSUM -v --page-type-dump $MYSQLTEST_VARDIR/tmp/dump.txt $MYSQLD_DATADIR/ibdata1
252 --file_exists $MYSQLTEST_VARDIR/tmp/dump.txt
253 --remove_file $MYSQLTEST_VARDIR/tmp/dump.txt
254
255 --echo [5]: Page type dump for with shortform for tab1.ibd
256 --exec $INNOCHECKSUM -D $MYSQLTEST_VARDIR/tmp/dump.txt $MYSQLD_DATADIR/test/tab1.ibd
257
258 perl;
259 use strict;
260 use warnings;
261 use File::Copy;
262 my $dir = $ENV{'MYSQLTEST_VARDIR'};
263 my $datadir=$ENV{'MYSQLD_DATADIR'};
264 $datadir =~ s/\\/\//g;
265 opendir(DIR, $dir) or die $!;
266 my $file= 'dump.txt';
267 # open file in write mode
268 open IN_FILE,"<", "$dir/tmp/$file" or die $!;
269 open OUT_FILE, ">", "$dir/tmp/tmpfile" or die $!;
270 while(<IN_FILE>)
271 {
272 # Replace the integers to # and complete file path to file name only.
273 # We exclude Inode Page here because this will cause result content
274 # mismatch on 4k page size
275 unless (/Inode page/) {
276 s/\\/\//g;
277 s/$datadir/MYSQLD_DATADIR/g;
278 s/\s*[1-9][0-9]*\s*/#/g;
279 s/\s+0\s+/0/g;
280 print OUT_FILE;
281 }
282 }
283 close(IN_FILE);
284 close(OUT_FILE);
285 # move the new content from tmp file to the orginal file.
286 move ("$dir/tmp/tmpfile", "$dir/tmp/$file");
287 closedir(DIR);
288 EOF
289
290 # Print the contents stored in dump.txt
291 cat_file $MYSQLTEST_VARDIR/tmp/dump.txt;
292 --remove_file $MYSQLTEST_VARDIR/tmp/dump.txt
293
294 --echo [6]: check the valid lower bound values for option
295 --echo # allow-mismatches,page,start-page,end-page
296 --exec $INNOCHECKSUM --allow-mismatches=0 $MYSQLD_DATADIR/test/tab1.ibd
297 --exec $INNOCHECKSUM -a 0 $MYSQLD_DATADIR/test/tab1.ibd
298 --exec $INNOCHECKSUM --page=0 $MYSQLD_DATADIR/test/tab1.ibd
299 --exec $INNOCHECKSUM -p 0 $MYSQLD_DATADIR/test/tab1.ibd
300 --exec $INNOCHECKSUM --start-page=0 $MYSQLD_DATADIR/test/tab1.ibd
301 --exec $INNOCHECKSUM -s 0 $MYSQLD_DATADIR/test/tab1.ibd
302 --exec $INNOCHECKSUM --end-page=0 $MYSQLD_DATADIR/test/tab1.ibd
303 --exec $INNOCHECKSUM -e 0 $MYSQLD_DATADIR/test/tab1.ibd
304
305 --echo [7]: check the negative values for option
306 --echo # allow-mismatches,page,start-page,end-page.
307 --echo # They will reset to zero for negative values.
308 --echo # check the invalid lower bound values
309 --exec $INNOCHECKSUM --allow-mismatches=-1 $MYSQLD_DATADIR/test/tab1.ibd
310 --exec $INNOCHECKSUM -a -1 $MYSQLD_DATADIR/test/tab1.ibd
311 --exec $INNOCHECKSUM --page=-1 $MYSQLD_DATADIR/test/tab1.ibd
312 --exec $INNOCHECKSUM -p -1 $MYSQLD_DATADIR/test/tab1.ibd
313 --exec $INNOCHECKSUM --start-page=-1 $MYSQLD_DATADIR/test/tab1.ibd
314 --exec $INNOCHECKSUM -s -1 $MYSQLD_DATADIR/test/tab1.ibd
315 --exec $INNOCHECKSUM --end-page=-1 $MYSQLD_DATADIR/test/tab1.ibd
316 --exec $INNOCHECKSUM -e -1 $MYSQLD_DATADIR/test/tab1.ibd
317
318 --echo [8]: check the valid upper bound values for
319 --echo # both short and long options "allow-mismatches" and "end-page"
320
321 --exec $INNOCHECKSUM --allow-mismatches=18446744073709551615 $MYSQLD_DATADIR/test/tab1.ibd
322 --exec $INNOCHECKSUM -a 18446744073709551615 $MYSQLD_DATADIR/test/tab1.ibd
323 --exec $INNOCHECKSUM --end-page=18446744073709551615 $MYSQLD_DATADIR/test/tab1.ibd
324 --exec $INNOCHECKSUM -e 18446744073709551615 $MYSQLD_DATADIR/test/tab1.ibd
325
326 --echo [9]: check the both short and long options "page" and "start-page" when
327 --echo # seek value is larger than file size.
328 --error 1
329 --exec $INNOCHECKSUM --page=18446744073709551615 $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE
330 let SEARCH_PATTERN= Error: Unable to seek to necessary offset: Invalid argument;
331 --source include/search_pattern.inc
332
333 --error 1
334 --exec $INNOCHECKSUM -p 18446744073709551615 $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE
335 let SEARCH_PATTERN= Error: Unable to seek to necessary offset: Invalid argument;
336 --source include/search_pattern.inc
337
338 --error 1
339 --exec $INNOCHECKSUM --start-page=18446744073709551615 $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE
340 let SEARCH_PATTERN= Error: Unable to seek to necessary offset: Invalid argument;
341 --source include/search_pattern.inc
342
343 --error 1
344 --exec $INNOCHECKSUM -s 18446744073709551615 $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE
345 let SEARCH_PATTERN= Error: Unable to seek to necessary offset: Invalid argument;
346 --source include/search_pattern.inc
347
348 --echo [34]: check the invalid upper bound values for options, allow-mismatches, end-page, start-page and page.
349 --echo # innochecksum will fail with error code: 1
350 --error 1
351 --exec $INNOCHECKSUM --allow-mismatches=18446744073709551616 $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE
352 let SEARCH_PATTERN= Incorrect unsigned integer value: '18446744073709551616';
353 --source include/search_pattern.inc
354
355 --error 1
356 --exec $INNOCHECKSUM -a 18446744073709551616 $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE
357 let SEARCH_PATTERN= Incorrect unsigned integer value: '18446744073709551616';
358 --source include/search_pattern.inc
359
360 --error 1
361 --exec $INNOCHECKSUM --end-page=18446744073709551616 $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE
362 let SEARCH_PATTERN= Incorrect unsigned integer value: '18446744073709551616';
363 --source include/search_pattern.inc
364
365 --error 1
366 --exec $INNOCHECKSUM -e 18446744073709551616 $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE
367 let SEARCH_PATTERN= Incorrect unsigned integer value: '18446744073709551616';
368 --source include/search_pattern.inc
369
370 --error 1
371 --exec $INNOCHECKSUM --page=18446744073709551616 $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE
372 let SEARCH_PATTERN= Incorrect unsigned integer value: '18446744073709551616';
373 --source include/search_pattern.inc
374
375 --error 1
376 --exec $INNOCHECKSUM -p 18446744073709551616 $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE
377 let SEARCH_PATTERN= Incorrect unsigned integer value: '18446744073709551616';
378 --source include/search_pattern.inc
379
380 --error 1
381 --exec $INNOCHECKSUM --start-page=18446744073709551616 $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE
382 let SEARCH_PATTERN= Incorrect unsigned integer value: '18446744073709551616';
383 --source include/search_pattern.inc
384
385 --error 1
386 --exec $INNOCHECKSUM -s 18446744073709551616 $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE
387 let SEARCH_PATTERN= Incorrect unsigned integer value: '18446744073709551616';
388 --source include/search_pattern.inc
389 --remove_file $SEARCH_FILE
390
391 # Cleanup
392 --echo # Restart the server
393 --let $restart_parameters= restart: --innodb_checksum_algorithm=crc32
394 --source include/start_mysqld.inc
395
396 DROP TABLE tab1;
397 DROP TABLE tab2;
398 SET GLOBAL innodb_file_per_table=default;