summaryrefslogtreecommitdiff
path: root/storage/innobase/dict/dict0dict.c
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@oracle.com>2010-08-24 11:34:19 +0300
committerMarko Mäkelä <marko.makela@oracle.com>2010-08-24 11:34:19 +0300
commit938ce0efd7782697c5b7e96d7343e800438da909 (patch)
tree84359ae91905fc038c35dcb37e008532094cd9de /storage/innobase/dict/dict0dict.c
parent398f3ebbed83a7bde11ddb98910860862527a32c (diff)
downloadmariadb-git-938ce0efd7782697c5b7e96d7343e800438da909.tar.gz
Merge Bug#55832 fix from mysql-5.1-innodb:
------------------------------------------------------------ revno: 3550 revision-id: marko.makela@oracle.com-20100824081003-v4ecy0tga99cpxw2 parent: marko.makela@oracle.com-20100823102854-t1clrojqis2ley36 committer: Marko Mäkelä <marko.makela@oracle.com> branch nick: 5.1-innodb timestamp: Tue 2010-08-24 11:10:03 +0300 message: Bug#55832: selects crash too easily when innodb_force_recovery>3 dict_update_statistics_low(): Create bogus statistics for those indexes that cannot be accessed because of the innodb_force_recovery setting. ha_innobase::info(): Calculate statistics for each index, even if innodb_force_recovery is set. Fill in bogus data for those indexes that are not accessed because of the innodb_force_recovery setting.
Diffstat (limited to 'storage/innobase/dict/dict0dict.c')
-rw-r--r--storage/innobase/dict/dict0dict.c55
1 files changed, 34 insertions, 21 deletions
diff --git a/storage/innobase/dict/dict0dict.c b/storage/innobase/dict/dict0dict.c
index 802f0bd8b6f..3dba63cc76a 100644
--- a/storage/innobase/dict/dict0dict.c
+++ b/storage/innobase/dict/dict0dict.c
@@ -4206,7 +4206,6 @@ dict_update_statistics_low(
dictionary mutex */
{
dict_index_t* index;
- ulint size;
ulint sum_of_index_sizes = 0;
if (table->ibd_file_missing) {
@@ -4221,14 +4220,6 @@ dict_update_statistics_low(
return;
}
- /* If we have set a high innodb_force_recovery level, do not calculate
- statistics, as a badly corrupted index can cause a crash in it. */
-
- if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE) {
-
- return;
- }
-
/* Find out the sizes of the indexes and how many different values
for the key they approximately have */
@@ -4240,26 +4231,48 @@ dict_update_statistics_low(
return;
}
- while (index) {
- size = btr_get_size(index, BTR_TOTAL_SIZE);
- index->stat_index_size = size;
+ do {
+ if (UNIV_LIKELY
+ (srv_force_recovery < SRV_FORCE_NO_IBUF_MERGE
+ || (srv_force_recovery < SRV_FORCE_NO_LOG_REDO
+ && dict_index_is_clust(index)))) {
+ ulint size;
+ size = btr_get_size(index, BTR_TOTAL_SIZE);
- sum_of_index_sizes += size;
+ index->stat_index_size = size;
- size = btr_get_size(index, BTR_N_LEAF_PAGES);
+ sum_of_index_sizes += size;
- if (size == 0) {
- /* The root node of the tree is a leaf */
- size = 1;
- }
+ size = btr_get_size(index, BTR_N_LEAF_PAGES);
- index->stat_n_leaf_pages = size;
+ if (size == 0) {
+ /* The root node of the tree is a leaf */
+ size = 1;
+ }
+
+ index->stat_n_leaf_pages = size;
+
+ btr_estimate_number_of_different_key_vals(index);
+ } else {
+ /* If we have set a high innodb_force_recovery
+ level, do not calculate statistics, as a badly
+ corrupted index can cause a crash in it.
+ Initialize some bogus index cardinality
+ statistics, so that the data can be queried in
+ various means, also via secondary indexes. */
+ ulint i;
- btr_estimate_number_of_different_key_vals(index);
+ sum_of_index_sizes++;
+ index->stat_index_size = index->stat_n_leaf_pages = 1;
+
+ for (i = dict_index_get_n_unique(index); i; ) {
+ index->stat_n_diff_key_vals[i--] = 1;
+ }
+ }
index = dict_table_get_next_index(index);
- }
+ } while (index);
index = dict_table_get_first_index(table);