~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to storage/innodb_plugin/dict/dict0dict.c

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-05-22 08:59:41 UTC
  • mto: (2.1.3 sid) (1.2.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20100522085941-4x62clk1ovyip4m5
Tags: upstream-5.1.47
ImportĀ upstreamĀ versionĀ 5.1.47

Show diffs side-by-side

added added

removed removed

Lines of Context:
80
80
/** Identifies generated InnoDB foreign key names */
81
81
static char     dict_ibfk[] = "_ibfk_";
82
82
 
 
83
/** array of mutexes protecting dict_index_t::stat_n_diff_key_vals[] */
 
84
#define DICT_INDEX_STAT_MUTEX_SIZE      32
 
85
mutex_t dict_index_stat_mutex[DICT_INDEX_STAT_MUTEX_SIZE];
 
86
 
83
87
/*******************************************************************//**
84
88
Tries to find column names for the index and sets the col field of the
85
89
index.
239
243
        mutex_exit(&(dict_sys->mutex));
240
244
}
241
245
 
 
246
/** Get the mutex that protects index->stat_n_diff_key_vals[] */
 
247
#define GET_INDEX_STAT_MUTEX(index) \
 
248
        (&dict_index_stat_mutex[ut_fold_dulint(index->id) \
 
249
                                % DICT_INDEX_STAT_MUTEX_SIZE])
 
250
 
 
251
/**********************************************************************//**
 
252
Lock the appropriate mutex to protect index->stat_n_diff_key_vals[].
 
253
index->id is used to pick the right mutex and it should not change
 
254
before dict_index_stat_mutex_exit() is called on this index. */
 
255
UNIV_INTERN
 
256
void
 
257
dict_index_stat_mutex_enter(
 
258
/*========================*/
 
259
        const dict_index_t*     index)  /*!< in: index */
 
260
{
 
261
        ut_ad(index != NULL);
 
262
        ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
 
263
        ut_ad(index->cached);
 
264
        ut_ad(!index->to_be_dropped);
 
265
 
 
266
        mutex_enter(GET_INDEX_STAT_MUTEX(index));
 
267
}
 
268
 
 
269
/**********************************************************************//**
 
270
Unlock the appropriate mutex that protects index->stat_n_diff_key_vals[]. */
 
271
UNIV_INTERN
 
272
void
 
273
dict_index_stat_mutex_exit(
 
274
/*=======================*/
 
275
        const dict_index_t*     index)  /*!< in: index */
 
276
{
 
277
        ut_ad(index != NULL);
 
278
        ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
 
279
        ut_ad(index->cached);
 
280
        ut_ad(!index->to_be_dropped);
 
281
 
 
282
        mutex_exit(GET_INDEX_STAT_MUTEX(index));
 
283
}
 
284
 
242
285
/********************************************************************//**
243
286
Decrements the count of open MySQL handles to a table. */
244
287
UNIV_INTERN
605
648
dict_init(void)
606
649
/*===========*/
607
650
{
 
651
        int     i;
 
652
 
608
653
        dict_sys = mem_alloc(sizeof(dict_sys_t));
609
654
 
610
655
        mutex_create(&dict_sys->mutex, SYNC_DICT);
625
670
        ut_a(dict_foreign_err_file);
626
671
 
627
672
        mutex_create(&dict_foreign_err_mutex, SYNC_ANY_LATCH);
 
673
 
 
674
        for (i = 0; i < DICT_INDEX_STAT_MUTEX_SIZE; i++) {
 
675
                mutex_create(&dict_index_stat_mutex[i], SYNC_INDEX_TREE);
 
676
        }
628
677
}
629
678
 
630
679
/**********************************************************************//**
4171
4220
 
4172
4221
        index = dict_table_get_first_index(table);
4173
4222
 
 
4223
        dict_index_stat_mutex_enter(index);
 
4224
 
4174
4225
        table->stat_n_rows = index->stat_n_diff_key_vals[
4175
4226
                dict_index_get_n_unique(index)];
4176
4227
 
 
4228
        dict_index_stat_mutex_exit(index);
 
4229
 
4177
4230
        table->stat_clustered_index_size = index->stat_index_size;
4178
4231
 
4179
4232
        table->stat_sum_of_other_index_sizes = sum_of_index_sizes
4351
4404
 
4352
4405
        ut_ad(mutex_own(&(dict_sys->mutex)));
4353
4406
 
 
4407
        dict_index_stat_mutex_enter(index);
 
4408
 
4354
4409
        if (index->n_user_defined_cols > 0) {
4355
4410
                n_vals = index->stat_n_diff_key_vals[
4356
4411
                        index->n_user_defined_cols];
4358
4413
                n_vals = index->stat_n_diff_key_vals[1];
4359
4414
        }
4360
4415
 
 
4416
        dict_index_stat_mutex_exit(index);
 
4417
 
4361
4418
        if (dict_index_is_clust(index)) {
4362
4419
                type_string = "clustered index";
4363
4420
        } else if (dict_index_is_unique(index)) {
4767
4824
void
4768
4825
dict_table_check_for_dup_indexes(
4769
4826
/*=============================*/
4770
 
        const dict_table_t*     table)  /*!< in: Check for dup indexes
 
4827
        const dict_table_t*     table,  /*!< in: Check for dup indexes
4771
4828
                                        in this table */
 
4829
        ibool                   tmp_ok) /*!< in: TRUE=allow temporary
 
4830
                                        index names */
4772
4831
{
4773
4832
        /* Check for duplicates, ignoring indexes that are marked
4774
4833
        as to be dropped */
4782
4841
        ut_a(UT_LIST_GET_LEN(table->indexes) > 0);
4783
4842
 
4784
4843
        index1 = UT_LIST_GET_FIRST(table->indexes);
4785
 
        index2 = UT_LIST_GET_NEXT(indexes, index1);
4786
 
 
4787
 
        while (index1 && index2) {
 
4844
 
 
4845
        do {
 
4846
                ut_ad(tmp_ok || *index1->name != TEMP_INDEX_PREFIX);
 
4847
 
 
4848
                index2 = UT_LIST_GET_NEXT(indexes, index1);
4788
4849
 
4789
4850
                while (index2) {
4790
4851
 
4796
4857
                }
4797
4858
 
4798
4859
                index1 = UT_LIST_GET_NEXT(indexes, index1);
4799
 
                index2 = UT_LIST_GET_NEXT(indexes, index1);
4800
 
        }
 
4860
        } while (index1);
4801
4861
}
4802
4862
#endif /* UNIV_DEBUG */
4803
4863
 
4850
4910
 
4851
4911
        mem_free(dict_sys);
4852
4912
        dict_sys = NULL;
 
4913
 
 
4914
        for (i = 0; i < DICT_INDEX_STAT_MUTEX_SIZE; i++) {
 
4915
                mutex_free(&dict_index_stat_mutex[i]);
 
4916
        }
4853
4917
}
4854
4918
#endif /* !UNIV_HOTBACKUP */