~vadim-tk/percona-server/percona-galera-5.1.57

« back to all changes in this revision

Viewing changes to storage/innodb_plugin/include/dict0mem.h

  • Committer: root
  • Date: 2011-07-10 16:09:24 UTC
  • Revision ID: root@r815.office.percona.com-20110710160924-fyffqsbaclgu6vui
Initial port

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*****************************************************************************
 
2
 
 
3
Copyright (c) 1996, 2009, 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., 59 Temple
 
15
Place, Suite 330, Boston, MA 02111-1307 USA
 
16
 
 
17
*****************************************************************************/
 
18
 
 
19
/**************************************************//**
 
20
@file include/dict0mem.h
 
21
Data dictionary memory object creation
 
22
 
 
23
Created 1/8/1996 Heikki Tuuri
 
24
*******************************************************/
 
25
 
 
26
#ifndef dict0mem_h
 
27
#define dict0mem_h
 
28
 
 
29
#include "univ.i"
 
30
#include "dict0types.h"
 
31
#include "data0type.h"
 
32
#include "mem0mem.h"
 
33
#include "rem0types.h"
 
34
#include "btr0types.h"
 
35
#ifndef UNIV_HOTBACKUP
 
36
# include "lock0types.h"
 
37
# include "que0types.h"
 
38
# include "sync0rw.h"
 
39
#endif /* !UNIV_HOTBACKUP */
 
40
#include "ut0mem.h"
 
41
#include "ut0lst.h"
 
42
#include "ut0rnd.h"
 
43
#include "ut0byte.h"
 
44
#include "hash0hash.h"
 
45
#include "trx0types.h"
 
46
 
 
47
/** Type flags of an index: OR'ing of the flags is allowed to define a
 
48
combination of types */
 
49
/* @{ */
 
50
#define DICT_CLUSTERED  1       /*!< clustered index */
 
51
#define DICT_UNIQUE     2       /*!< unique index */
 
52
#define DICT_UNIVERSAL  4       /*!< index which can contain records from any
 
53
                                other index */
 
54
#define DICT_IBUF       8       /*!< insert buffer tree */
 
55
/* @} */
 
56
 
 
57
/** Types for a table object */
 
58
#define DICT_TABLE_ORDINARY             1 /*!< ordinary table */
 
59
#if 0 /* not implemented */
 
60
#define DICT_TABLE_CLUSTER_MEMBER       2
 
61
#define DICT_TABLE_CLUSTER              3 /* this means that the table is
 
62
                                          really a cluster definition */
 
63
#endif
 
64
 
 
65
/** Table flags.  All unused bits must be 0. */
 
66
/* @{ */
 
67
#define DICT_TF_COMPACT                 1       /* Compact page format.
 
68
                                                This must be set for
 
69
                                                new file formats
 
70
                                                (later than
 
71
                                                DICT_TF_FORMAT_51). */
 
72
 
 
73
/** Compressed page size (0=uncompressed, up to 15 compressed sizes) */
 
74
/* @{ */
 
75
#define DICT_TF_ZSSIZE_SHIFT            1
 
76
#define DICT_TF_ZSSIZE_MASK             (15 << DICT_TF_ZSSIZE_SHIFT)
 
77
#define DICT_TF_ZSSIZE_MAX (UNIV_PAGE_SIZE_SHIFT - PAGE_ZIP_MIN_SIZE_SHIFT + 1)
 
78
/* @} */
 
79
 
 
80
/** File format */
 
81
/* @{ */
 
82
#define DICT_TF_FORMAT_SHIFT            5       /* file format */
 
83
#define DICT_TF_FORMAT_MASK             \
 
84
((~(~0 << (DICT_TF_BITS - DICT_TF_FORMAT_SHIFT))) << DICT_TF_FORMAT_SHIFT)
 
85
#define DICT_TF_FORMAT_51               0       /*!< InnoDB/MySQL up to 5.1 */
 
86
#define DICT_TF_FORMAT_ZIP              1       /*!< InnoDB plugin for 5.1:
 
87
                                                compressed tables,
 
88
                                                new BLOB treatment */
 
89
/** Maximum supported file format */
 
90
#define DICT_TF_FORMAT_MAX              DICT_TF_FORMAT_ZIP
 
91
/* @} */
 
92
#define DICT_TF_BITS                    6       /*!< number of flag bits */
 
