1
1
/*****************************************************************************
3
Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved.
3
Copyright (C) 1996, 2010, Innobase Oy. All Rights Reserved.
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
82
82
#define DICT_TF_FORMAT_SHIFT 5 /* file format */
83
#define DICT_TF_FORMAT_MASK (127 << DICT_TF_FORMAT_SHIFT)
83
#define DICT_TF_FORMAT_MASK \
84
((~(~0 << (DICT_TF_BITS - DICT_TF_FORMAT_SHIFT))) << DICT_TF_FORMAT_SHIFT)
84
85
#define DICT_TF_FORMAT_51 0 /*!< InnoDB/MySQL up to 5.1 */
85
86
#define DICT_TF_FORMAT_ZIP 1 /*!< InnoDB plugin for 5.1:
88
89
/** Maximum supported file format */
89
90
#define DICT_TF_FORMAT_MAX DICT_TF_FORMAT_ZIP
92
/** Minimum supported file format */
93
#define DICT_TF_FORMAT_MIN DICT_TF_FORMAT_51
91
96
#define DICT_TF_BITS 6 /*!< number of flag bits */
92
97
#if (1 << (DICT_TF_BITS - DICT_TF_FORMAT_SHIFT)) <= DICT_TF_FORMAT_MAX
93
98
# error "DICT_TF_BITS is insufficient for DICT_TF_FORMAT_MAX"
102
/** @brief Additional table flags.
104
These flags will be stored in SYS_TABLES.MIX_LEN. All unused flags
105
will be written as 0. The column may contain garbage for tables
106
created with old versions of InnoDB that only implemented
107
ROW_FORMAT=REDUNDANT. */
109
#define DICT_TF2_SHIFT DICT_TF_BITS
112
#define DICT_TF2_TEMPORARY 1 /*!< TRUE for tables from
113
CREATE TEMPORARY TABLE. */
114
#define DICT_TF2_BITS (DICT_TF2_SHIFT + 1)
115
/*!< Total number of bits
119
/** Tables could be chained together with Foreign key constraint. When
120
first load the parent table, we would load all of its descedents.
121
This could result in rescursive calls and out of stack error eventually.
122
DICT_FK_MAX_RECURSIVE_LOAD defines the maximum number of recursive loads,
123
when exceeded, the child table will not be loaded. It will be loaded when
124
the foreign constraint check needs to be run. */
125
#define DICT_FK_MAX_RECURSIVE_LOAD 255
127
/** Similarly, when tables are chained together with foreign key constraints
128
with on cascading delete/update clause, delete from parent table could
129
result in recursive cascading calls. This defines the maximum number of
130
such cascading deletes/updates allowed. When exceeded, the delete from
131
parent table will fail, and user has to drop excessive foreign constraint
133
#define FK_MAX_CASCADE_DEL 255
98
135
/**********************************************************************//**
99
136
Creates a table memory object.
100
137
@return own: table object */
129
166
ulint prtype, /*!< in: precise type */
130
167
ulint len); /*!< in: precision */
131
168
/**********************************************************************//**
169
This function populates a dict_col_t memory structure with
170
supplied information. */
173
dict_mem_fill_column_struct(
174
/*========================*/
175
dict_col_t* column, /*!< out: column struct to be
177
ulint col_pos, /*!< in: column position */
178
ulint mtype, /*!< in: main data type */
179
ulint prtype, /*!< in: precise type */
180
ulint col_len); /*!< in: column length */
181
/**********************************************************************//**
182
This function poplulates a dict_index_t index memory structure with
183
supplied information. */
186
dict_mem_fill_index_struct(
187
/*=======================*/
188
dict_index_t* index, /*!< out: index to be filled */
189
mem_heap_t* heap, /*!< in: memory heap */
190
const char* table_name, /*!< in: table name */
191
const char* index_name, /*!< in: index name */
192
ulint space, /*!< in: space where the index tree is
193
placed, ignored if the index is of
194
the clustered type */
195
ulint type, /*!< in: DICT_UNIQUE,
196
DICT_CLUSTERED, ... ORed */
197
ulint n_fields); /*!< in: number of fields */
198
/**********************************************************************//**
132
199
Creates an index memory object.
133
200
@return own: index object */
197
264
the string, MySQL uses 1 or 2
198
265
bytes to store the string length) */
200
unsigned mbminlen:2; /*!< minimum length of a
201
character, in bytes */
202
unsigned mbmaxlen:3; /*!< maximum length of a
203
character, in bytes */
267
unsigned mbminmaxlen:5; /*!< minimum and maximum length of a
269
DATA_MBMINMAXLEN(mbminlen,mbmaxlen);
270
mbminlen=DATA_MBMINLEN(mbminmaxlen);
271
mbmaxlen=DATA_MBMINLEN(mbminmaxlen) */
204
272
/*----------------------*/
205
273
/* End of definitions copied from dtype_t */
241
309
/** Data structure for an index. Most fields will be
242
310
initialized to 0, NULL or FALSE in dict_mem_index_create(). */
243
311
struct dict_index_struct{
244
dulint id; /*!< id of the index */
312
index_id_t id; /*!< id of the index */
245
313
mem_heap_t* heap; /*!< memory heap */
246
314
const char* name; /*!< index name */
247
315
const char* table_name;/*!< table name */
298
366
rw_lock_t lock; /*!< read-write lock protecting the
299
367
upper levels of the index tree */
300
ib_uint64_t trx_id; /*!< id of the transaction that created this
368
trx_id_t trx_id; /*!< id of the transaction that created this
301
369
index, or 0 if the index existed
302
370
when InnoDB was started up */
303
371
#endif /* !UNIV_HOTBACKUP */
362
430
/** Data structure for a database table. Most fields will be
363
431
initialized to 0, NULL or FALSE in dict_mem_table_create(). */
364
432
struct dict_table_struct{
365
dulint id; /*!< id of the table */
433
table_id_t id; /*!< id of the table */
366
434
mem_heap_t* heap; /*!< memory heap */
367
const char* name; /*!< table name */
435
char* name; /*!< table name */
368
436
const char* dir_path_of_temp_table;/*!< NULL or the directory path
369
437
where a TEMPORARY table that was explicitly
370
438
created by a user should be placed if
374
442
unsigned space:32;
375
443
/*!< space where the clustered index of the
376
444
table is placed */
377
unsigned flags:DICT_TF_BITS;/*!< DICT_TF_COMPACT, ... */
445
unsigned flags:DICT_TF2_BITS;/*!< DICT_TF_COMPACT, ... */
378
446
unsigned ibd_file_missing:1;
379
447
/*!< TRUE if this is in a single-table
380
448
tablespace and the .ibd file is missing; then
416
484
NOT allowed until this count gets to zero;
417
485
MySQL does NOT itself check the number of
418
486
open handles at drop */
487
unsigned fk_max_recusive_level:8;
488
/*!< maximum recursive level we support when
489
loading tables chained together with FK
490
constraints. If exceeds this level, we will
491
stop loading child table into memory along with
419
493
ulint n_foreign_key_checks_running;
420
494
/*!< count of how many foreign key check
421
495
operations are currently being performed