Debian Codegraph @

mysql-test/suite/innodb/t/innodb_stats_auto_recalc_on_nonexistent.test

raw
1 #
2 # Test the persistent stats auto recalc when persistent stats do not exist
3 #
4
5 -- source include/have_innodb.inc
6
7 -- vertical_results
8
9 -- let $check_stats1 = SELECT COUNT(*) FROM mysql.innodb_table_stats WHERE table_name = 't'
10 -- let $check_stats2 = SELECT COUNT(*) FROM mysql.innodb_index_stats WHERE table_name = 't'
11
12 -- echo Test with default setting
13
14 CREATE TABLE t (a INT, PRIMARY KEY (a)) ENGINE=INNODB;
15
16 # the CREATE should have inserted zeroed stats
17 -- eval $check_stats1
18 -- eval $check_stats2
19
20 SELECT * FROM t;
21
22 DELETE FROM mysql.innodb_index_stats WHERE table_name = 't';
23 DELETE FROM mysql.innodb_table_stats WHERE table_name = 't';
24
25 -- eval $check_stats1
26 -- eval $check_stats2
27
28 # rename and open the table, causing stats recalc/save
29 RENAME TABLE t TO tmp, tmp TO t;
30 SELECT * FROM t;
31
32 -- eval $check_stats1
33 -- eval $check_stats2
34
35 DROP TABLE t;
36
37 -- echo Test with explicit enable
38
39 CREATE TABLE t (a INT, PRIMARY KEY (a)) ENGINE=INNODB STATS_AUTO_RECALC=1;
40
41 # the CREATE should have inserted zeroed stats
42 -- eval $check_stats1
43 -- eval $check_stats2
44
45 SELECT * FROM t;
46
47 DELETE FROM mysql.innodb_index_stats WHERE table_name = 't';
48 DELETE FROM mysql.innodb_table_stats WHERE table_name = 't';
49
50 -- eval $check_stats1
51 -- eval $check_stats2
52
53 RENAME TABLE t TO tmp, tmp TO t;
54 SELECT * FROM t;
55
56 -- eval $check_stats1
57 -- eval $check_stats2
58
59 DROP TABLE t;
60
61 -- echo Test with explicit disable
62
63 CREATE TABLE t (a INT, PRIMARY KEY (a)) ENGINE=INNODB STATS_AUTO_RECALC=0;
64
65 # the CREATE should have inserted zeroed stats
66 -- eval $check_stats1
67 -- eval $check_stats2
68
69 SELECT * FROM t;
70
71 DELETE FROM mysql.innodb_index_stats WHERE table_name = 't';
72 DELETE FROM mysql.innodb_table_stats WHERE table_name = 't';
73
74 -- eval $check_stats1
75 -- eval $check_stats2
76
77 # rename the table, stats should not be present, since autorecalc is disabled
78 RENAME TABLE t TO tmp, tmp TO t;
79 SELECT * FROM t;
80
81 -- eval $check_stats1
82 -- eval $check_stats2
83
84 DROP TABLE t;