~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/include/dict0dict.ic

  • Committer: lbieber at stabletransit
  • Date: 2010-10-19 14:03:27 UTC
  • mfrom: (1861.1.2 build)
  • Revision ID: lbieber@drizzle-build-n02.wc1.dfw1.stabletransit.com-20101019140327-2jvt5j2wi4pzhm1z
Merge Brian - Small collection of cleanups/refactor'ing around locks
Merge Monty - fix a few things in the tarball

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*****************************************************************************
2
2
 
3
 
Copyright (C) 1996, 2009, Innobase Oy. All Rights Reserved.
 
3
Copyright (c) 1996, 2009, 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
29
29
#include "rem0types.h"
30
30
 
31
31
/*********************************************************************//**
32
 
Gets the minimum number of bytes per character.
33
 
@return minimum multi-byte char size, in bytes */
34
 
UNIV_INLINE
35
 
ulint
36
 
dict_col_get_mbminlen(
37
 
/*==================*/
38
 
        const dict_col_t*       col)    /*!< in: column */
39
 
{
40
 
        return(DATA_MBMINLEN(col->mbminmaxlen));
41
 
}
42
 
/*********************************************************************//**
43
 
Gets the maximum number of bytes per character.
44
 
@return maximum multi-byte char size, in bytes */
45
 
UNIV_INLINE
46
 
ulint
47
 
dict_col_get_mbmaxlen(
48
 
/*==================*/
49
 
        const dict_col_t*       col)    /*!< in: column */
50
 
{
51
 
        return(DATA_MBMAXLEN(col->mbminmaxlen));
52
 
}
53
 
/*********************************************************************//**
54
 
Sets the minimum and maximum number of bytes per character. */
55
 
UNIV_INLINE
56
 
void
57
 
dict_col_set_mbminmaxlen(
58
 
/*=====================*/
59
 
        dict_col_t*     col,            /*!< in/out: column */
60
 
        ulint           mbminlen,       /*!< in: minimum multi-byte
61
 
                                        character size, in bytes */
62
 
        ulint           mbmaxlen)       /*!< in: minimum multi-byte
63
 
                                        character size, in bytes */
64
 
{
65
 
        ut_ad(mbminlen < DATA_MBMAX);
66
 
        ut_ad(mbmaxlen < DATA_MBMAX);
67
 
        ut_ad(mbminlen <= mbmaxlen);
68
 
 
69
 
        col->mbminmaxlen = DATA_MBMINMAXLEN(mbminlen, mbmaxlen);
70
 
}
71
 
/*********************************************************************//**
72
32
Gets the column data type. */
73
33
UNIV_INLINE
74
34
void
82
42
        type->mtype = col->mtype;
83
43
        type->prtype = col->prtype;
84
44
        type->len = col->len;
85
 
        type->mbminmaxlen = col->mbminmaxlen;
 
45
        type->mbminlen = col->mbminlen;
 
46
        type->mbmaxlen = col->mbmaxlen;
86
47
}
87
48
#endif /* !UNIV_HOTBACKUP */
88
49
 
104
65
        ut_ad(col->prtype == type->prtype);
105
66
        ut_ad(col->len == type->len);
106
67
# ifndef UNIV_HOTBACKUP
107
 
        ut_ad(col->mbminmaxlen == type->mbminmaxlen);
 
68
        ut_ad(col->mbminlen == type->mbminlen);
 
69
        ut_ad(col->mbmaxlen == type->mbmaxlen);
108
70
# endif /* !UNIV_HOTBACKUP */
109
71
 
110
72
        return(TRUE);
122
84
        const dict_col_t*       col)    /*!< in: column */
123
85
{
124
86
        return(dtype_get_min_size_low(col->mtype, col->prtype, col->len,
125
 
                                      col->mbminmaxlen));
 
87
                                      col->mbminlen, col->mbmaxlen));
126
88
}
127
89
/***********************************************************************//**
128
90
Returns the maximum size of the column.
147
109
        ulint                   comp)   /*!< in: nonzero=ROW_FORMAT=COMPACT  */
148
110
{
149
111
        return(dtype_get_fixed_size_low(col->mtype, col->prtype, col->len,
150
 
                                        col->mbminmaxlen, comp));
 
112
                                        col->mbminlen, col->mbmaxlen, comp));
151
113
}
152
114
/***********************************************************************//**
153
115
Returns the ROW_FORMAT=REDUNDANT stored SQL NULL size of a column.
491
453
        return(dict_table_flags_to_zip_size(table->flags));
492
454
}
493
455
 
494
 
/*********************************************************************//**
495
 
Obtain exclusive locks on all index trees of the table. This is to prevent
496
 
accessing index trees while InnoDB is updating internal metadata for
497
 
operations such as truncate tables. */
498
 
UNIV_INLINE
499
 
void
500
 
dict_table_x_lock_indexes(
501
 
/*======================*/
502
 
        dict_table_t*   table)  /*!< in: table */
503
 
{
504
 
        dict_index_t*   index;
505
 
 
506
 
        ut_a(table);
507
 
        ut_ad(mutex_own(&(dict_sys->mutex)));
508
 
 
509
 
        /* Loop through each index of the table and lock them */
510
 
        for (index = dict_table_get_first_index(table);
511
 
             index != NULL;
512
 
             index = dict_table_get_next_index(index)) {
513
 
                rw_lock_x_lock(dict_index_get_lock(index));
514
 
        }
515
 
}
516
 
 
517
 
/*********************************************************************//**
518
 
Release the exclusive locks on all index tree. */
519
 
UNIV_INLINE
520
 
void
521
 
dict_table_x_unlock_indexes(
522
 
/*========================*/
523
 
        dict_table_t*   table)  /*!< in: table */
524
 
{
525
 
        dict_index_t*   index;
526
 
 
527
 
        ut_a(table);
528
 
        ut_ad(mutex_own(&(dict_sys->mutex)));
529
 
 
530
 
        for (index = dict_table_get_first_index(table);
531
 
             index != NULL;
532
 
             index = dict_table_get_next_index(index)) {
533
 
                rw_lock_x_unlock(dict_index_get_lock(index));
534
 
        }
535
 
}
536
456
/********************************************************************//**
537
457
Gets the number of fields in the internal representation of an index,
538
458
including fields added by the dictionary system.
846
766
        table = dict_table_check_if_in_cache_low(table_name);
847
767
 
848
768
        if (table == NULL) {
849
 
                table = dict_load_table(table_name, TRUE);
 
769
                table = dict_load_table(table_name);
850
770
        }
851
771
 
852
772
        ut_ad(!table || table->cached);
861
781
dict_table_t*
862
782
dict_table_get_on_id_low(
863
783
/*=====================*/
864
 
        table_id_t      table_id)       /*!< in: table id */
 
784
        dulint  table_id)       /*!< in: table id */
865
785
{
866
786
        dict_table_t*   table;
867
787
        ulint           fold;
869
789
        ut_ad(mutex_own(&(dict_sys->mutex)));
870
790
 
871
791
        /* Look for the table name in the hash table */
872
 
        fold = ut_fold_ull(table_id);
 
792
        fold = ut_fold_dulint(table_id);
873
793
 
874
794
        HASH_SEARCH(id_hash, dict_sys->table_id_hash, fold,
875
795
                    dict_table_t*, table, ut_ad(table->cached),
876
 
                    table->id == table_id);
 
796
                    !ut_dulint_cmp(table->id, table_id));
877
797
        if (table == NULL) {
878
798
                table = dict_load_table_on_id(table_id);
879
799
        }