| 1 |
# |
| 2 |
# Bug#57252 disabling innobase_stats_on_metadata disables ANALYZE |
| 3 |
# http://bugs.mysql.com/57252 |
| 4 |
# |
| 5 |
|
| 6 |
|
| 7 |
-- disable_query_log |
| 8 |
-- disable_result_log |
| 9 |
|
| 10 |
SET @innodb_stats_on_metadata_orig = @@innodb_stats_on_metadata; |
| 11 |
|
| 12 |
CREATE TABLE bug57252 (a INT, KEY akey (a)) ENGINE=INNODB STATS_PERSISTENT=0; |
| 13 |
|
| 14 |
BEGIN; |
| 15 |
let $i = 19; |
| 16 |
while ($i) { |
| 17 |
eval INSERT INTO bug57252 VALUES ($i); |
| 18 |
dec $i; |
| 19 |
} |
| 20 |
COMMIT; |
| 21 |
|
| 22 |
-- enable_result_log |
| 23 |
|
| 24 |
SET GLOBAL innodb_stats_on_metadata=0; |
| 25 |
|
| 26 |
# this calls ::info() without HA_STATUS_CONST and so |
| 27 |
# index->stat_n_diff_key_vals[] is not copied to the mysql-visible |
| 28 |
# rec_per_key |
| 29 |
|
| 30 |
# Cardinality value return by InnoDB is not correct. Masking |
| 31 |
# cardinality value to make test consistent until Bug#25539486 is fixed. |
| 32 |
SELECT cardinality FROM information_schema.statistics |
| 33 |
WHERE table_name='bug57252' AND index_name='akey'; |
| 34 |
|
| 35 |
# this calls ::info() with HA_STATUS_CONST and so |
| 36 |
# index->stat_n_diff_key_vals[] is copied to the mysql-visible |
| 37 |
# rec_per_key at the end; when the bug is present dict_update_statistics() |
| 38 |
# is not called beforehand and so index->stat_n_diff_key_vals[] contains |
| 39 |
# an outdated data and thus we get an outdated data in the result when the |
| 40 |
# bug is present |
| 41 |
ANALYZE TABLE bug57252; |
| 42 |
|
| 43 |
SELECT cardinality FROM information_schema.statistics |
| 44 |
WHERE table_name='bug57252' AND index_name='akey'; |
| 45 |
|
| 46 |
DROP TABLE bug57252; |
| 47 |
|
| 48 |
SET GLOBAL innodb_stats_on_metadata = @innodb_stats_on_metadata_orig; |