93
#if (1 << (DICT_TF_BITS - DICT_TF_FORMAT_SHIFT)) <= DICT_TF_FORMAT_MAX
 
94
# error "DICT_TF_BITS is insufficient for DICT_TF_FORMAT_MAX"
 
95
#endif
 
96
/* @} */
 
97
 
 
98
/** @brief Additional table flags.
 
99
 
 
100
These flags will be stored in SYS_TABLES.MIX_LEN.  All unused flags
 
101
will be written as 0.  The column may contain garbage for tables
 
102
created with old versions of InnoDB that only implemented
 
103
ROW_FORMAT=REDUNDANT. */
 
104
/* @{ */
 
105
#define DICT_TF2_SHIFT                  DICT_TF_BITS
 
106
                                                /*!< Shift value for
 
107
                                                table->flags. */
 
108
#define DICT_TF2_TEMPORARY              1       /*!< TRUE for tables from
 
109
                                                CREATE TEMPORARY TABLE. */
 
110
#define DICT_TF2_BITS                   (DICT_TF2_SHIFT + 1)
 
111
                                                /*!< Total number of bits
 
112
                                                in table->flags. */
 
113
/* @} */
 
114
 
 
115
/** Tables could be chained together with Foreign key constraint. When
 
116
first load the parent table, we would load all of its descedents.
 
117
This could result in rescursive calls and out of stack error eventually.
 
118
DICT_FK_MAX_RECURSIVE_LOAD defines the maximum number of recursive loads,
 
119
when exceeded, the child table will not be loaded. It will be loaded when
 
120
the foreign constraint check needs to be run. */
 
121
#define DICT_FK_MAX_RECURSIVE_LOAD      250
 
122
 
 
123
/** Similarly, when tables are chained together with foreign key constraints
 
124
with on cascading delete/update clause, delete from parent table could
 
125
result in recursive cascading calls. This defines the maximum number of
 
126
such cascading deletes/updates allowed. When exceeded, the delete from
 
127
parent table will fail, and user has to drop excessive foreign constraint
 
128
before proceeds. */
 
129
#define FK_MAX_CASCADE_DEL              300
 
130
 
 
131
/**********************************************************************//**
 
132
Creates a table memory object.
 
133
@return own: table object */
 
134
UNIV_INTERN
 
135
dict_table_t*
 
136
dict_mem_table_create(
 
137
/*==================*/
 
138
        const char*     name,           /*!< in: table name */
 
139
        ulint           space,          /*!< in: space where the clustered index
 
140
                                        of the table is placed; this parameter
 
141
                                        is ignored if the table is made
 
142
                                        a member of a cluster */
 
143
        ulint           n_cols,         /*!< in: number of columns */
 
144
        ulint           flags);         /*!< in: table flags */
 
145
/****************************************************************//**
 
146
Free a table memory object. */
 
147
UNIV_INTERN
 
148
void
 
149
dict_mem_table_free(
 
150
/*================*/
 
151
        dict_table_t*   table);         /*!< in: table */
 
152
/**********************************************************************//**
 
153
Adds a column definition to a table. */
 
154
UNIV_INTERN
 
155
void
 
156
dict_mem_table_add_col(
 
157
/*===================*/
 
158
        dict_table_t*   table,  /*!< in: table */
 
159
        mem_heap_t*     heap,   /*!< in: temporary memory heap, or NULL */
 
160
        const char*     name,   /*!< in: column name, or NULL */
 
161
        ulint           mtype,  /*!< in: main datatype */
 
162
        ulint           prtype, /*!< in: precise type */
 
163
        ulint           len);   /*!< in: precision */
 
164
/**********************************************************************//**
 
165
Creates an index memory object.
 
166
@return own: index object */
 
167
UNIV_INTERN
 
168
dict_index_t*
 
169
dict_mem_index_create(
 
170
/*==================*/
 
171
        const char*     table_name,     /*!< in: table name */
 
172
        const char*     index_name,     /*!< in: index name */
 
173
        ulint           space,          /*!< in: space where the index tree is
 
174
                                        placed, ignored if the index is of
 
175
                                        the clustered type */
 
176
        ulint           type,           /*!< in: DICT_UNIQUE,
 
177
                                        DICT_CLUSTERED, ... ORed */
 
178
        ulint           n_fields);      /*!< in: number of fields */
 
