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
#
# Bug#12429573 TIMESTAMP COLUMN OF INNODB.INDEX_STATS ARE NOT UPDATED
# WHEN RE-RUNNING ANALYZE
#
-- source include/have_innodb.inc
-- source include/not_embedded.inc
CREATE TABLE bug12429573 (i INTEGER PRIMARY KEY, j INTEGER, KEY(j))
ENGINE=INNODB STATS_PERSISTENT=1;
ANALYZE TABLE bug12429573;
# Cannot check the exact timestamp here because it is always different
# but at least check that both timestamps in innodb_table_stats and in
# innodb_index_stats have been updated to the same value. If the bug is
# present this check will fail.
SELECT last_update FROM mysql.innodb_index_stats WHERE
table_name = 'bug12429573' AND
last_update NOT IN
(SELECT last_update FROM mysql.innodb_table_stats
WHERE table_name = 'bug12429573');
# The first ANALYZE would insert timestamp e.g. 17:23:39 in both
# innodb_table_stats and innodb_index_stats. The bug is that the second
# ANALYZE only updates the timestamp in innodb_table_stats. In order to
# check if the timestamp in innodb_index_stats has really been updated we
# need it to be different from the previous one (17:23:39) with at least
# one second.
-- sleep 1
ANALYZE TABLE bug12429573;
# If the bug is present we get the timestamps different here.
SELECT last_update FROM mysql.innodb_index_stats WHERE
table_name = 'bug12429573' AND
last_update NOT IN
(SELECT last_update FROM mysql.innodb_table_stats
WHERE table_name = 'bug12429573');
DROP TABLE bug12429573;