Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00026 #pragma once
00027 #ifndef dict0mem_h
00028 #define dict0mem_h
00029
00030 #include "univ.i"
00031 #include "dict0types.h"
00032 #include "data0type.h"
00033 #include "mem0mem.h"
00034 #include "rem0types.h"
00035 #include "btr0types.h"
00036 #ifndef UNIV_HOTBACKUP
00037 # include "lock0types.h"
00038 # include "que0types.h"
00039 # include "sync0rw.h"
00040 #endif
00041 #include "ut0mem.h"
00042 #include "ut0lst.h"
00043 #include "ut0rnd.h"
00044 #include "ut0byte.h"
00045 #include "hash0hash.h"
00046 #include "trx0types.h"
00047
00050
00051 #define DICT_CLUSTERED 1
00052 #define DICT_UNIQUE 2
00053 #define DICT_UNIVERSAL 4
00055 #define DICT_IBUF 8
00056
00057
00059 #define DICT_TABLE_ORDINARY 1
00060 #if 0
00061 #define DICT_TABLE_CLUSTER_MEMBER 2
00062 #define DICT_TABLE_CLUSTER 3
00063
00064 #endif
00065
00067
00068 #define DICT_TF_COMPACT 1
00069
00070
00071
00072
00073
00075
00076 #define DICT_TF_ZSSIZE_SHIFT 1
00077 #define DICT_TF_ZSSIZE_MASK (15 << DICT_TF_ZSSIZE_SHIFT)
00078 #define DICT_TF_ZSSIZE_MAX (UNIV_PAGE_SIZE_SHIFT - PAGE_ZIP_MIN_SIZE_SHIFT + 1)
00079
00080
00082
00083 #define DICT_TF_FORMAT_SHIFT 5
00084 #define DICT_TF_FORMAT_MASK \
00085 ((~(~0 << (DICT_TF_BITS - DICT_TF_FORMAT_SHIFT))) << DICT_TF_FORMAT_SHIFT)
00086 #define DICT_TF_FORMAT_51 0
00087 #define DICT_TF_FORMAT_ZIP 1
00091 #define DICT_TF_FORMAT_MAX DICT_TF_FORMAT_ZIP
00092
00094 #define DICT_TF_FORMAT_MIN DICT_TF_FORMAT_51
00095
00096
00097 #define DICT_TF_BITS 6
00098 #if (1 << (DICT_TF_BITS - DICT_TF_FORMAT_SHIFT)) <= DICT_TF_FORMAT_MAX
00099 # error "DICT_TF_BITS is insufficient for DICT_TF_FORMAT_MAX"
00100 #endif
00101
00102
00109
00110 #define DICT_TF2_SHIFT DICT_TF_BITS
00111
00113 #define DICT_TF2_TEMPORARY 1
00115 #define DICT_TF2_BITS (DICT_TF2_SHIFT + 1)
00116
00118
00119
00126 #define DICT_FK_MAX_RECURSIVE_LOAD 255
00127
00134 #define FK_MAX_CASCADE_DEL 255
00135
00136
00139 UNIV_INTERN
00140 dict_table_t*
00141 dict_mem_table_create(
00142
00143 const char* name,
00144 ulint space,
00148 ulint n_cols,
00149 ulint flags);
00150
00152 UNIV_INTERN
00153 void
00154 dict_mem_table_free(
00155
00156 dict_table_t* table);
00157
00159 UNIV_INTERN
00160 void
00161 dict_mem_table_add_col(
00162
00163 dict_table_t* table,
00164 mem_heap_t* heap,
00165 const char* name,
00166 ulint mtype,
00167 ulint prtype,
00168 ulint len);
00169
00172 UNIV_INTERN
00173 void
00174 dict_mem_fill_column_struct(
00175
00176 dict_col_t* column,
00178 ulint col_pos,
00179 ulint mtype,
00180 ulint prtype,
00181 ulint col_len);
00182
00185 UNIV_INLINE
00186 void
00187 dict_mem_fill_index_struct(
00188
00189 dict_index_t* index,
00190 mem_heap_t* heap,
00191 const char* table_name,
00192 const char* index_name,
00193 ulint space,
00196 ulint type,
00198 ulint n_fields);
00199
00202 UNIV_INTERN
00203 dict_index_t*
00204 dict_mem_index_create(
00205
00206 const char* table_name,
00207 const char* index_name,
00208 ulint space,
00211 ulint type,
00213 ulint n_fields);
00214
00218 UNIV_INTERN
00219 void
00220 dict_mem_index_add_field(
00221
00222 dict_index_t* index,
00223 const char* name,
00224 ulint prefix_len);
00227
00229 UNIV_INTERN
00230 void
00231 dict_mem_index_free(
00232
00233 dict_index_t* index);
00234
00237 UNIV_INTERN
00238 dict_foreign_t*
00239 dict_mem_foreign_create(void);
00240
00241
00243 struct dict_col_struct{
00244
00247
00248 unsigned mtype:8;
00249 unsigned prtype:24;
00257
00258
00259 unsigned len:16;
00268 unsigned mbminmaxlen:5;
00273
00274
00275
00276
00277 unsigned ind:10;
00279 unsigned ord_part:1;
00282 };
00283
00292 #define DICT_MAX_INDEX_COL_LEN REC_MAX_INDEX_COL_LEN
00293
00295 struct dict_field_struct{
00296 dict_col_t* col;
00297 const char* name;
00298 unsigned prefix_len:10;
00305 unsigned fixed_len:10;
00308 };
00309
00312 struct dict_index_struct{
00313 index_id_t id;
00314 mem_heap_t* heap;
00315 const char* name;
00316 const char* table_name;
00317 dict_table_t* table;
00318 #ifndef UNIV_HOTBACKUP
00319 unsigned space:32;
00321 unsigned page:32;
00322 #endif
00323 unsigned type:4;
00325 unsigned trx_id_offset:10;
00329 unsigned n_user_defined_cols:10;
00333 unsigned n_uniq:10;
00336 unsigned n_def:10;
00337 unsigned n_fields:10;
00338 unsigned n_nullable:10;
00339 unsigned cached:1;
00341 unsigned to_be_dropped:1;
00345 dict_field_t* fields;
00346 #ifndef UNIV_HOTBACKUP
00347 UT_LIST_NODE_T(dict_index_t)
00348 indexes;
00349 btr_search_t* search_info;
00350
00352
00353 ib_int64_t* stat_n_diff_key_vals;
00360 ulint stat_index_size;
00363 ulint stat_n_leaf_pages;
00366
00367 rw_lock_t lock;
00369 trx_id_t trx_id;
00372 #endif
00373 #ifdef UNIV_DEBUG
00374 ulint magic_n;
00376 # define DICT_INDEX_MAGIC_N 76789786
00377 #endif
00378 };
00379
00383 struct dict_foreign_struct{
00384 mem_heap_t* heap;
00386 char* id;
00388 unsigned n_fields:10;
00394 unsigned type:6;
00396 char* foreign_table_name;
00397 dict_table_t* foreign_table;
00398 const char** foreign_col_names;
00400 char* referenced_table_name;
00401 dict_table_t* referenced_table;
00403 const char** referenced_col_names;
00405 dict_index_t* foreign_index;
00410 dict_index_t* referenced_index;
00411 UT_LIST_NODE_T(dict_foreign_t)
00412 foreign_list;
00414 UT_LIST_NODE_T(dict_foreign_t)
00415 referenced_list;
00417 };
00418
00421
00422 #define DICT_FOREIGN_ON_DELETE_CASCADE 1
00423 #define DICT_FOREIGN_ON_DELETE_SET_NULL 2
00424 #define DICT_FOREIGN_ON_UPDATE_CASCADE 4
00425 #define DICT_FOREIGN_ON_UPDATE_SET_NULL 8
00426 #define DICT_FOREIGN_ON_DELETE_NO_ACTION 16
00427 #define DICT_FOREIGN_ON_UPDATE_NO_ACTION 32
00428
00429
00430
00433 struct dict_table_struct{
00434 table_id_t id;
00435 mem_heap_t* heap;
00436 char* name;
00437 const char* dir_path_of_temp_table;
00443 unsigned space:32;
00446 unsigned flags:DICT_TF2_BITS;
00447 unsigned ibd_file_missing:1;
00452 unsigned tablespace_discarded:1;
00457 unsigned cached:1;
00459 unsigned n_def:10;
00460 unsigned n_cols:10;
00461 dict_col_t* cols;
00462 const char* col_names;
00468 #ifndef UNIV_HOTBACKUP
00469 hash_node_t name_hash;
00470 hash_node_t id_hash;
00471 UT_LIST_BASE_NODE_T(dict_index_t)
00472 indexes;
00473 UT_LIST_BASE_NODE_T(dict_foreign_t)
00474 foreign_list;
00477 UT_LIST_BASE_NODE_T(dict_foreign_t)
00478 referenced_list;
00480 UT_LIST_NODE_T(dict_table_t)
00481 table_LRU;
00482 ulint n_mysql_handles_opened;
00488 unsigned fk_max_recusive_level:8;
00494 ulint n_foreign_key_checks_running;
00500 trx_id_t query_cache_inv_trx_id;
00508 UT_LIST_BASE_NODE_T(lock_t)
00509 locks;
00510 #ifdef UNIV_DEBUG
00511
00512 ibool does_not_fit_in_memory;
00523 #endif
00524
00525 unsigned big_rows:1;
00530
00531 unsigned stat_initialized:1;
00534 ib_int64_t stat_n_rows;
00537 ulint stat_clustered_index_size;
00540 ulint stat_sum_of_other_index_sizes;
00542 ulint stat_modified_counter;
00555
00556
00571
00572 lock_t* autoinc_lock;
00580 mutex_t autoinc_mutex;
00583 ib_uint64_t autoinc;
00585 ulong n_waiting_or_granted_auto_inc_locks;
00594 const trx_t* autoinc_trx;
00597
00598
00599 #endif
00600
00601 #ifdef UNIV_DEBUG
00602 ulint magic_n;
00604 # define DICT_TABLE_MAGIC_N 76333786
00605 #endif
00606 };
00607
00608 #ifndef UNIV_NONINL
00609 #include "dict0mem.ic"
00610 #endif
00611
00612 #endif