179
/**********************************************************************//**
 
180
Adds a field definition to an index. NOTE: does not take a copy
 
181
of the column name if the field is a column. The memory occupied
 
182
by the column name may be released only after publishing the index. */
 
183
UNIV_INTERN
 
184
void
 
185
dict_mem_index_add_field(
 
186
/*=====================*/
 
187
        dict_index_t*   index,          /*!< in: index */
 
188
        const char*     name,           /*!< in: column name */
 
189
        ulint           prefix_len);    /*!< in: 0 or the column prefix length
 
190
                                        in a MySQL index like
 
191
                                        INDEX (textcol(25)) */
 
192
/**********************************************************************//**
 
193
Frees an index memory object. */
 
194
UNIV_INTERN
 
195
void
 
196
dict_mem_index_free(
 
197
/*================*/
 
198
        dict_index_t*   index); /*!< in: index */
 
199
/**********************************************************************//**
 
200
Creates and initializes a foreign constraint memory object.
 
201
@return own: foreign constraint struct */
 
202
UNIV_INTERN
 
203
dict_foreign_t*
 
204
dict_mem_foreign_create(void);
 
205
/*=========================*/
 
206
 
 
207
/** Data structure for a column in a table */
 
208
struct dict_col_struct{
 
209
        /*----------------------*/
 
210
        /** The following are copied from dtype_t,
 
211
        so that all bit-fields can be packed tightly. */
 
212
        /* @{ */
 
213
        unsigned        mtype:8;        /*!< main data type */
 
214
        unsigned        prtype:24;      /*!< precise type; MySQL data
 
215
                                        type, charset code, flags to
 
216
                                        indicate nullability,
 
217
                                        signedness, whether this is a
 
218
                                        binary string, whether this is
 
219
                                        a true VARCHAR where MySQL
 
220
                                        uses 2 bytes to store the length */
 
221
 
 
222
        /* the remaining fields do not affect alphabetical ordering: */
 
223
 
 
224
        unsigned        len:16;         /*!< length; for MySQL data this
 
225
                                        is field->pack_length(),
 
226
                                        except that for a >= 5.0.3
 
227
                                        type true VARCHAR this is the
 
228
                                        maximum byte length of the
 
229
                                        string data (in addition to
 
230
                                        the string, MySQL uses 1 or 2
 
231
                                        bytes to store the string length) */
 
232
 
 
233
        unsigned        mbminlen:2;     /*!< minimum length of a
 
234
                                        character, in bytes */
 
235
        unsigned        mbmaxlen:3;     /*!< maximum length of a
 
236
                                        character, in bytes */
 
237
        /*----------------------*/
 
238
        /* End of definitions copied from dtype_t */
 
239
        /* @} */
 
240
 
 
241
        unsigned        ind:10;         /*!< table column position
 
242
                                        (starting from 0) */
 
243
        unsigned        ord_part:1;     /*!< nonzero if this column
 
244
                                        appears in the ordering fields
 
245
                                        of an index */
 
246
};
 
247
 
 
248
/** @brief DICT_MAX_INDEX_COL_LEN is measured in bytes and is the maximum
 
249
indexed column length (or indexed prefix length).
 
250
 
 
251
It is set to 3*256, so that one can create a column prefix index on
 
252
256 characters of a TEXT or VARCHAR column also in the UTF-8
 
253
charset. In that charset, a character may take at most 3 bytes.  This
 
254
constant MUST NOT BE CHANGED, or the compatibility of InnoDB data
 
255
files would be at risk! */
 
256
#define DICT_MAX_INDEX_COL_LEN          REC_MAX_INDEX_COL_LEN
 
257
#ifdef WITH_WSREP
 
258
#define WSREP_MAX_SUPPORTED_KEY_LENGTH 3500
 
259
#endif /* WITH_WSREP */
 
260
 
 
261
/** Data structure for a field in an index */
 
262
struct dict_field_struct{
 
263
        dict_col_t*     col;            /*!< pointer to the table column */
 
264
        const char*     name;           /*!< name of the column */
 
265
        unsigned        prefix_len:10;  /*!< 0 or the length of the column
 
266
                                        prefix in bytes in a MySQL index of
 
267
                                        type, e.g., INDEX (textcol(25));
 
268
                                        must be smaller than
 
269
                                        DICT_MAX_INDEX_COL_LEN; NOTE that
 
270
                                        in the UTF-8 charset, MySQL sets this
 
271
                                        to 3 * the prefix len in UTF-8 chars */
 
272
        unsigned        fixed_len:10;   /*!< 0 or the fixed length of the
 
273
                                        column if smaller than
 
274
                                        DICT_MAX_INDEX_COL_LEN */
 
275
};
 
