summaryrefslogtreecommitdiff
path: root/storage/xtradb/dict/dict0dict.c
diff options
context:
space:
mode:
authorunknown <knielsen@knielsen-hq.org>2010-10-19 14:16:15 +0200
committerunknown <knielsen@knielsen-hq.org>2010-10-19 14:16:15 +0200
commitc6ccd3f34693198883d905b98638db49ea6e6a76 (patch)
treeca49772d376816b7d08173489e9eae4447eef0d7 /storage/xtradb/dict/dict0dict.c
parentf0c6576b85a57ec82fd911f73cce7c99683b378c (diff)
parent4f907dc75b44bca9d9f3c293e7ada0911645837d (diff)
downloadmariadb-git-c6ccd3f34693198883d905b98638db49ea6e6a76.tar.gz
Merge XtraDB from Percona-server-5.1.51-12 into MariaDB.
Diffstat (limited to 'storage/xtradb/dict/dict0dict.c')
-rw-r--r--storage/xtradb/dict/dict0dict.c62
1 files changed, 37 insertions, 25 deletions
diff --git a/storage/xtradb/dict/dict0dict.c b/storage/xtradb/dict/dict0dict.c
index 51ee7f9246f..3db0b362a60 100644
--- a/storage/xtradb/dict/dict0dict.c
+++ b/storage/xtradb/dict/dict0dict.c
@@ -569,8 +569,7 @@ dict_table_get_on_id(
{
dict_table_t* table;
- if (ut_dulint_cmp(table_id, DICT_FIELDS_ID) <= 0
- || trx->dict_operation_lock_mode == RW_X_LATCH) {
+ if (trx->dict_operation_lock_mode == RW_X_LATCH) {
/* Note: An X latch implies that the transaction
already owns the dictionary mutex. */
@@ -4514,7 +4513,6 @@ dict_update_statistics_low(
ibool sync) /*!< in: TRUE if must update SYS_STATS */
{
dict_index_t* index;
- ulint size;
ulint sum_of_index_sizes = 0;
if (table->ibd_file_missing) {
@@ -4529,15 +4527,7 @@ 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;
- }
-
- if (srv_use_sys_stats_table && !sync) {
+ if (srv_use_sys_stats_table && !((table->flags >> DICT_TF2_SHIFT) & DICT_TF2_TEMPORARY) && !sync) {
/* reload statistics from SYS_STATS table */
if (dict_reload_statistics(table, &sum_of_index_sizes)) {
/* success */
@@ -4565,33 +4555,55 @@ dict_update_statistics_low(
return;
}
- while (index) {
+
+ do {
if (table->is_corrupt) {
ut_a(srv_pass_corrupt_table);
return;
}
- size = btr_get_size(index, BTR_TOTAL_SIZE);
+ 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);
- index->stat_index_size = size;
+ index->stat_index_size = size;
- sum_of_index_sizes += size;
+ sum_of_index_sizes += size;
- size = btr_get_size(index, BTR_N_LEAF_PAGES);
+ size = btr_get_size(index, BTR_N_LEAF_PAGES);
- if (size == 0) {
- /* The root node of the tree is a leaf */
- size = 1;
- }
+ if (size == 0) {
+ /* The root node of the tree is a leaf */
+ size = 1;
+ }
- index->stat_n_leaf_pages = size;
+ 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;
+
+ sum_of_index_sizes++;
+ index->stat_index_size = index->stat_n_leaf_pages = 1;
- btr_estimate_number_of_different_key_vals(index);
+ 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);
- if (srv_use_sys_stats_table) {
+ if (srv_use_sys_stats_table && !((table->flags >> DICT_TF2_SHIFT) & DICT_TF2_TEMPORARY)) {
/* store statistics to SYS_STATS table */
dict_store_statistics(table);
}