|
| 1 | +--source include/have_innodb.inc |
| 2 | +--source include/not_embedded.inc |
| 3 | + |
| 4 | +let INNODB_PAGE_SIZE=`select @@innodb_page_size`; |
| 5 | +let MYSQLD_DATADIR=`select @@datadir`; |
| 6 | +let MYSQLD_IS_DEBUG=`select version() like '%debug%'`; |
| 7 | +--source include/no_checkpoint_start.inc |
| 8 | +SET GLOBAL innodb_file_per_table=0; |
| 9 | +SET GLOBAL innodb_file_format=barracuda; |
| 10 | +CREATE TABLE t(a INT)ENGINE=InnoDB; |
| 11 | +let INNODB_ROOT_PAGE= `SELECT page_no FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES WHERE name='GEN_CLUST_INDEX'`; |
| 12 | +SET GLOBAL innodb_file_per_table=1; |
| 13 | + |
| 14 | +CREATE TABLE ibd4(a INT UNIQUE)ENGINE=InnoDB; |
| 15 | +CREATE TABLE ibd4f(a INT UNIQUE)ENGINE=InnoDB; |
| 16 | +CREATE TABLE ibd5(a INT UNIQUE, b INT UNIQUE)ENGINE=InnoDB; |
| 17 | + |
| 18 | +let $drop_tables= DROP TABLE t,ibd4,ibd4f,ibd5; |
| 19 | +--let CLEANUP_IF_CHECKPOINT= $drop_tables; |
| 20 | +--source ../include/no_checkpoint_end.inc |
| 21 | + |
| 22 | +perl; |
| 23 | +use Fcntl 'SEEK_CUR', 'SEEK_END'; |
| 24 | + |
| 25 | +my $page_size = $ENV{'INNODB_PAGE_SIZE'}; |
| 26 | +my $restart = 'restart'; |
| 27 | +if ($ENV{'MYSQLD_IS_DEBUG'}) |
| 28 | +{ |
| 29 | + # It is impractical to ensure that CREATE TABLE t will extend ibdata1. |
| 30 | + # We rely on innodb_system_tablespace_extend_debug=1 |
| 31 | + # to recover from this fault injection if no size change was redo-logged. |
| 32 | + my $root = $ENV{'INNODB_ROOT_PAGE'}; |
| 33 | + open(FILE, "+<", "$ENV{'MYSQLD_DATADIR'}ibdata1") or die; |
| 34 | + my $size = sysseek(FILE, 0, SEEK_END) / $page_size; |
| 35 | + seek(FILE, $page_size * ($root + 1), SEEK_SET) or die; |
| 36 | + my $empty_tail= 1; |
| 37 | + while(<FILE>) { unless (/\0*/gso) { $empty_tail= 0; last } } |
| 38 | + if ($empty_tail) |
| 39 | + { |
| 40 | + $restart = 'restart: --innodb-data-file-size-debug=' . $size; |
| 41 | + truncate(FILE, $page_size * $root); |
| 42 | + } |
| 43 | + close FILE; |
| 44 | +} |
| 45 | +open(FILE, ">$ENV{MYSQLTEST_VARDIR}/log/start_mysqld.txt") || die; |
| 46 | +print FILE '--exec echo "', $restart, '" > $_expect_file_name |
| 47 | +--enable_reconnect |
| 48 | +--source include/wait_until_connected_again.inc |
| 49 | +--disable_reconnect |
| 50 | +'; |
| 51 | +close FILE; |
| 52 | +open(FILE, "+<", "$ENV{'MYSQLD_DATADIR'}test/ibd4.ibd") or die; |
| 53 | +truncate(FILE, $page_size * 4); |
| 54 | +close FILE; |
| 55 | +open(FILE, "+<", "$ENV{'MYSQLD_DATADIR'}test/ibd4f.ibd") or die; |
| 56 | +truncate(FILE, $page_size * 4 + 1234); |
| 57 | +close FILE; |
| 58 | +open(FILE, "+<", "$ENV{'MYSQLD_DATADIR'}test/ibd5.ibd") or die; |
| 59 | +truncate(FILE, $page_size * 5); |
| 60 | +close FILE; |
| 61 | +EOF |
| 62 | + |
| 63 | +--source $MYSQLTEST_VARDIR/log/start_mysqld.txt |
| 64 | +--remove_file $MYSQLTEST_VARDIR/log/start_mysqld.txt |
| 65 | + |
| 66 | +eval $drop_tables; |
0 commit comments