276
 
 
277
/** Data structure for an index.  Most fields will be
 
278
initialized to 0, NULL or FALSE in dict_mem_index_create(). */
 
279
struct dict_index_struct{
 
280
        dulint          id;     /*!< id of the index */
 
281
        mem_heap_t*     heap;   /*!< memory heap */
 
282
        const char*     name;   /*!< index name */
 
283
        const char*     table_name;/*!< table name */
 
284
        dict_table_t*   table;  /*!< back pointer to table */
 
285
#ifndef UNIV_HOTBACKUP
 
286
        unsigned        space:32;
 
287
                                /*!< space where the index tree is placed */
 
288
        unsigned        page:32;/*!< index tree root page number */
 
289
#endif /* !UNIV_HOTBACKUP */
 
290
        unsigned        type:4; /*!< index type (DICT_CLUSTERED, DICT_UNIQUE,
 
291
                                DICT_UNIVERSAL, DICT_IBUF) */
 
292
        unsigned        trx_id_offset:10;/*!< position of the trx id column
 
293
                                in a clustered index record, if the fields
 
294
                                before it are known to be of a fixed size,
 
295
                                0 otherwise */
 
296
        unsigned        n_user_defined_cols:10;
 
297
                                /*!< number of columns the user defined to
 
298
                                be in the index: in the internal
 
299
                                representation we add more columns */
 
300
        unsigned        n_uniq:10;/*!< number of fields from the beginning
 
301
                                which are enough to determine an index
 
302
                                entry uniquely */
 
303
        unsigned        n_def:10;/*!< number of fields defined so far */
 
304
        unsigned        n_fields:10;/*!< number of fields in the index */
 
305
        unsigned        n_nullable:10;/*!< number of nullable fields */
 
306
        unsigned        cached:1;/*!< TRUE if the index object is in the
 
307
                                dictionary cache */
 
308
        unsigned        to_be_dropped:1;
 
309
                                /*!< TRUE if this index is marked to be
 
310
                                dropped in ha_innobase::prepare_drop_index(),
 
311
                                otherwise FALSE */
 
312
        dict_field_t*   fields; /*!< array of field descriptions */
 
313
#ifndef UNIV_HOTBACKUP
 
314
        UT_LIST_NODE_T(dict_index_t)
 
315
                        indexes;/*!< list of indexes of the table */
 
316
        btr_search_t*   search_info; /*!< info used in optimistic searches */
 
317
        /*----------------------*/
 
318
        /** Statistics for query optimization */
 
319
        /* @{ */
 
320
        ib_int64_t*     stat_n_diff_key_vals;
 
321
                                /*!< approximate number of different
 
322
                                key values for this index, for each
 
323
                                n-column prefix where n <=
 
324
                                dict_get_n_unique(index); we
 
325
                                periodically calculate new
 
326
                                estimates */
 
327
        ib_int64_t*     stat_n_non_null_key_vals;
 
328
                                /* approximate number of non-null key values
 
329
                                for this index, for each column where
 
330
                                n < dict_get_n_unique(index); This
 
331
                                is used when innodb_stats_method is
 
332
                                "nulls_ignored". */
 
333
        ulint           stat_index_size;
 
334
                                /*!< approximate index size in
 
335
                                database pages */
 
336
        ulint           stat_n_leaf_pages;
 
337
                                /*!< approximate number of leaf pages in the
 
338
                                index tree */
 
339
        /* @} */
 
340
        rw_lock_t       lock;   /*!< read-write lock protecting the
 
341
                                upper levels of the index tree */
 
342
        ib_uint64_t     trx_id; /*!< id of the transaction that created this
 
343
                                index, or 0 if the index existed
 
344
                                when InnoDB was started up */
 
345
#endif /* !UNIV_HOTBACKUP */
 
346
#ifdef UNIV_BLOB_DEBUG
 
347
        mutex_t         blobs_mutex;
 
348
                                /*!< mutex protecting blobs */
 
349
        void*           blobs;  /*!< map of (page_no,heap_no,field_no)
 
350
                                to first_blob_page_no; protected by
 
351
                                blobs_mutex; @see btr_blob_dbg_t */
 
352
#endif /* UNIV_BLOB_DEBUG */
 
353
#ifdef UNIV_DEBUG
 
354
        ulint           magic_n;/*!< magic number */
 
355
/** Value of dict_index_struct::magic_n */
 
356
# define DICT_INDEX_MAGIC_N     76789786
 
357
#endif
 
358
};
 
