Drizzled Public API Documentation

dict0mem.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3 Copyright (C) 1996, 2010, Innobase Oy. All Rights Reserved.
4 
5 This program is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License as published by the Free Software
7 Foundation; version 2 of the License.
8 
9 This program is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12 
13 You should have received a copy of the GNU General Public License along with
14 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
15 St, Fifth Floor, Boston, MA 02110-1301 USA
16 
17 *****************************************************************************/
18 
19 /**************************************************/
26 #pragma once
27 #ifndef dict0mem_h
28 #define dict0mem_h
29 
30 #include "univ.i"
31 #include "dict0types.h"
32 #include "data0type.h"
33 #include "mem0mem.h"
34 #include "rem0types.h"
35 #include "btr0types.h"
36 #ifndef UNIV_HOTBACKUP
37 # include "lock0types.h"
38 # include "que0types.h"
39 # include "sync0rw.h"
40 #endif /* !UNIV_HOTBACKUP */
41 #include "ut0mem.h"
42 #include "ut0lst.h"
43 #include "ut0rnd.h"
44 #include "ut0byte.h"
45 #include "hash0hash.h"
46 #include "trx0types.h"
47 
50 /* @{ */
51 #define DICT_CLUSTERED 1
52 #define DICT_UNIQUE 2
53 #define DICT_UNIVERSAL 4
55 #define DICT_IBUF 8
56 /* @} */
57 
59 #define DICT_TABLE_ORDINARY 1
60 #if 0 /* not implemented */
61 #define DICT_TABLE_CLUSTER_MEMBER 2
62 #define DICT_TABLE_CLUSTER 3 /* this means that the table is
63  really a cluster definition */
64 #endif
65 
67 /* @{ */
68 #define DICT_TF_COMPACT 1 /* Compact page format.
69  This must be set for
70  new file formats
71  (later than
72  DICT_TF_FORMAT_51). */
73 
75 /* @{ */
76 #define DICT_TF_ZSSIZE_SHIFT 1
77 #define DICT_TF_ZSSIZE_MASK (15 << DICT_TF_ZSSIZE_SHIFT)
78 #define DICT_TF_ZSSIZE_MAX (UNIV_PAGE_SIZE_SHIFT - PAGE_ZIP_MIN_SIZE_SHIFT + 1)
79 /* @} */
80 
82 /* @{ */
83 #define DICT_TF_FORMAT_SHIFT 5 /* file format */
84 #define DICT_TF_FORMAT_MASK \
85 ((~(~0 << (DICT_TF_BITS - DICT_TF_FORMAT_SHIFT))) << DICT_TF_FORMAT_SHIFT)
86 #define DICT_TF_FORMAT_51 0
87 #define DICT_TF_FORMAT_ZIP 1
91 #define DICT_TF_FORMAT_MAX DICT_TF_FORMAT_ZIP
92 
94 #define DICT_TF_FORMAT_MIN DICT_TF_FORMAT_51
95 
96 /* @} */
97 #define DICT_TF_BITS 6
98 #if (1 << (DICT_TF_BITS - DICT_TF_FORMAT_SHIFT)) <= DICT_TF_FORMAT_MAX
99 # error "DICT_TF_BITS is insufficient for DICT_TF_FORMAT_MAX"
100 #endif
101 /* @} */
102 
109 /* @{ */
110 #define DICT_TF2_SHIFT DICT_TF_BITS
111 
113 #define DICT_TF2_TEMPORARY 1
115 #define DICT_TF2_BITS (DICT_TF2_SHIFT + 1)
118 /* @} */
126 #define DICT_FK_MAX_RECURSIVE_LOAD 255
127 
134 #define FK_MAX_CASCADE_DEL 255
135 
136 /**********************************************************************/
139 UNIV_INTERN
142 /*==================*/
143  const char* name,
144  ulint space,
148  ulint n_cols,
149  ulint flags);
150 /****************************************************************/
152 UNIV_INTERN
153 void
155 /*================*/
156  dict_table_t* table);
157 /**********************************************************************/
159 UNIV_INTERN
160 void
162 /*===================*/
163  dict_table_t* table,
164  mem_heap_t* heap,
165  const char* name,
166  ulint mtype,
167  ulint prtype,
168  ulint len);
169 /**********************************************************************/
172 UNIV_INTERN
173 void
175 /*========================*/
176  dict_col_t* column,
178  ulint col_pos,
179  ulint mtype,
180  ulint prtype,
181  ulint col_len);
182 /**********************************************************************/
185 UNIV_INLINE
186 void
188 /*=======================*/
189  dict_index_t* index,
190  mem_heap_t* heap,
191  const char* table_name,
192  const char* index_name,
193  ulint space,
196  ulint type,
198  ulint n_fields);
199 /**********************************************************************/
202 UNIV_INTERN
205 /*==================*/
206  const char* table_name,
207  const char* index_name,
208  ulint space,
211  ulint type,
213  ulint n_fields);
214 /**********************************************************************/
218 UNIV_INTERN
219 void
221 /*=====================*/
222  dict_index_t* index,
223  const char* name,
224  ulint prefix_len);
227 /**********************************************************************/
229 UNIV_INTERN
230 void
232 /*================*/
233  dict_index_t* index);
234 /**********************************************************************/
237 UNIV_INTERN
240 /*=========================*/
241 
242 /**********************************************************************/
245 UNIV_INTERN
246 void
248 /*===================================*/
249  dict_foreign_t* foreign,
250  ibool do_alloc);
252 /**********************************************************************/
255 UNIV_INTERN
256 void
258 /*======================================*/
259  dict_foreign_t* foreign,
260  ibool do_alloc);
263 struct dict_col_struct{
264  /*----------------------*/
267  /* @{ */
268  unsigned mtype:8;
269  unsigned prtype:24;
277  /* the remaining fields do not affect alphabetical ordering: */
278 
279  unsigned len:16;
288  unsigned mbminmaxlen:5;
293  /*----------------------*/
294  /* End of definitions copied from dtype_t */
295  /* @} */
296 
297  unsigned ind:10;
299  unsigned ord_part:1;
302 };
312 #define DICT_MAX_INDEX_COL_LEN REC_MAX_INDEX_COL_LEN
313 
315 struct dict_field_struct{
317  const char* name;
318  unsigned prefix_len:10;
325  unsigned fixed_len:10;
328 };
332 struct dict_index_struct{
333  index_id_t id;
334  mem_heap_t* heap;
335  const char* name;
336  const char* table_name;
338 #ifndef UNIV_HOTBACKUP
339  unsigned space:32;
341  unsigned page:32;
342 #endif /* !UNIV_HOTBACKUP */
343  unsigned type:4;
345  unsigned trx_id_offset:10;
349  unsigned n_user_defined_cols:10;
353  unsigned n_uniq:10;
356  unsigned n_def:10;
357  unsigned n_fields:10;
358  unsigned n_nullable:10;
359  unsigned cached:1;
361  unsigned to_be_dropped:1;
365  unsigned corrupted:1;
368 #ifndef UNIV_HOTBACKUP
370  indexes;
372  /*----------------------*/
374  /* @{ */
375  ib_int64_t* stat_n_diff_key_vals;
382  ib_int64_t* stat_n_non_null_key_vals;
383  /* approximate number of non-null key values
384  for this index, for each column where
385  n < dict_get_n_unique(index); This
386  is used when innodb_stats_method is
387  "nulls_ignored". */
388  ulint stat_index_size;
391  ulint stat_n_leaf_pages;
394  /* @} */
397  trx_id_t trx_id;
400 #endif /* !UNIV_HOTBACKUP */
401 #ifdef UNIV_BLOB_DEBUG
402  mutex_t blobs_mutex;
404  void* blobs;
407 #endif /* UNIV_BLOB_DEBUG */
408 #ifdef UNIV_DEBUG
409  ulint magic_n;
411 # define DICT_INDEX_MAGIC_N 76789786
412 #endif
413 };
414 
418 struct dict_foreign_struct{
419  mem_heap_t* heap;
421  char* id;
423  unsigned n_fields:10;
429  unsigned type:6;
431  char* foreign_table_name;
435  const char** foreign_col_names;
437  char* referenced_table_name;
442  const char** referenced_col_names;
451  foreign_list;
456 };
457 
460 /* @{ */
461 #define DICT_FOREIGN_ON_DELETE_CASCADE 1
462 #define DICT_FOREIGN_ON_DELETE_SET_NULL 2
463 #define DICT_FOREIGN_ON_UPDATE_CASCADE 4
464 #define DICT_FOREIGN_ON_UPDATE_SET_NULL 8
465 #define DICT_FOREIGN_ON_DELETE_NO_ACTION 16
466 #define DICT_FOREIGN_ON_UPDATE_NO_ACTION 32
467 /* @} */
472 struct dict_table_struct{
473  table_id_t id;
474  mem_heap_t* heap;
475  char* name;
476  const char* dir_path_of_temp_table;
482  unsigned space:32;
485  unsigned flags:DICT_TF2_BITS;
486  unsigned ibd_file_missing:1;
491  unsigned tablespace_discarded:1;
496  unsigned cached:1;
498  unsigned n_def:10;
499  unsigned n_cols:10;
500  unsigned corrupted:1;
502  dict_col_t* cols;
503  const char* col_names;
509 #ifndef UNIV_HOTBACKUP
510  hash_node_t name_hash;
511  hash_node_t id_hash;
513  indexes;
515  foreign_list;
519  referenced_list;
522  table_LRU;
523  ulint n_mysql_handles_opened;
529  unsigned fk_max_recusive_level:8;
535  ulint n_foreign_key_checks_running;
541  trx_id_t query_cache_inv_trx_id;
550  locks;
551 #ifdef UNIV_DEBUG
552  /*----------------------*/
553  ibool does_not_fit_in_memory;
564 #endif /* UNIV_DEBUG */
565  /*----------------------*/
566  unsigned big_rows:1;
571  /* @{ */
572  unsigned stat_initialized:1;
575  ib_int64_t stat_n_rows;
578  ulint stat_clustered_index_size;
581  ulint stat_sum_of_other_index_sizes;
583  ulint stat_modified_counter;
596  /* @} */
597  /*----------------------*/
612  /* @{ */
613  lock_t* autoinc_lock;
621  mutex_t autoinc_mutex;
624  ib_uint64_t autoinc;
626  ulong n_waiting_or_granted_auto_inc_locks;
635  const trx_t* autoinc_trx;
638  /* @} */
639  /*----------------------*/
640 #endif /* !UNIV_HOTBACKUP */
641 
642 #ifdef UNIV_DEBUG
643  ulint magic_n;
645 # define DICT_TABLE_MAGIC_N 76333786
646 #endif /* UNIV_DEBUG */
647 };
648 
649 #ifndef UNIV_NONINL
650 #include "dict0mem.ic"
651 #endif
652 
653 #endif
UNIV_INTERN void dict_mem_index_add_field(dict_index_t *index, const char *name, ulint prefix_len)
Definition: dict0mem.cc:356
const char * name
Definition: dict0mem.h:339
ulint stat_index_size
Definition: dict0mem.h:392
unsigned trx_id_offset
Definition: dict0mem.h:349
dict_field_t * fields
Definition: dict0mem.h:371
char * foreign_table_name_lookup
Definition: dict0mem.h:436
unsigned space
Definition: dict0mem.h:343
char * foreign_table_name
Definition: dict0mem.h:435
unsigned type
Definition: dict0mem.h:347
UNIV_INLINE void dict_mem_fill_index_struct(dict_index_t *index, mem_heap_t *heap, const char *table_name, const char *index_name, ulint space, ulint type, ulint n_fields)
char * referenced_table_name_lookup
Definition: dict0mem.h:442
trx_id_t trx_id
Definition: dict0mem.h:401
mem_heap_t * heap
Definition: dict0mem.h:423
UNIV_INTERN dict_index_t * dict_mem_index_create(const char *table_name, const char *index_name, ulint space, ulint type, ulint n_fields)
Definition: dict0mem.cc:251
UNIV_INTERN void dict_mem_table_free(dict_table_t *table)
Definition: dict0mem.cc:111
unsigned prtype
Definition: dict0mem.h:273
unsigned n_nullable
Definition: dict0mem.h:362
unsigned len
Definition: dict0mem.h:283
unsigned page
Definition: dict0mem.h:345
char * referenced_table_name
Definition: dict0mem.h:441
unsigned n_user_defined_cols
Definition: dict0mem.h:353
unsigned ord_part
Definition: dict0mem.h:303
dict_index_t * foreign_index
Definition: dict0mem.h:448
typedef UT_LIST_BASE_NODE_T(mutex_t) ut_list_base_node_t
UNIV_INTERN void dict_mem_fill_column_struct(dict_col_t *column, ulint col_pos, ulint mtype, ulint prtype, ulint col_len)
Definition: dict0mem.cc:221
const char ** referenced_col_names
Definition: dict0mem.h:446
#define UT_LIST_NODE_T(TYPE)
Definition: ut0lst.h:73
unsigned to_be_dropped
Definition: dict0mem.h:365
unsigned prefix_len
Definition: dict0mem.h:322
ib_int64_t * stat_n_diff_key_vals
Definition: dict0mem.h:379
UNIV_INTERN dict_table_t * dict_mem_table_create(const char *name, ulint space, ulint n_cols, ulint flags)
Definition: dict0mem.cc:59
const char * name
Definition: dict0mem.h:321
unsigned cached
Definition: dict0mem.h:363
btr_search_t * search_info
Definition: dict0mem.h:375
dict_table_t * table
Definition: dict0mem.h:341
unsigned corrupted
Definition: dict0mem.h:369
unsigned ind
Definition: dict0mem.h:301
UNIV_INTERN void dict_mem_table_add_col(dict_table_t *table, mem_heap_t *heap, const char *name, ulint mtype, ulint prtype, ulint len)
Definition: dict0mem.cc:178
unsigned n_uniq
Definition: dict0mem.h:357
#define DICT_TF2_BITS
Definition: dict0mem.h:119
mem_heap_t * heap
Definition: dict0mem.h:338
UNIV_INTERN void dict_mem_foreign_table_name_lookup_set(dict_foreign_t *foreign, ibool do_alloc)
Definition: dict0mem.cc:303
UNIV_INTERN void dict_mem_index_free(dict_index_t *index)
Definition: dict0mem.cc:381
index_id_t id
Definition: dict0mem.h:337
dict_table_t * referenced_table
Definition: dict0mem.h:444
ib_id_t trx_id_t
Definition: trx0types.h:85
const char * table_name
Definition: dict0mem.h:340
unsigned n_fields
Definition: dict0mem.h:361
UNIV_INTERN dict_foreign_t * dict_mem_foreign_create(void)
Definition: dict0mem.cc:281
rw_lock_t lock
Definition: dict0mem.h:399
dict_col_t * col
Definition: dict0mem.h:320
unsigned n_fields
Definition: dict0mem.h:427
dict_table_t * foreign_table
Definition: dict0mem.h:438
unsigned n_def
Definition: dict0mem.h:360
UNIV_INTERN void dict_mem_referenced_table_name_lookup_set(dict_foreign_t *foreign, ibool do_alloc)
Definition: dict0mem.cc:330
unsigned mbminmaxlen
Definition: dict0mem.h:292
ulint stat_n_leaf_pages
Definition: dict0mem.h:395
const char ** foreign_col_names
Definition: dict0mem.h:439
unsigned mtype
Definition: dict0mem.h:272
dict_index_t * referenced_index
Definition: dict0mem.h:453
unsigned fixed_len
Definition: dict0mem.h:329