~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to plugin/innobase/dict/dict0dict.c

  • Committer: Bazaar Package Importer
  • Author(s): Monty Taylor
  • Date: 2010-12-21 16:39:40 UTC
  • mfrom: (1.2.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20101221163940-c1pfo1jjvx7909xq
Tags: 2010.12.06-0ubuntu1
* New upstream release.
* Added libaio-dev build depend for InnoDB.
* Removed libpcre patch - applied upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*****************************************************************************
2
2
 
3
 
Copyright (c) 1996, 2010, Innobase Oy. All Rights Reserved.
 
3
Copyright (C) 1996, 2010, Innobase Oy. All Rights Reserved.
4
4
 
5
5
This program is free software; you can redistribute it and/or modify it under
6
6
the terms of the GNU General Public License as published by the Free Software
578
578
{
579
579
        dict_table_t*   table;
580
580
 
581
 
        if (table_id <= DICT_FIELDS_ID
582
 
            || trx->dict_operation_lock_mode == RW_X_LATCH) {
 
581
        if (trx->dict_operation_lock_mode == RW_X_LATCH) {
583
582
 
584
583
                /* Note: An X latch implies that the transaction
585
584
                already owns the dictionary mutex. */
4205
4204
                                        dictionary mutex */
4206
4205
{
4207
4206
        dict_index_t*   index;
4208
 
        ulint           size;
4209
4207
        ulint           sum_of_index_sizes      = 0;
4210
4208
 
4211
4209
        if (table->ibd_file_missing) {
4220
4218
                return;
4221
4219
        }
4222
4220
 
4223
 
        /* If we have set a high innodb_force_recovery level, do not calculate
4224
 
        statistics, as a badly corrupted index can cause a crash in it. */
4225
 
 
4226
 
        if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE) {
4227
 
 
4228
 
                return;
4229
 
        }
4230
 
 
4231
4221
        /* Find out the sizes of the indexes and how many different values
4232
4222
        for the key they approximately have */
4233
4223
 
4239
4229
                return;
4240
4230
        }
4241
4231
 
4242
 
        while (index) {
4243
 
                size = btr_get_size(index, BTR_TOTAL_SIZE);
4244
 
 
4245
 
                index->stat_index_size = size;
4246
 
 
4247
 
                sum_of_index_sizes += size;
4248
 
 
4249
 
                size = btr_get_size(index, BTR_N_LEAF_PAGES);
4250
 
 
4251
 
                if (size == 0) {
4252
 
                        /* The root node of the tree is a leaf */
4253
 
                        size = 1;
 
4232
 
 
4233
        do {
 
4234
                if (UNIV_LIKELY
 
4235
                    (srv_force_recovery < SRV_FORCE_NO_IBUF_MERGE
 
4236
                     || (srv_force_recovery < SRV_FORCE_NO_LOG_REDO
 
4237
                         && dict_index_is_clust(index)))) {
 
4238
                        ulint   size;
 
4239
                        size = btr_get_size(index, BTR_TOTAL_SIZE);
 
4240
 
 
4241
                        index->stat_index_size = size;
 
4242
 
 
4243
                        sum_of_index_sizes += size;
 
4244
 
 
4245
                        size = btr_get_size(index, BTR_N_LEAF_PAGES);
 
4246
 
 
4247
                        if (size == 0) {
 
4248
                                /* The root node of the tree is a leaf */
 
4249
                                size = 1;
 
4250
                        }
 
4251
 
 
4252
                        index->stat_n_leaf_pages = size;
 
4253
 
 
4254
                        btr_estimate_number_of_different_key_vals(index);
 
4255
                } else {
 
4256
                        /* If we have set a high innodb_force_recovery
 
4257
                        level, do not calculate statistics, as a badly
 
4258
                        corrupted index can cause a crash in it.
 
4259
                        Initialize some bogus index cardinality
 
4260
                        statistics, so that the data can be queried in
 
4261
                        various means, also via secondary indexes. */
 
4262
                        ulint   i;
 
4263
 
 
4264
                        sum_of_index_sizes++;
 
4265
                        index->stat_index_size = index->stat_n_leaf_pages = 1;
 
4266
 
 
4267
                        for (i = dict_index_get_n_unique(index); i; ) {
 
4268
                                index->stat_n_diff_key_vals[i--] = 1;
 
4269
                        }
4254
4270
                }
4255
4271
 
4256
 
                index->stat_n_leaf_pages = size;
4257
 
 
4258
 
                btr_estimate_number_of_different_key_vals(index);
4259
 
 
4260
4272
                index = dict_table_get_next_index(index);
4261
 
        }
 
4273
        } while (index);
4262
4274
 
4263
4275
        index = dict_table_get_first_index(table);
4264
4276
 
4441
4453
{
4442
4454
        ib_int64_t      n_vals;
4443
4455
        ulint           i;
4444
 
        const char*     type_string;
4445
4456
 
4446
4457
        ut_ad(mutex_own(&(dict_sys->mutex)));
4447
4458
 
4456
4467
 
4457
4468
        dict_index_stat_mutex_exit(index);
4458
4469
 
4459
 
        if (dict_index_is_clust(index)) {
4460
 
                type_string = "clustered index";
4461
 
        } else if (dict_index_is_unique(index)) {
4462
 
                type_string = "unique index";
4463
 
        } else {
4464
 
                type_string = "secondary index";
4465
 
        }
4466
 
 
4467
4470
        fprintf(stderr,
4468
4471
                "  INDEX: name %s, id %llu, fields %lu/%lu,"
4469
4472
                " uniq %lu, type %lu\n"