359
 
 
360
/** Data structure for a foreign key constraint; an example:
 
361
FOREIGN KEY (A, B) REFERENCES TABLE2 (C, D).  Most fields will be
 
362
initialized to 0, NULL or FALSE in dict_mem_foreign_create(). */
 
363
struct dict_foreign_struct{
 
364
        mem_heap_t*     heap;           /*!< this object is allocated from
 
365
                                        this memory heap */
 
366
        char*           id;             /*!< id of the constraint as a
 
367
                                        null-terminated string */
 
368
        unsigned        n_fields:10;    /*!< number of indexes' first fields
 
369
                                        for which the foreign key
 
370
                                        constraint is defined: we allow the
 
371
                                        indexes to contain more fields than
 
372
                                        mentioned in the constraint, as long
 
373
                                        as the first fields are as mentioned */
 
374
        unsigned        type:6;         /*!< 0 or DICT_FOREIGN_ON_DELETE_CASCADE
 
375
                                        or DICT_FOREIGN_ON_DELETE_SET_NULL */
 
376
        char*           foreign_table_name;/*!< foreign table name */
 
377
        dict_table_t*   foreign_table;  /*!< table where the foreign key is */
 
378
        const char**    foreign_col_names;/*!< names of the columns in the
 
379
                                        foreign key */
 
380
        char*           referenced_table_name;/*!< referenced table name */
 
381
        dict_table_t*   referenced_table;/*!< table where the referenced key
 
382
                                        is */
 
383
        const char**    referenced_col_names;/*!< names of the referenced
 
384
                                        columns in the referenced table */
 
385
        dict_index_t*   foreign_index;  /*!< foreign index; we require that
 
386
                                        both tables contain explicitly defined
 
387
                                        indexes for the constraint: InnoDB
 
388
                                        does not generate new indexes
 
389
                                        implicitly */
 
390
        dict_index_t*   referenced_index;/*!< referenced index */
 
391
        UT_LIST_NODE_T(dict_foreign_t)
 
392
                        foreign_list;   /*!< list node for foreign keys of the
 
393
                                        table */
 
394
        UT_LIST_NODE_T(dict_foreign_t)
 
395
                        referenced_list;/*!< list node for referenced
 
396
                                        keys of the table */
 
397
};
 
398
 
 
399
/** The flags for ON_UPDATE and ON_DELETE can be ORed; the default is that
 
400
a foreign key constraint is enforced, therefore RESTRICT just means no flag */
 
401
/* @{ */
 
402
#define DICT_FOREIGN_ON_DELETE_CASCADE  1       /*!< ON DELETE CASCADE */
 
403
#define DICT_FOREIGN_ON_DELETE_SET_NULL 2       /*!< ON UPDATE SET NULL */
 
404
#define DICT_FOREIGN_ON_UPDATE_CASCADE  4       /*!< ON DELETE CASCADE */
 
405
#define DICT_FOREIGN_ON_UPDATE_SET_NULL 8       /*!< ON UPDATE SET NULL */
 
406
#define DICT_FOREIGN_ON_DELETE_NO_ACTION 16     /*!< ON DELETE NO ACTION */
 
407
#define DICT_FOREIGN_ON_UPDATE_NO_ACTION 32     /*!< ON UPDATE NO ACTION */
 
408
/* @} */
 
409
 
 
410
 
 
411
/** Data structure for a database table.  Most fields will be
 
412
initialized to 0, NULL or FALSE in dict_mem_table_create(). */
 
