summaryrefslogtreecommitdiff
path: root/mysql-test/suite/innodb/t/innodb_bug60049.test
blob: 70fec8cb95938206c6a6f64d5e14903747cf378a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Bug #60049 Verify that purge leaves no garbage in unique secondary indexes
# This test requires a fresh server start-up and a slow shutdown.
# This was a suspected bug (not a bug).

-- source include/not_embedded.inc
-- source include/have_innodb.inc
-- source include/have_innodb_16k.inc

#
# This test will not work if we don't do full shutdown of innodb
#
set @@global.innodb_fast_shutdown=0;

-- disable_query_log
let $create1 = query_get_value(SHOW CREATE TABLE mysql.innodb_table_stats, Create Table, 1);
let $create2 = query_get_value(SHOW CREATE TABLE mysql.innodb_index_stats, Create Table, 1);
DROP TABLE mysql.innodb_index_stats;
DROP TABLE mysql.innodb_table_stats;
-- enable_query_log

CREATE TABLE t(a INT)ENGINE=InnoDB;
RENAME TABLE t TO u;
DROP TABLE u;
SELECT @@innodb_fast_shutdown;
let $MYSQLD_DATADIR=`select @@datadir`;

# Shut down the server
-- exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
-- shutdown_server 30
-- source include/wait_until_disconnected.inc

# Check the tail of ID_IND (SYS_TABLES.ID)
let IBDATA1=$MYSQLD_DATADIR/ibdata1;
perl;
my $file = $ENV{'IBDATA1'};
open(FILE, "<$file") || die "Unable to open $file";
# Read DICT_HDR_TABLE_IDS, the root page number of ID_IND (SYS_TABLES.ID).
seek(FILE, 7*16384+38+36, 0) || die "Unable to seek $file";
die unless read(FILE, $_, 4) == 4;
my $sys_tables_id_root = unpack("N", $_);
print "Last record of ID_IND root page ($sys_tables_id_root):\n";
# This should be the last record in ID_IND. Dump it in hexadecimal.
seek(FILE, $sys_tables_id_root*16384 + 152, 0) || die "Unable to seek $file";
read(FILE, $_, 32) || die "Unable to read $file";
close(FILE);
print unpack("H*", $_), "\n";
EOF

# Restart the server.
-- exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
-- enable_reconnect
-- source include/wait_until_connected_again.inc

-- disable_query_log
USE mysql;
eval $create1;
eval $create2;