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
141 dict_mem_table_create(
142 /*==================*/
143  const char* name,
144  ulint space,
148  ulint n_cols,
149  ulint flags);
150 /****************************************************************/
152 UNIV_INTERN
153 void
154 dict_mem_table_free(
155 /*================*/
156  dict_table_t* table);
157 /**********************************************************************/
159 UNIV_INTERN
160 void
161 dict_mem_table_add_col(
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
174 dict_mem_fill_column_struct(
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
204 dict_mem_index_create(
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
220 dict_mem_index_add_field(
221 /*=====================*/
222  dict_index_t* index,
223  const char* name,
224  ulint prefix_len);
227 /**********************************************************************/
229 UNIV_INTERN
230 void
231 dict_mem_index_free(
232 /*================*/
233  dict_index_t* index);
234 /**********************************************************************/
237 UNIV_INTERN
239 dict_mem_foreign_create(void);
240 /*=========================*/
241 
243 struct dict_col_struct{
244  /*----------------------*/
247  /* @{ */
248  unsigned mtype:8;
249  unsigned prtype:24;
257  /* the remaining fields do not affect alphabetical ordering: */
258 
259  unsigned len:16;
268  unsigned mbminmaxlen:5;
273  /*----------------------*/
274  /* End of definitions copied from dtype_t */
275  /* @} */
276 
277  unsigned ind:10;
279  unsigned ord_part:1;
282 };
292 #define DICT_MAX_INDEX_COL_LEN REC_MAX_INDEX_COL_LEN
293 
295 struct dict_field_struct{
297  const char* name;
298  unsigned prefix_len:10;
305  unsigned fixed_len:10;
308 };
312 struct dict_index_struct{
313  index_id_t id;
314  mem_heap_t* heap;
315  const char* name;
316  const char* table_name;
318 #ifndef UNIV_HOTBACKUP
319  unsigned space:32;
321  unsigned page:32;
322 #endif /* !UNIV_HOTBACKUP */
323  unsigned type:4;
325  unsigned trx_id_offset:10;
329  unsigned n_user_defined_cols:10;
333  unsigned n_uniq:10;
336  unsigned n_def:10;
337  unsigned n_fields:10;
338  unsigned n_nullable:10;
339  unsigned cached:1;
341  unsigned to_be_dropped:1;
346 #ifndef UNIV_HOTBACKUP
348  indexes;
350  /*----------------------*/
352  /* @{ */
353  ib_int64_t* stat_n_diff_key_vals;
360  ulint stat_index_size;
363  ulint stat_n_leaf_pages;
366  /* @} */
369  trx_id_t trx_id;
372 #endif /* !UNIV_HOTBACKUP */
373 #ifdef UNIV_DEBUG
374  ulint magic_n;
376 # define DICT_INDEX_MAGIC_N 76789786
377 #endif
378 };
379 
383 struct dict_foreign_struct{
384  mem_heap_t* heap;
386  char* id;
388  unsigned n_fields:10;
394  unsigned type:6;
396  char* foreign_table_name;
398  const char** foreign_col_names;
403  const char** referenced_col_names;
412  foreign_list;
417 };
418 
421 /* @{ */
422 #define DICT_FOREIGN_ON_DELETE_CASCADE 1
423 #define DICT_FOREIGN_ON_DELETE_SET_NULL 2
424 #define DICT_FOREIGN_ON_UPDATE_CASCADE 4
425 #define DICT_FOREIGN_ON_UPDATE_SET_NULL 8
426 #define DICT_FOREIGN_ON_DELETE_NO_ACTION 16
427 #define DICT_FOREIGN_ON_UPDATE_NO_ACTION 32
428 /* @} */
433 struct dict_table_struct{
434  table_id_t id;
435  mem_heap_t* heap;
436  char* name;
437  const char* dir_path_of_temp_table;
443  unsigned space:32;
446  unsigned flags:DICT_TF2_BITS;
447  unsigned ibd_file_missing:1;
452  unsigned tablespace_discarded:1;
457  unsigned cached:1;
459  unsigned n_def:10;
460  unsigned n_cols:10;
461  dict_col_t* cols;
462  const char* col_names;
468 #ifndef UNIV_HOTBACKUP
469  hash_node_t name_hash;
470  hash_node_t id_hash;
472  indexes;
474  foreign_list;
478  referenced_list;
481  table_LRU;
482  ulint n_mysql_handles_opened;
488  unsigned fk_max_recusive_level:8;
494  ulint n_foreign_key_checks_running;
500  trx_id_t query_cache_inv_trx_id;
509  locks;
510 #ifdef UNIV_DEBUG
511  /*----------------------*/
512  ibool does_not_fit_in_memory;
523 #endif /* UNIV_DEBUG */
524  /*----------------------*/
525  unsigned big_rows:1;
530  /* @{ */
531  unsigned stat_initialized:1;
534  ib_int64_t stat_n_rows;
537  ulint stat_clustered_index_size;
540  ulint stat_sum_of_other_index_sizes;
542  ulint stat_modified_counter;
555  /* @} */
556  /*----------------------*/
571  /* @{ */
572  lock_t* autoinc_lock;
580  mutex_t autoinc_mutex;
583  ib_uint64_t autoinc;
585  ulong n_waiting_or_granted_auto_inc_locks;
594  const trx_t* autoinc_trx;
597  /* @} */
598  /*----------------------*/
599 #endif /* !UNIV_HOTBACKUP */
600 
601 #ifdef UNIV_DEBUG
602  ulint magic_n;
604 # define DICT_TABLE_MAGIC_N 76333786
605 #endif /* UNIV_DEBUG */
606 };
607 
608 #ifndef UNIV_NONINL
609 #include "dict0mem.ic"
610 #endif
611 
612 #endif