mirror of
				https://github.com/MariaDB/server.git
				synced 2025-10-31 15:50:51 +03:00 
			
		
		
		
	To disable debug instrumentation, save and restore the original value of the variable DEBUG_DBUG. Assigning -d,... will enable the output of a lot of unrelated DBUG messages to the server error log.
		
			
				
	
	
		
			80 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			80 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| #
 | |
| # Test opening a corrupted table.
 | |
| #
 | |
| # Restarting is not supported under embedded
 | |
| -- source include/not_embedded.inc
 | |
| # Require InnoDB
 | |
| -- source include/have_innodb.inc
 | |
| -- source include/not_encrypted.inc
 | |
| 
 | |
| --disable_query_log
 | |
| call mtr.add_suppression("InnoDB: Table `test`\\.`t1` is corrupted\\. Please drop the table and recreate\\.");
 | |
| call mtr.add_suppression("InnoDB: Database page corruption on disk or a failed file read of tablespace test/t1 page");
 | |
| call mtr.add_suppression("InnoDB: We detected index corruption in an InnoDB type table");
 | |
| call mtr.add_suppression("Index for table 't1' is corrupt; try to repair it");
 | |
| --enable_query_log
 | |
| 
 | |
| --echo # Create and populate the table to be corrupted
 | |
| 
 | |
| set global innodb_file_per_table=ON;
 | |
| 
 | |
| 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 1030,1712,1932
 | |
| SELECT * FROM t1;
 | |
| 
 | |
| --error 126,1030,1034,1712,1932
 | |
| INSERT INTO t1(b) VALUES('abcdef');
 | |
| 
 | |
| --error 1030,1712,1932
 | |
| UPDATE t1 set b = 'deadbeef' where a = 1;
 | |
| 
 | |
| --echo # Cleanup, this must be possible
 | |
| DROP TABLE t1;
 |