| 1 |
# |
| 2 |
# MDEV-11759: Encryption code in MariaDB 10.1/10.2 causes compatibility problems |
| 3 |
# |
| 4 |
|
| 5 |
-- source include/have_innodb.inc |
| 6 |
-- source include/have_file_key_management_plugin.inc |
| 7 |
# Don't test under embedded |
| 8 |
-- source include/not_embedded.inc |
| 9 |
|
| 10 |
call mtr.add_suppression("Table `test`\\.`t[123]` (has an unreadable root page|is corrupted)"); |
| 11 |
call mtr.add_suppression("InnoDB: File '.*test/t[123]\\.ibd' is corrupted"); |
| 12 |
call mtr.add_suppression("InnoDB: Failed to read page 3 from file '.*test/t[13]\\.ibd'"); |
| 13 |
call mtr.add_suppression("InnoDB: Failed to read page 6 from file '.*test/t2\\.ibd'"); |
| 14 |
call mtr.add_suppression("InnoDB: Encrypted page \\[page id: space=\\d+, page number=[36]\\] in file .*test.t[123]\\.ibd looks corrupted; key_version="); |
| 15 |
call mtr.add_suppression("\\[ERROR\\] InnoDB: We detected index corruption in an InnoDB type table"); |
| 16 |
call mtr.add_suppression("\\[ERROR\\] mariadbd.*: Index for table 't2' is corrupt; try to repair it"); |
| 17 |
|
| 18 |
set global innodb_compression_algorithm = 1; |
| 19 |
|
| 20 |
--echo # Create and populate tables to be corrupted |
| 21 |
CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT,c char(200)) ENGINE=InnoDB encrypted=yes; |
| 22 |
CREATE TABLE t2 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT,c char(200)) ENGINE=InnoDB row_format=compressed encrypted=yes; |
| 23 |
CREATE TABLE t3 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT, c char(200)) ENGINE=InnoDB page_compressed=yes encrypted=yes; |
| 24 |
|
| 25 |
BEGIN; |
| 26 |
INSERT INTO t1 (b,c) VALUES ('corrupt me','secret'); |
| 27 |
--disable_query_log |
| 28 |
--let $i = 100 |
| 29 |
while ($i) |
| 30 |
{ |
| 31 |
INSERT INTO t1 (b,c) VALUES (REPEAT('abcabcabc', 100),'secretsecret'); |
| 32 |
dec $i; |
| 33 |
} |
| 34 |
--enable_query_log |
| 35 |
|
| 36 |
INSERT INTO t1 (b,c) VALUES ('corrupt me','moresecretmoresecret'); |
| 37 |
INSERT INTO t2 select * from t1; |
| 38 |
INSERT INTO t3 select * from t1; |
| 39 |
COMMIT; |
| 40 |
|
| 41 |
let INNODB_PAGE_SIZE=`select @@innodb_page_size`; |
| 42 |
let MYSQLD_DATADIR=`select @@datadir`; |
| 43 |
|
| 44 |
--source include/shutdown_mysqld.inc |
| 45 |
|
| 46 |
--echo # Backup tables before corrupting |
| 47 |
--copy_file $MYSQLD_DATADIR/test/t1.ibd $MYSQLD_DATADIR/test/t1.ibd.backup |
| 48 |
--copy_file $MYSQLD_DATADIR/test/t2.ibd $MYSQLD_DATADIR/test/t2.ibd.backup |
| 49 |
--copy_file $MYSQLD_DATADIR/test/t3.ibd $MYSQLD_DATADIR/test/t3.ibd.backup |
| 50 |
|
| 51 |
--echo # Corrupt tables |
| 52 |
|
| 53 |
perl; |
| 54 |
open(FILE, "+<", "$ENV{MYSQLD_DATADIR}/test/t1.ibd") or die "open"; |
| 55 |
binmode FILE; |
| 56 |
seek(FILE, $ENV{'INNODB_PAGE_SIZE'} * 3 + 26, SEEK_SET) or die "seek"; |
| 57 |
print FILE pack("H*", "c001cafedeadb017"); |
| 58 |
close FILE or die "close"; |
| 59 |
open(FILE, "+<", "$ENV{MYSQLD_DATADIR}/test/t2.ibd") or die "open"; |
| 60 |
binmode FILE; |
| 61 |
seek(FILE, $ENV{'INNODB_PAGE_SIZE'} * 3 + 26, SEEK_SET) or die "seek"; |
| 62 |
print FILE pack("H*", "c001cafedeadb017"); |
| 63 |
close FILE or die "close"; |
| 64 |
open(FILE, "+<", "$ENV{MYSQLD_DATADIR}/test/t3.ibd") or die "open"; |
| 65 |
binmode FILE; |
| 66 |
seek(FILE, $ENV{'INNODB_PAGE_SIZE'} * 3 + 26, SEEK_SET) or die "seek"; |
| 67 |
print FILE pack("H*", "c001cafedeadb017"); |
| 68 |
close FILE or die "close"; |
| 69 |
EOF |
| 70 |
|
| 71 |
--source include/start_mysqld.inc |
| 72 |
|
| 73 |
--error ER_TABLE_CORRUPT |
| 74 |
SELECT * FROM t1; |
| 75 |
--error ER_GET_ERRMSG,ER_NOT_KEYFILE |
| 76 |
SELECT * FROM t2; |
| 77 |
--error ER_TABLE_CORRUPT |
| 78 |
SELECT * FROM t3; |
| 79 |
|
| 80 |
--source include/shutdown_mysqld.inc |
| 81 |
|
| 82 |
--echo # Restore the original tables |
| 83 |
--move_file $MYSQLD_DATADIR/test/t1.ibd.backup $MYSQLD_DATADIR/test/t1.ibd |
| 84 |
--move_file $MYSQLD_DATADIR/test/t2.ibd.backup $MYSQLD_DATADIR/test/t2.ibd |
| 85 |
--move_file $MYSQLD_DATADIR/test/t3.ibd.backup $MYSQLD_DATADIR/test/t3.ibd |
| 86 |
|
| 87 |
--source include/start_mysqld.inc |
| 88 |
|
| 89 |
DROP TABLE t1,t2,t3; |