drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
dict0mem.h
Go to the documentation of this file.
1/*****************************************************************************
2
3Copyright (C) 1996, 2010, Innobase Oy. All Rights Reserved.
4
5This program is free software; you can redistribute it and/or modify it under
6the terms of the GNU General Public License as published by the Free Software
7Foundation; version 2 of the License.
8
9This program is distributed in the hope that it will be useful, but WITHOUT
10ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
13You should have received a copy of the GNU General Public License along with
14this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
15St, Fifth Floor, Boston, MA 02110-1301 USA
16
17*****************************************************************************/
18
19/**************************************************/
25
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
113#define DICT_TF2_TEMPORARY 1
115#define DICT_TF2_BITS (DICT_TF2_SHIFT + 1)
118/* @} */
119
126#define DICT_FK_MAX_RECURSIVE_LOAD 255
127
134#define FK_MAX_CASCADE_DEL 255
135
136/**********************************************************************/
139UNIV_INTERN
140dict_table_t*
142/*==================*/
143 const char* name,
144 ulint space,
148 ulint n_cols,
149 ulint flags);
150/****************************************************************/
152UNIV_INTERN
153void
155/*================*/
156 dict_table_t* table);
157/**********************************************************************/
159UNIV_INTERN
160void
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/**********************************************************************/
172UNIV_INTERN
173void
175/*========================*/
176 dict_col_t* column,
178 ulint col_pos,
179 ulint mtype,
180 ulint prtype,
181 ulint col_len);
182/**********************************************************************/
185UNIV_INLINE
186void
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/**********************************************************************/
202UNIV_INTERN
203dict_index_t*
205/*==================*/
206 const char* table_name,
207 const char* index_name,
208 ulint space,
211 ulint type,
213 ulint n_fields);
214/**********************************************************************/
218UNIV_INTERN
219void
221/*=====================*/
222 dict_index_t* index,
223 const char* name,
224 ulint prefix_len);
227/**********************************************************************/
229UNIV_INTERN
230void
232/*================*/
233 dict_index_t* index);
234/**********************************************************************/
237UNIV_INTERN
238dict_foreign_t*
240/*=========================*/
241
242/**********************************************************************/
245UNIV_INTERN
246void
248/*===================================*/
249 dict_foreign_t* foreign,
250 ibool do_alloc);
251
252/**********************************************************************/
255UNIV_INTERN
256void
258/*======================================*/
259 dict_foreign_t* foreign,
260 ibool do_alloc);
261
263struct dict_col_struct{
264 /*----------------------*/
267 /* @{ */
268 unsigned mtype:8;
269 unsigned prtype:24;
276
277 /* the remaining fields do not affect alphabetical ordering: */
278
279 unsigned len:16;
287
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};
303
311files would be at risk! */
312#define DICT_MAX_INDEX_COL_LEN REC_MAX_INDEX_COL_LEN
315struct dict_field_struct{
316 dict_col_t* col;
317 const char* name;
318 unsigned prefix_len:10;
325 unsigned fixed_len:10;
333 index_id_t id;
334 mem_heap_t* heap;
335 const char* name;
336 const char* table_name;
337 dict_table_t* table;
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;
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;
367 dict_field_t* fields;
368#ifndef UNIV_HOTBACKUP
369 UT_LIST_NODE_T(dict_index_t)
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;
394 /* @} */
395 rw_lock_t lock;
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;
410
411# define DICT_INDEX_MAGIC_N 76789786
412#endif
413};
419 mem_heap_t* heap;
421 char* id;
423 unsigned n_fields:10;
429 unsigned type:6;
434 dict_table_t* foreign_table;
435 const char** foreign_col_names;
440 dict_table_t* referenced_table;
442 const char** referenced_col_names;
444 dict_index_t* foreign_index;
449 dict_index_t* referenced_index;
450 UT_LIST_NODE_T(dict_foreign_t)
453 UT_LIST_NODE_T(dict_foreign_t)
456};
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/* @} */
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;
512 UT_LIST_BASE_NODE_T(dict_index_t)
513 indexes;
514 UT_LIST_BASE_NODE_T(dict_foreign_t)
518 UT_LIST_BASE_NODE_T(dict_foreign_t)
521 UT_LIST_NODE_T(dict_table_t)
522 table_LRU;
529 unsigned fk_max_recusive_level:8;
549 UT_LIST_BASE_NODE_T(lock_t)
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;
596 /* @} */
597 /*----------------------*/
612 /* @{ */
613 lock_t* autoinc_lock;
624 ib_uint64_t autoinc;
635 const trx_t* autoinc_trx;
638 /* @} */
639 /*----------------------*/
640#endif /* !UNIV_HOTBACKUP */
641
642#ifdef UNIV_DEBUG
643 ulint magic_n;
644
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
struct btr_search_struct btr_search_t
Definition btr0types.h:40
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:177
UNIV_INTERN void dict_mem_referenced_table_name_lookup_set(dict_foreign_t *foreign, ibool do_alloc)
Definition dict0mem.cc:329
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:220
UNIV_INTERN void dict_mem_index_add_field(dict_index_t *index, const char *name, ulint prefix_len)
Definition dict0mem.cc:355
UNIV_INTERN dict_table_t * dict_mem_table_create(const char *name, ulint space, ulint n_cols, ulint flags)
Definition dict0mem.cc:58
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)
UNIV_INTERN dict_foreign_t * dict_mem_foreign_create(void)
Definition dict0mem.cc:280
#define DICT_TF2_BITS
Definition dict0mem.h:111
UNIV_INTERN void dict_mem_foreign_table_name_lookup_set(dict_foreign_t *foreign, ibool do_alloc)
Definition dict0mem.cc:302
UNIV_INTERN void dict_mem_table_free(dict_table_t *table)
Definition dict0mem.cc:110
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:250
UNIV_INTERN void dict_mem_index_free(dict_index_t *index)
Definition dict0mem.cc:380
unsigned ind
Definition dict0mem.h:293
unsigned ord_part
Definition dict0mem.h:295
unsigned prtype
Definition dict0mem.h:265
unsigned mbminmaxlen
Definition dict0mem.h:284
unsigned len
Definition dict0mem.h:275
unsigned mtype
Definition dict0mem.h:264
unsigned fixed_len
Definition dict0mem.h:321
const char * name
Definition dict0mem.h:313
unsigned prefix_len
Definition dict0mem.h:314
dict_col_t * col
Definition dict0mem.h:312
char * referenced_table_name
Definition dict0mem.h:433
dict_index_t * referenced_index
Definition dict0mem.h:445
char * foreign_table_name_lookup
Definition dict0mem.h:428
dict_table_t * foreign_table
Definition dict0mem.h:430
const char ** foreign_col_names
Definition dict0mem.h:431
char * foreign_table_name
Definition dict0mem.h:427
mem_heap_t * heap
Definition dict0mem.h:415
dict_index_t * foreign_index
Definition dict0mem.h:440
const char ** referenced_col_names
Definition dict0mem.h:438
dict_table_t * referenced_table
Definition dict0mem.h:436
char * referenced_table_name_lookup
Definition dict0mem.h:434
btr_search_t * search_info
Definition dict0mem.h:367
unsigned to_be_dropped
Definition dict0mem.h:357
const char * table_name
Definition dict0mem.h:332
unsigned trx_id_offset
Definition dict0mem.h:341
unsigned cached
Definition dict0mem.h:355
mem_heap_t * heap
Definition dict0mem.h:330
unsigned n_user_defined_cols
Definition dict0mem.h:345
const char * name
Definition dict0mem.h:331
index_id_t id
Definition dict0mem.h:329
unsigned n_fields
Definition dict0mem.h:353
rw_lock_t lock
Definition dict0mem.h:391
ulint stat_index_size
Definition dict0mem.h:384
dict_table_t * table
Definition dict0mem.h:333
unsigned corrupted
Definition dict0mem.h:361
dict_field_t * fields
Definition dict0mem.h:363
ib_int64_t * stat_n_diff_key_vals
Definition dict0mem.h:371
ulint stat_n_leaf_pages
Definition dict0mem.h:387
unsigned n_uniq
Definition dict0mem.h:349
unsigned n_nullable
Definition dict0mem.h:354
trx_id_t trx_id
Definition dict0mem.h:393
unsigned cached
Definition dict0mem.h:492
unsigned n_cols
Definition dict0mem.h:495
mutex_t autoinc_mutex
Definition dict0mem.h:617
unsigned big_rows
Definition dict0mem.h:562
mem_heap_t * heap
Definition dict0mem.h:470
unsigned fk_max_recusive_level
Definition dict0mem.h:525
dict_col_t * cols
Definition dict0mem.h:498
unsigned tablespace_discarded
Definition dict0mem.h:487
ulint n_mysql_handles_opened
Definition dict0mem.h:519
const char * col_names
Definition dict0mem.h:499
hash_node_t name_hash
Definition dict0mem.h:506
ulint stat_clustered_index_size
Definition dict0mem.h:574
ib_int64_t stat_n_rows
Definition dict0mem.h:571
unsigned stat_initialized
Definition dict0mem.h:568
lock_t * autoinc_lock
Definition dict0mem.h:609
ulint stat_sum_of_other_index_sizes
Definition dict0mem.h:577
table_id_t id
Definition dict0mem.h:469
ulint n_foreign_key_checks_running
Definition dict0mem.h:531
trx_id_t query_cache_inv_trx_id
Definition dict0mem.h:537
ib_uint64_t autoinc
Definition dict0mem.h:620
ulong n_waiting_or_granted_auto_inc_locks
Definition dict0mem.h:622
ulint stat_modified_counter
Definition dict0mem.h:579
hash_node_t id_hash
Definition dict0mem.h:507
unsigned ibd_file_missing
Definition dict0mem.h:482
const char * dir_path_of_temp_table
Definition dict0mem.h:472
const trx_t * autoinc_trx
Definition dict0mem.h:631
unsigned corrupted
Definition dict0mem.h:496
#define mutex_t
Definition sync0types.h:31
ib_id_t trx_id_t
Definition trx0types.h:85
#define UT_LIST_NODE_T(TYPE)
Definition ut0lst.h:73
#define UT_LIST_BASE_NODE_T(TYPE)
Definition ut0lst.h:54