| 1 |
# |
| 2 |
# Test the persistent stats auto recalc during DDL |
| 3 |
# |
| 4 |
|
| 5 |
|
| 6 |
-- vertical_results |
| 7 |
|
| 8 |
-- let $check_stats1 = SELECT n_rows FROM mysql.innodb_table_stats WHERE table_name = 'arddl' ORDER BY 1 |
| 9 |
-- let $check_stats2 = SELECT index_name, stat_name, stat_value FROM mysql.innodb_index_stats WHERE table_name = 'arddl' AND index_name = 'PRIMARY' ORDER BY 1, 2, 3 |
| 10 |
|
| 11 |
# Test ADD INDEX during background stats gathering |
| 12 |
|
| 13 |
CREATE TABLE arddl (a INT, b INT, PRIMARY KEY (a)) ENGINE=INNODB; |
| 14 |
|
| 15 |
INSERT INTO arddl VALUES (1, 10); |
| 16 |
INSERT INTO arddl VALUES (2, 10); |
| 17 |
|
| 18 |
ALTER TABLE arddl ADD INDEX (b); |
| 19 |
|
| 20 |
# wait for the bg stats thread to update the stats, notice we wait on |
| 21 |
# innodb_index_stats because innodb_table_stats gets updated first and |
| 22 |
# it is possible that (if we wait on innodb_table_stats) the wait cond |
| 23 |
# gets satisfied before innodb_index_stats is updated |
| 24 |
let $wait_condition = SELECT stat_value = 2 FROM mysql.innodb_index_stats WHERE table_name = 'arddl' AND index_name = 'PRIMARY' AND stat_name = 'n_diff_pfx01'; |
| 25 |
-- source include/wait_condition.inc |
| 26 |
|
| 27 |
# the second INSERT from above should have triggered an auto-recalc |
| 28 |
-- eval $check_stats1 |
| 29 |
-- eval $check_stats2 |
| 30 |
|
| 31 |
DROP TABLE arddl; |
| 32 |
|
| 33 |
# Test DROP INDEX during background stats gathering |
| 34 |
|
| 35 |
CREATE TABLE arddl (a INT, b INT, PRIMARY KEY (a), KEY (b)) ENGINE=INNODB; |
| 36 |
|
| 37 |
INSERT INTO arddl VALUES (3, 10); |
| 38 |
INSERT INTO arddl VALUES (4, 10); |
| 39 |
|
| 40 |
ALTER TABLE arddl DROP INDEX b; |
| 41 |
|
| 42 |
let $wait_condition = SELECT stat_value = 2 FROM mysql.innodb_index_stats WHERE table_name = 'arddl' AND index_name = 'PRIMARY' AND stat_name = 'n_diff_pfx01'; |
| 43 |
-- source include/wait_condition.inc |
| 44 |
|
| 45 |
-- eval $check_stats1 |
| 46 |
-- eval $check_stats2 |
| 47 |
|
| 48 |
DROP TABLE arddl; |