413
struct dict_table_struct{
 
414
        dulint          id;     /*!< id of the table */
 
415
        mem_heap_t*     heap;   /*!< memory heap */
 
416
        char*           name;   /*!< table name */
 
417
        const char*     dir_path_of_temp_table;/*!< NULL or the directory path
 
418
                                where a TEMPORARY table that was explicitly
 
419
                                created by a user should be placed if
 
420
                                innodb_file_per_table is defined in my.cnf;
 
421
                                in Unix this is usually /tmp/..., in Windows
 
422
                                temp\... */
 
423
        unsigned        space:32;
 
424
                                /*!< space where the clustered index of the
 
425
                                table is placed */
 
426
        unsigned        flags:DICT_TF2_BITS;/*!< DICT_TF_COMPACT, ... */
 
427
        unsigned        ibd_file_missing:1;
 
428
                                /*!< TRUE if this is in a single-table
 
429
                                tablespace and the .ibd file is missing; then
 
430
                                we must return in ha_innodb.cc an error if the
 
431
                                user tries to query such an orphaned table */
 
432
        unsigned        tablespace_discarded:1;
 
433
                                /*!< this flag is set TRUE when the user
 
434
                                calls DISCARD TABLESPACE on this
 
435
                                table, and reset to FALSE in IMPORT
 
436
                                TABLESPACE */
 
437
        unsigned        cached:1;/*!< TRUE if the table object has been added
 
438
                                to the dictionary cache */
 
439
        unsigned        n_def:10;/*!< number of columns defined so far */
 
440
        unsigned        n_cols:10;/*!< number of columns */
 
441
        dict_col_t*     cols;   /*!< array of column descriptions */
 
442
        const char*     col_names;
 
443
                                /*!< Column names packed in a character string
 
444
                                "name1\0name2\0...nameN\0".  Until
 
445
                                the string contains n_cols, it will be
 
446
                                allocated from a temporary heap.  The final
 
447
                                string will be allocated from table->heap. */
 
448
#ifndef UNIV_HOTBACKUP
 
449
        hash_node_t     name_hash; /*!< hash chain node */
 
450
        hash_node_t     id_hash; /*!< hash chain node */
 
451
        UT_LIST_BASE_NODE_T(dict_index_t)
 
452
                        indexes; /*!< list of indexes of the table */
 
453
        UT_LIST_BASE_NODE_T(dict_foreign_t)
 
454
                        foreign_list;/*!< list of foreign key constraints
 
455
                                in the table; these refer to columns
 
456
                                in other tables */
 
457
        UT_LIST_BASE_NODE_T(dict_foreign_t)
 
458
                        referenced_list;/*!< list of foreign key constraints
 
459
                                which refer to this table */
 
460
        UT_LIST_NODE_T(dict_table_t)
 
461
                        table_LRU; /*!< node of the LRU list of tables */
 
462
        ulint           n_mysql_handles_opened;
 
463
                                /*!< count of how many handles MySQL has opened
 
464
                                to this table; dropping of the table is
 
465
                                NOT allowed until this count gets to zero;
 
466
                                MySQL does NOT itself check the number of
 
467
                                open handles at drop */
 
468
        unsigned        fk_max_recusive_level:8;
 
469
                                /*!< maximum recursive level we support when
 
470
                                loading tables chained together with FK
 
471
                                constraints. If exceeds this level, we will
 
472
                                stop loading child table into memory along with
 
473
                                its parent table */
 
474
        ulint           n_foreign_key_checks_running;
 
475
                                /*!< count of how many foreign key check
 
476
                                operations are currently being performed
 
477
                                on the table: we cannot drop the table while
 
478
                                there are foreign key checks running on
 
479
                                it! */
 
480
        trx_id_t        query_cache_inv_trx_id;
 
481
                                /*!< transactions whose trx id is
 
482
                                smaller than this number are not
 
483
                                allowed to store to the MySQL query
 
484
                                cache or retrieve from it; when a trx
 
485
                                with undo logs commits, it sets this
 
486
                                to the value of the trx id counter for
 
487
                                the tables it had an IX lock on */
 
488
        UT_LIST_BASE_NODE_T(lock_t)
 
489
                        locks; /*!< list of locks on the table */
 
490
#ifdef UNIV_DEBUG
 
491
        /*----------------------*/
 
492
        ibool           does_not_fit_in_memory;
 
493
                                /*!< this field is used to specify in
 
494
                                simulations tables which are so big
 
495
                                that disk should be accessed: disk
 
496
                                access is simulated by putting the
 
497
                                thread to sleep for a while; NOTE that
 
498
                                this flag is not stored to the data
 
499
                                dictionary on disk, and the database
 
500
                                will forget about value TRUE if it has
 
501
                                to reload the table definition from
 
502
                                disk */
 
503
#endif /* UNIV_DEBUG */
 
504
        /*----------------------*/
 
505
        unsigned        big_rows:1;
 
506
                                /*!< flag: TRUE if the maximum length of
 
507
                                a single row exceeds BIG_ROW_SIZE;
 
508
                                initialized in dict_table_add_to_cache() */
 
509
                                /** Statistics for query optimization */
 
510
                                /* @{ */
 
511
        unsigned        stat_initialized:1; /*!< TRUE if statistics have
 
512
                                been calculated the first time
 
513
                                after database startup or table creation */
 
514
        ib_int64_t      stat_n_rows;
 
515
                                /*!< approximate number of rows in the table;
 
516
                                we periodically calculate new estimates */
 
517
        ulint           stat_clustered_index_size;
 
518
                                /*!< approximate clustered index size in
 
519
                                database pages */
 
520
        ulint           stat_sum_of_other_index_sizes;
 
521
                                /*!< other indexes in database pages */
 
522
        ulint           stat_modified_counter;
 
523
                                /*!< when a row is inserted, updated,
 
524
                                or deleted,
 
525
                                we add 1 to this number; we calculate new
 
526
                                estimates for the stat_... values for the
 
527
                                table and the indexes at an interval of 2 GB
 
528
                                or when about 1 / 16 of table has been
 
529
                                modified; also when the estimate operation is
 
530
                                called for MySQL SHOW TABLE STATUS; the
 
531
                                counter is reset to zero at statistics
 
532
                                calculation; this counter is not protected by
 
533
                                any latch, because this is only used for
 
534
                                heuristics */
 
535
                                /* @} */
 
536
        /*----------------------*/
 
537
                                /**!< The following fields are used by the
 
538
                                AUTOINC code.  The actual collection of
 
539
                                tables locked during AUTOINC read/write is
 
540
                                kept in trx_t. In order to quickly determine
 
541
                                whether a transaction has locked the AUTOINC
 
542
                                lock we keep a pointer to the transaction
 
543
                                here in the autoinc_trx variable. This is to
 
544
                                avoid acquiring the kernel mutex and scanning
 
545
                                the vector in trx_t.
 
546
 
 
547
                                When an AUTOINC lock has to wait, the
 
548
                                corresponding lock instance is created on
 
549
                                the trx lock heap rather than use the
 
550
                                pre-allocated instance in autoinc_lock below.*/
 
551
                                /* @{ */
 
552
        lock_t*         autoinc_lock;
 
553
                                /*!< a buffer for an AUTOINC lock
 
554
                                for this table: we allocate the memory here
 
555
                                so that individual transactions can get it
 
556
                                and release it without a need to allocate
 
557
                                space from the lock heap of the trx:
 
558
                                otherwise the lock heap would grow rapidly
 
559
                                if we do a large insert from a select */
 
560
        mutex_t         autoinc_mutex;
 
561
                                /*!< mutex protecting the autoincrement
 
562
                                counter */
 
563
        ib_uint64_t     autoinc;/*!< autoinc counter value to give to the
 
564
                                next inserted row */
 
565
        ulong           n_waiting_or_granted_auto_inc_locks;
 
566
                                /*!< This counter is used to track the number
 
567
                                of granted and pending autoinc locks on this
 
568
                                table. This value is set after acquiring the
 
569
                                kernel mutex but we peek the contents to
 
570
                                determine whether other transactions have
 
571
                                acquired the AUTOINC lock or not. Of course
 
572
                                only one transaction can be granted the
 
573
                                lock but there can be multiple waiters. */
 
574
        const trx_t*            autoinc_trx;
 
575
                                /*!< The transaction that currently holds the
 
576
                                the AUTOINC lock on this table. */
 
577
                                /* @} */
 
578
        /*----------------------*/
 
579
        ibool           is_corrupt;
 
580
#endif /* !UNIV_HOTBACKUP */
 
581
 
 
582
#ifdef UNIV_DEBUG
 
583
        ulint           magic_n;/*!< magic number */
 
584
/** Value of dict_table_struct::magic_n */
 
585
# define DICT_TABLE_MAGIC_N     76333786
 
586
#endif /* UNIV_DEBUG */
 
587
};
 
588
 
 
589
#ifndef UNIV_NONINL
 
590
#include "dict0mem.ic"
 
591
#endif
 
592
 
 
593
#endif