| 1 |
# |
| 2 |
# Test fetching from stats tables that are corrupted |
| 3 |
# |
| 4 |
|
| 5 |
-- source include/have_innodb.inc |
| 6 |
# Various sizes printed in this test depend on the page size and the |
| 7 |
# functionality tested here is not related to the page size, so we only |
| 8 |
# test with 16k page size. |
| 9 |
-- source include/have_innodb_16k.inc |
| 10 |
# server restart |
| 11 |
-- source include/not_embedded.inc |
| 12 |
|
| 13 |
call mtr.add_suppression("InnoDB: Column stat_value in table mysql\\.innodb_index_stats is BIGINT UNSIGNED but should be BIGINT UNSIGNED NOT NULL"); |
| 14 |
call mtr.add_suppression("InnoDB: Fetch of persistent statistics requested for table"); |
| 15 |
|
| 16 |
-- vertical_results |
| 17 |
|
| 18 |
CREATE TABLE test_ps_fetch_corrupted |
| 19 |
(a INT, PRIMARY KEY (a)) |
| 20 |
ENGINE=INNODB STATS_PERSISTENT=1; |
| 21 |
|
| 22 |
# write stats to mysql.innodb_table_stats |
| 23 |
ANALYZE TABLE test_ps_fetch_corrupted; |
| 24 |
|
| 25 |
# check that indeed stats were written by ANALYZE above |
| 26 |
SELECT n_rows, clustered_index_size, sum_of_other_index_sizes |
| 27 |
FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_fetch_corrupted'; |
| 28 |
|
| 29 |
# corrupt the persistent storage |
| 30 |
ALTER TABLE mysql.innodb_index_stats MODIFY stat_value BIGINT UNSIGNED NULL; |
| 31 |
|
| 32 |
# reopen the table, this will attept to read from the persistent storage |
| 33 |
FLUSH TABLE test_ps_fetch_corrupted; |
| 34 |
|
| 35 |
# check the stats (should have been generated using the old transient stats |
| 36 |
# method) |
| 37 |
SELECT seq_in_index, column_name, cardinality |
| 38 |
FROM information_schema.statistics WHERE table_name = 'test_ps_fetch_corrupted' |
| 39 |
ORDER BY index_name, seq_in_index; |
| 40 |
|
| 41 |
SELECT table_rows, avg_row_length, max_data_length, index_length |
| 42 |
FROM information_schema.tables WHERE table_name = 'test_ps_fetch_corrupted'; |
| 43 |
|
| 44 |
# restore the persistent storage |
| 45 |
ALTER TABLE mysql.innodb_index_stats MODIFY stat_value BIGINT UNSIGNED NOT NULL; |
| 46 |
FLUSH TABLE test_ps_fetch_corrupted; |
| 47 |
|
| 48 |
SELECT seq_in_index, column_name, cardinality |
| 49 |
FROM information_schema.statistics WHERE table_name = 'test_ps_fetch_corrupted' |
| 50 |
ORDER BY index_name, seq_in_index; |
| 51 |
|
| 52 |
SELECT table_rows, avg_row_length, max_data_length, index_length |
| 53 |
FROM information_schema.tables WHERE table_name = 'test_ps_fetch_corrupted'; |
| 54 |
|
| 55 |
DROP TABLE test_ps_fetch_corrupted; |
| 56 |
|
| 57 |
# force server restart to clean up log from above error |
| 58 |
--source include/restart_mysqld.inc |