diff options
author | Annamalai Gurusami <annamalai.gurusami@oracle.com> | 2012-12-11 10:11:24 +0530 |
---|---|---|
committer | Annamalai Gurusami <annamalai.gurusami@oracle.com> | 2012-12-11 10:11:24 +0530 |
commit | d426504b9e3e9e92b0c948e912f2b6ffdc89e2d7 (patch) | |
tree | b2fa7ccc2d586b8998b73472581a3b9cb019241b /storage | |
parent | 6b3dad83c921981f1df739047136ece74a35409c (diff) | |
download | mariadb-git-d426504b9e3e9e92b0c948e912f2b6ffdc89e2d7.tar.gz |
Bug #14200010 NEWLY CREATED TABLE DOESN'T ALLOW FOR LOOSE INDEX SCANS
Problem:
Before the ALTER TABLE statement, the array
dict_index_t::stat_n_diff_key_vals had proper values calculated
and updated. But after the ALTER TABLE statement, all the values
of this array is 0.
Because of this statistics returned by innodb_rec_per_key() is
different before and after the ALTER TABLE statement. Running the
ANALYZE TABLE command populates the statistics correctly.
Solution:
After ALTER TABLE statement, set the flag dict_table_t::stat_initialized
correctly so that the table statistics will be recalculated properly when
the table is next loaded. But note that we still don't choose the loose
index scans. This fix only ensures that an ALTER TABLE does not change
the optimizer plan.
rb://1639 approved by Marko and Jimmy.
Diffstat (limited to 'storage')
-rw-r--r-- | storage/innodb_plugin/row/row0mysql.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/storage/innodb_plugin/row/row0mysql.c b/storage/innodb_plugin/row/row0mysql.c index 137a164c4cd..9379912a218 100644 --- a/storage/innodb_plugin/row/row0mysql.c +++ b/storage/innodb_plugin/row/row0mysql.c @@ -4083,6 +4083,13 @@ end: trx->error_state = DB_SUCCESS; trx_general_rollback_for_mysql(trx, NULL); trx->error_state = DB_SUCCESS; + } else { + if (old_is_tmp && !new_is_tmp) { + /* After ALTER TABLE the table statistics + needs to be rebuilt. It will be rebuilt + when the table is loaded again. */ + table->stat_initialized = FALSE; + } } } |