mariadb/include/dict0mem.h
marko c1d4665514 branches/innodb+: Merge revisions 2867:2986 from branches/zip:
------------------------------------------------------------------------
  r2867 | marko | 2008-10-24 10:24:17 +0300 (Fri, 24 Oct 2008) | 2 lines

  branches/zip: ChangeLog: Document r2763, r2794, r2683, r2799, r2809, r2866.
  ------------------------------------------------------------------------
  r2869 | vasil | 2008-10-24 11:14:16 +0300 (Fri, 24 Oct 2008) | 4 lines

  branches/zip:

  White space cleanup in ChangeLog
  ------------------------------------------------------------------------
  r2870 | vasil | 2008-10-24 13:36:14 +0300 (Fri, 24 Oct 2008) | 8 lines

  branches/zip:

  Remove a statement that causes the innodb-index test to fail.

  The change in behavior was introduced in MySQL BZR-r2738.

  Suggested by:	Marko
  ------------------------------------------------------------------------
  r2871 | vasil | 2008-10-24 13:48:38 +0300 (Fri, 24 Oct 2008) | 5 lines

  branches/zip:

  Adjust mysql-test/patches/innodb-index.diff after the change to
  mysql-test/innodb-index.(test|result) in r2870.
  ------------------------------------------------------------------------
  r2878 | calvin | 2008-10-27 11:05:42 +0200 (Mon, 27 Oct 2008) | 8 lines

  branches/zip: port the fix of Bug#19424 - InnoDB: Possibly a memory
  overrun of the buffer being freed with 64-bit Microsoft Visual C++.

  The changed file:

  CMakeLists.txt: Removing Win64 compiler optimizations for all 
  innodb/mem/* files.
  ------------------------------------------------------------------------
  r2884 | vasil | 2008-10-27 11:48:46 +0200 (Mon, 27 Oct 2008) | 7 lines

  branches/zip:

  ChangeLog:

  Add entry for the fix of Bug#19424 InnoDB: Possibly a memory overrun of
  the buffer being freed (64-bit Visual C)
  ------------------------------------------------------------------------
  r2886 | calvin | 2008-10-27 22:39:11 +0200 (Mon, 27 Oct 2008) | 8 lines

  branches/zip: This patch is to solve the issue that file handles can
  not cross DLL/EXE boundaries on Windows. In builtin InnoDB, it makes
  call to MySQL server for creating tmp files. innobase_mysql_tmpfile
  is now rewritten for the plugin. 

  rb://5

  Approved by:	Marko
  ------------------------------------------------------------------------
  r2887 | calvin | 2008-10-27 22:48:29 +0200 (Mon, 27 Oct 2008) | 44 lines

  branches/zip: implement the delayloading of externals for the plugin
  on Windows, which includes:

   * Load mysqld.map and insert all symbol/address pairs into hash for
     quick access
   * Resolves all external data variables. The delayloading mechanism
     in MSVC does not support automatic imports of data variables.
     A workaround is to explicitly handle the data import using the delay
     loader during the initialization of the plugin.
   * Resolves all external functions during run-time, by implementing
     the delayed loading helper function delayLoadHelper2, which is
     called by run-time as well as HrLoadAllImportsForDll. 

  The delay loader reuses the hash implementation in InnoDB. The normal
  hash_create (in hash0hash.c) creates hash tables in buffer pool. But
  the delay loader is invoked before the engine is initialized, and 
  buffer pools are not ready yet. Instead, the delay loader has its own
  implementation of hash_create() and hash_table_free(), called
  wdl_hash_create() and wdl_hash_table_free().

  This patch should be used with other two patches in order to build
  a dynamically linked plugin on Windows:
   * patch for tmpfile functions (r2886)
   * patch for "build" files (to be committed)

  The list of file changed:

  handler/handler0vars.h: new file, defines a list of external data
  variables (no external functions).

  handler/win_delay_loader.cc: new file, the implementation of the delay
  loader for Windows plugin.

  handler/ha_innodb.cc: add a header file, and changes for copying the
  system variables.

  handler/handler0alter.cc: add a header file

  handler/i_s.cc: add a header file

  rb://27

  Reviewed by:	Sunny, Marko
  Approved by:	Sunny
  ------------------------------------------------------------------------
  r2888 | calvin | 2008-10-28 01:51:49 +0200 (Tue, 28 Oct 2008) | 25 lines

  branches/zip: for building dynamic plugin on Windows, ha_innodb.dll,
  when INNODB_DYNAMIC_PLUGIN is specified.

  The changes are:

  CMakeLists.txt: add project ha_innodb for dynamic plugin on Windows.
  ha_innodb depends on project mysqld.

  ha_innodb.def: a new file with standard exports for a dynamic plugin.

  Two new files will be added:
   * sql/mysqld.def:	.def file for 32-bit compiler
   * sql/mysqld_x64.def:	.def file for x64 compiler

  It is also required to apply a patch to the MySQL source tree. The 
  patch is described in win-plugin/README:

  win-plugin/win-plugin.diff - a patch to be applied to MySQL source
  tree. When applied, the following files will be modified:
   * CMakeLists.txt:	add INNODB_DYNAMIC_PLUGIN and _USE_32BIT_TIME_T
   * sql/CMakeLists.txt:	add mysqld.def or mysqld_x64.def for mysqld
   * win/configure.js:	add INNODB_DYNAMIC_PLUGIN
   * win/build-vs71.bat:	provide an option to specify CMAKE_BUILD_TYPE
   * win/build-vs8.bat:	provide an option to specify CMAKE_BUILD_TYPE
   * win/build-vs8_x64.bat: provide an option to specify CMAKE_BUILD_TYPE
  ------------------------------------------------------------------------
  r2894 | marko | 2008-10-28 08:36:39 +0200 (Tue, 28 Oct 2008) | 4 lines

  branches/zip: dict_str_starts_with_keyword(): Removed this unused function.

  Spotted by Sunny.
  ------------------------------------------------------------------------
  r2895 | vasil | 2008-10-28 08:40:45 +0200 (Tue, 28 Oct 2008) | 6 lines

  branches/zip:

  ChangeLog:

  add entry for the Windows plugin.
  ------------------------------------------------------------------------
  r2917 | marko | 2008-10-28 23:53:23 +0200 (Tue, 28 Oct 2008) | 3 lines

  branches/zip: innodb_plugin_init(): Do not copy session variables,
  even when the variable is a global variable in the built-in InnoDB.
  ------------------------------------------------------------------------
  r2918 | calvin | 2008-10-29 00:08:11 +0200 (Wed, 29 Oct 2008) | 2 lines

  branches/zip: fix a problem introduced in r2917 - dyn is not
  initialized. Move the check into for().
  ------------------------------------------------------------------------
  r2922 | calvin | 2008-10-29 08:29:01 +0200 (Wed, 29 Oct 2008) | 16 lines

  branches/zip: fix issue #102 - Windows plugin: resolve dbug functions
  during run-time.

  Implement wrapper functions in the plugin. The plugin will get the
  function entries from mysqld.exe during the init, and invoke the
  corresponding functions (in mysqld.exe). The list of functions are:

  	_db_pargs_
  	_db_doprnt_
  	_db_enter_
  	_db_return_
  	_db_dump_

  rb://38

  Approved by:	Marko
  ------------------------------------------------------------------------
  r2923 | marko | 2008-10-29 09:52:30 +0200 (Wed, 29 Oct 2008) | 1 line

  branches/zip: ChangeLog: Mention Bug #27276.
  ------------------------------------------------------------------------
  r2925 | calvin | 2008-10-29 10:09:41 +0200 (Wed, 29 Oct 2008) | 16 lines

  branches/zip: change function names in sql/mysqld.def in order
  to work with 5.1.29-rc.

  In 5.1.29, the following function names are changed:
    _hash_init
    hash_free
    hash_search
    hash_delete

  changed to
    _my_hash_init
    my_hash_free
    my_hash_search
    my_hash_delete

  Approved by:	Marko (on IM)
  ------------------------------------------------------------------------
  r2927 | marko | 2008-10-29 11:43:23 +0200 (Wed, 29 Oct 2008) | 4 lines

  branches/zip: ha_innodb.cc: Make some functions static, so that they will
  not be compiled as weak global symbols.  These functions must not be
  redirected to the built-in InnoDB.
  ------------------------------------------------------------------------
  r2928 | michael | 2008-10-29 19:20:10 +0200 (Wed, 29 Oct 2008) | 4 lines

  Remove unnecessary assert

  Approved by: Heikki, over IM
  ------------------------------------------------------------------------
  r2930 | marko | 2008-10-29 21:39:24 +0200 (Wed, 29 Oct 2008) | 33 lines

  branches/zip: Merge revisions 2854:2929 from branches/5.1,
  except r2924, which was merged from branches/zip r2866 to branches/5.1
  and except r2879 which was merged separately by Calvin:

    ------------------------------------------------------------------------
    r2902 | vasil | 2008-10-28 12:10:25 +0200 (Tue, 28 Oct 2008) | 10 lines

    branches/5.1:

    Fix Bug#38189 innodb_stats_on_metadata missing

    Make the variable innodb_stats_on_metadata visible to the users and
    also settable at runtime. Previously it was only "visible" as a command
    line startup option to mysqld.

    Approved by:    Marko (https://svn.innodb.com/rb/r/36)
    ------------------------------------------------------------------------
    r2929 | marko | 2008-10-29 21:26:14 +0200 (Wed, 29 Oct 2008) | 13 lines

    branches/5.1: dtype_get_sql_null_size(): return the correct storage
    size of a SQL NULL column. (Bug #40369)

    When MySQL Bug #20877 was fixed in r834, this function was
    accidentally modified to return 0 or 1. Apparently, the only impact of
    this bug is that fixed-length columns cannot be updated in-place from
    or to SQL NULL, even in ROW_FORMAT=REDUNDANT.  After this fix,
    fixed-length columns in ROW_FORMAT=REDUNDANT will have a constant
    storage size as they should, no matter if NULL or non-NULL.  The bug
    caused fixed-length NULL columns to occupy 1 byte.

    rb://37 approved by Heikki over IM.
    ------------------------------------------------------------------------

  ------------------------------------------------------------------------
  r2931 | vasil | 2008-10-29 22:10:40 +0200 (Wed, 29 Oct 2008) | 4 lines

  branches/zip:

  Add 2 ChangeLog entries for the 2 bugfixes that were merged from branches/5.1.
  ------------------------------------------------------------------------
  r2935 | vasil | 2008-10-30 12:17:23 +0200 (Thu, 30 Oct 2008) | 17 lines

  branches/zip:

  Fix "Bug#40360 Binlog related errors with binlog off" in InnoDB code in order
  to have a Bug#40360-free InnoDB Plugin 1.0.2.

  The fix does check whether binary logging is enabled in MySQL by accessing the
  opt_bin_log global variable that is defined in sql/mysqld.cc.

  In case MySQL does develop another solution to this via Bug#40360 then we can
  revert this patch (except the mysql-tests).

  The windows-plugin part of this fix will be committed as a separate commit to
  ease eventual merge into branches/5.1 [note from the future: the separate
  commit went into r2936].

  Approved by:	Marko (https://svn.innodb.com/rb/r/39)
  ------------------------------------------------------------------------
  r2936 | vasil | 2008-10-30 12:24:09 +0200 (Thu, 30 Oct 2008) | 7 lines

  branches/zip:

  Followup to r2935: add the Windows Delay Loader stuff for the MySQL
  variable that we are accessing. If someday we have another solution for
  Bug#40360 Binlog related errors with binlog off
  then this should also be reverted.
  ------------------------------------------------------------------------
  r2937 | vasil | 2008-10-30 12:28:47 +0200 (Thu, 30 Oct 2008) | 4 lines

  branches/zip:

  Add ChangeLog entry for Bug#40360 Binlog related errors with binlog off
  ------------------------------------------------------------------------
  r2938 | vasil | 2008-10-30 12:33:28 +0200 (Thu, 30 Oct 2008) | 5 lines

  branches/zip:

  Non-functional change: convert handler/handler0vars.h and
  handler/win_delay_loader.cc from \r\n (dos) to \n (unix) line terminators.
  ------------------------------------------------------------------------
  r2939 | marko | 2008-10-30 12:38:18 +0200 (Thu, 30 Oct 2008) | 2 lines

  branches/zip: Set svn:eol-style native on some recently added text files.
  ------------------------------------------------------------------------
  r2940 | marko | 2008-10-30 12:46:21 +0200 (Thu, 30 Oct 2008) | 1 line

  branches/zip: ChangeLog, ha_innodb.def: Set svn:eol-style native
  ------------------------------------------------------------------------
  r2941 | vasil | 2008-10-30 19:34:27 +0200 (Thu, 30 Oct 2008) | 4 lines

  branches/zip:

  Increment the InnoDB Plugin version from 1.0.1 to 1.0.2.
  ------------------------------------------------------------------------
  r2943 | sunny | 2008-10-31 09:40:29 +0200 (Fri, 31 Oct 2008) | 15 lines

  branches/zip: 
    1. We add a vector of locks to trx_t. This array contains the autoinc
    locks granted to a transaction. There is one per table.

    2. We enforce releasing of these locks in the reverse order from the
    one in which they are acquired. The assumption is that since the
    AUTOINC locks are statement level locks. Nested statements introduced
    by triggers are stacked it should hold.

  There was some cleanup done to the vector code too by adding const and
  some new functions. Rename dict_table_t::auto_inc_lock to autoinc_lock.

  Fix Bug#26316 Triggers create duplicate entries on auto-increment columns
  rb://22
  ------------------------------------------------------------------------
  r2944 | vasil | 2008-10-31 09:44:16 +0200 (Fri, 31 Oct 2008) | 12 lines

  branches/zip:

  Revert our temporary fix for "Bug#40360 Binlog related errors with binlog off"
  (r2935, r2936) and deploy MySQL's one, but put the function
  mysql_bin_log_is_engaged() inside mysql_addons.cc instead of in mysql's log.cc
  and use a different name for it so there is no collision when MySQL adds this
  function in log.cc.

  [note from the future: the windows part of this patch went into r2947]

  Approved by:	Marko (https://svn.innodb.com/rb/r/41/)
  ------------------------------------------------------------------------
  r2945 | sunny | 2008-10-31 09:44:45 +0200 (Fri, 31 Oct 2008) | 2 lines

  branches/zip: Update ChangeLog with r2943 info.
  ------------------------------------------------------------------------
  r2946 | marko | 2008-10-31 10:18:47 +0200 (Fri, 31 Oct 2008) | 2 lines

  branches/zip: Revert the unintended change to univ.i that was made in r2943.
  ------------------------------------------------------------------------
  r2947 | calvin | 2008-10-31 10:38:26 +0200 (Fri, 31 Oct 2008) | 6 lines

  branches/zip: Windows plugin part of r2944

  r2944 has reference to mysql_bin_log.is_open(), which is new in InnoDB.
  Add two new entries and remove one duplicate in mysqld.def & 
  mysqld_x64.def.
  ------------------------------------------------------------------------
  r2948 | vasil | 2008-10-31 11:39:07 +0200 (Fri, 31 Oct 2008) | 9 lines

  branches/zip:

  Fix Mantis issue#106 plugin init error:InnoDB: stats_on_metadata in static
  InnoDB (flags=0x2401) differs from stats_on_metadata in dynamic InnoDB (fl

  Ignore the NOSYSVAR flag in addition to ignoring the READONLY flag.

  Approved by:	Marko (https://svn.innodb.com/rb/r/42/)
  ------------------------------------------------------------------------
  r2949 | vasil | 2008-10-31 11:47:56 +0200 (Fri, 31 Oct 2008) | 4 lines

  branches/zip:

  White-space cleanup in ChangeLog.
  ------------------------------------------------------------------------
  r2951 | marko | 2008-10-31 14:21:43 +0200 (Fri, 31 Oct 2008) | 4 lines

  branches/zip: scripts/install_innodb_plugins_win.sql: New script,
  for installing the InnoDB plugins in Windows.  Copied from
  scripts/install_innodb_plugins.sql.
  ------------------------------------------------------------------------
  r2954 | calvin | 2008-11-04 09:15:26 +0200 (Tue, 04 Nov 2008) | 8 lines

  branches/zip: ignore the failure when builtin_innobase_plugin is not
  available.

  External variable builtin_innobase_plugin is not available when mysqld
  does not have a builtin InnoDB. The init of the Windows plugin should
  not fail in this case. 

  Approved by:	Marko (on IM)
  ------------------------------------------------------------------------
  r2955 | calvin | 2008-11-04 12:43:14 +0200 (Tue, 04 Nov 2008) | 11 lines

  branches/zip: windows plugin - fix references to array variables.

  This problem surfaced when running new test innodb_bug40360.test. Both
  tx_isolation_names and binlog_format_names are name arrays, and
  should be defined as wdl_tx_isolation_names and wdl_binlog_format_names,
  not *wdl_tx_isolation_names and *wdl_binlog_format_names.

  Another array variable is all_charsets, which is already correctly
  defined.

  Approved by:	Marko (on IM)
  ------------------------------------------------------------------------
  r2986 | marko | 2008-11-11 09:28:37 +0200 (Tue, 11 Nov 2008) | 11 lines

  branches/zip: ha_innobase::create(): Remove the dependences on
  DICT_TF_ZSSIZE_MAX, so that the code can be compiled with a different
  uncompressed page size by redefining UNIV_PAGE_SIZE_SHIFT in univ.i.
  Currently, the allowed values are 12, 13, or 14 (4k, 8k, 16k).

  Make the default compressed page size half the uncompressed page size.
  The previous default was 8 kilobytes, which is the same when compiling
  with the default 16k uncompressed page size.

  rb://50 approved by Pekka Lampio and Sunny Bains.
  ------------------------------------------------------------------------
2008-11-11 10:21:16 +00:00

486 lines
18 KiB
C

/******************************************************
Data dictionary memory object creation
(c) 1996 Innobase Oy
Created 1/8/1996 Heikki Tuuri
*******************************************************/
#ifndef dict0mem_h
#define dict0mem_h
#include "univ.i"
#include "dict0types.h"
#include "data0type.h"
#include "data0data.h"
#include "mem0mem.h"
#include "rem0types.h"
#include "btr0types.h"
#include "ut0mem.h"
#include "ut0lst.h"
#include "ut0rnd.h"
#include "ut0byte.h"
#include "sync0rw.h"
#include "lock0types.h"
#include "hash0hash.h"
#include "que0types.h"
#include "trx0types.h"
/* Type flags of an index: OR'ing of the flags is allowed to define a
combination of types */
#define DICT_CLUSTERED 1 /* clustered index */
#define DICT_UNIQUE 2 /* unique index */
#define DICT_UNIVERSAL 4 /* index which can contain records from any
other index */
#define DICT_IBUF 8 /* insert buffer tree */
/* Types for a table object */
#define DICT_TABLE_ORDINARY 1
#if 0 /* not implemented */
#define DICT_TABLE_CLUSTER_MEMBER 2
#define DICT_TABLE_CLUSTER 3 /* this means that the table is
really a cluster definition */
#endif
/* Table flags. All unused bits must be 0. */
#define DICT_TF_COMPACT 1 /* Compact page format.
This must be set for
new file formats
(later than
DICT_TF_FORMAT_51). */
/* compressed page size (0=uncompressed, up to 15 compressed sizes) */
#define DICT_TF_ZSSIZE_SHIFT 1
#define DICT_TF_ZSSIZE_MASK (15 << DICT_TF_ZSSIZE_SHIFT)
#define DICT_TF_ZSSIZE_MAX (UNIV_PAGE_SIZE_SHIFT - PAGE_ZIP_MIN_SIZE_SHIFT + 1)
#define DICT_TF_FORMAT_SHIFT 5 /* file format */
#define DICT_TF_FORMAT_MASK (127 << DICT_TF_FORMAT_SHIFT)
#define DICT_TF_FORMAT_51 0 /* InnoDB/MySQL up to 5.1 */
#define DICT_TF_FORMAT_ZIP 1 /* InnoDB plugin for 5.1:
compressed tables,
new BLOB treatment */
#define DICT_TF_FORMAT_MAX DICT_TF_FORMAT_ZIP
#define DICT_TF_BITS 6 /* number of flag bits */
#if (1 << (DICT_TF_BITS - DICT_TF_FORMAT_SHIFT)) <= DICT_TF_FORMAT_MAX
# error "DICT_TF_BITS is insufficient for DICT_TF_FORMAT_MAX"
#endif
/**************************************************************************
Creates a table memory object. */
UNIV_INTERN
dict_table_t*
dict_mem_table_create(
/*==================*/
/* out, own: table object */
const char* name, /* in: table name */
ulint space, /* in: space where the clustered index
of the table is placed; this parameter
is ignored if the table is made
a member of a cluster */
ulint n_cols, /* in: number of columns */
ulint flags); /* in: table flags */
/********************************************************************
Free a table memory object. */
UNIV_INTERN
void
dict_mem_table_free(
/*================*/
dict_table_t* table); /* in: table */
/**************************************************************************
Adds a column definition to a table. */
UNIV_INTERN
void
dict_mem_table_add_col(
/*===================*/
dict_table_t* table, /* in: table */
mem_heap_t* heap, /* in: temporary memory heap, or NULL */
const char* name, /* in: column name, or NULL */
ulint mtype, /* in: main datatype */
ulint prtype, /* in: precise type */
ulint len); /* in: precision */
/**************************************************************************
Creates an index memory object. */
UNIV_INTERN
dict_index_t*
dict_mem_index_create(
/*==================*/
/* out, own: index object */
const char* table_name, /* in: table name */
const char* index_name, /* in: index name */
ulint space, /* in: space where the index tree is
placed, ignored if the index is of
the clustered type */
ulint type, /* in: DICT_UNIQUE,
DICT_CLUSTERED, ... ORed */
ulint n_fields); /* in: number of fields */
/**************************************************************************
Adds a field definition to an index. NOTE: does not take a copy
of the column name if the field is a column. The memory occupied
by the column name may be released only after publishing the index. */
UNIV_INTERN
void
dict_mem_index_add_field(
/*=====================*/
dict_index_t* index, /* in: index */
const char* name, /* in: column name */
ulint prefix_len); /* in: 0 or the column prefix length
in a MySQL index like
INDEX (textcol(25)) */
/**************************************************************************
Frees an index memory object. */
UNIV_INTERN
void
dict_mem_index_free(
/*================*/
dict_index_t* index); /* in: index */
/**************************************************************************
Creates and initializes a foreign constraint memory object. */
UNIV_INTERN
dict_foreign_t*
dict_mem_foreign_create(void);
/*=========================*/
/* out, own: foreign constraint struct */
/* Data structure for a column in a table */
struct dict_col_struct{
/*----------------------*/
/* The following are copied from dtype_t,
so that all bit-fields can be packed tightly. */
unsigned mtype:8; /* main data type */
unsigned prtype:24; /* precise type; MySQL data
type, charset code, flags to
indicate nullability,
signedness, whether this is a
binary string, whether this is
a true VARCHAR where MySQL
uses 2 bytes to store the length */
/* the remaining fields do not affect alphabetical ordering: */
unsigned len:16; /* length; for MySQL data this
is field->pack_length(),
except that for a >= 5.0.3
type true VARCHAR this is the
maximum byte length of the
string data (in addition to
the string, MySQL uses 1 or 2
bytes to store the string length) */
unsigned mbminlen:2; /* minimum length of a
character, in bytes */
unsigned mbmaxlen:3; /* maximum length of a
character, in bytes */
/*----------------------*/
/* End of definitions copied from dtype_t */
unsigned ind:10; /* table column position
(starting from 0) */
unsigned ord_part:1; /* nonzero if this column
appears in the ordering fields
of an index */
};
/* DICT_MAX_INDEX_COL_LEN is measured in bytes and is the maximum
indexed column length (or indexed prefix length). It is set to 3*256,
so that one can create a column prefix index on 256 characters of a
TEXT or VARCHAR column also in the UTF-8 charset. In that charset,
a character may take at most 3 bytes.
This constant MUST NOT BE CHANGED, or the compatibility of InnoDB data
files would be at risk! */
#define DICT_MAX_INDEX_COL_LEN REC_MAX_INDEX_COL_LEN
/* Data structure for a field in an index */
struct dict_field_struct{
dict_col_t* col; /* pointer to the table column */
const char* name; /* name of the column */
unsigned prefix_len:10; /* 0 or the length of the column
prefix in bytes in a MySQL index of
type, e.g., INDEX (textcol(25));
must be smaller than
DICT_MAX_INDEX_COL_LEN; NOTE that
in the UTF-8 charset, MySQL sets this
to 3 * the prefix len in UTF-8 chars */
unsigned fixed_len:10; /* 0 or the fixed length of the
column if smaller than
DICT_MAX_INDEX_COL_LEN */
};
/* Data structure for an index. Most fields will be
initialized to 0, NULL or FALSE in dict_mem_index_create(). */
struct dict_index_struct{
dulint id; /* id of the index */
mem_heap_t* heap; /* memory heap */
const char* name; /* index name */
const char* table_name; /* table name */
dict_table_t* table; /* back pointer to table */
unsigned space:32;
/* space where the index tree is placed */
unsigned page:32;/* index tree root page number */
unsigned type:4; /* index type (DICT_CLUSTERED, DICT_UNIQUE,
DICT_UNIVERSAL, DICT_IBUF) */
unsigned trx_id_offset:10;/* position of the trx id column
in a clustered index record, if the fields
before it are known to be of a fixed size,
0 otherwise */
unsigned n_user_defined_cols:10;
/* number of columns the user defined to
be in the index: in the internal
representation we add more columns */
unsigned n_uniq:10;/* number of fields from the beginning
which are enough to determine an index
entry uniquely */
unsigned n_def:10;/* number of fields defined so far */
unsigned n_fields:10;/* number of fields in the index */
unsigned n_nullable:10;/* number of nullable fields */
unsigned cached:1;/* TRUE if the index object is in the
dictionary cache */
unsigned to_be_dropped:1;
/* TRUE if this index is marked to be
dropped in ha_innobase::prepare_drop_index(),
otherwise FALSE */
dict_field_t* fields; /* array of field descriptions */
UT_LIST_NODE_T(dict_index_t)
indexes;/* list of indexes of the table */
btr_search_t* search_info; /* info used in optimistic searches */
/*----------------------*/
ib_int64_t* stat_n_diff_key_vals;
/* approximate number of different key values
for this index, for each n-column prefix
where n <= dict_get_n_unique(index); we
periodically calculate new estimates */
ulint stat_index_size;
/* approximate index size in database pages */
ulint stat_n_leaf_pages;
/* approximate number of leaf pages in the
index tree */
rw_lock_t lock; /* read-write lock protecting the upper levels
of the index tree */
#ifdef ROW_MERGE_IS_INDEX_USABLE
dulint trx_id; /* id of the transaction that created this
index, or ut_dulint_zero if the index existed
when InnoDB was started up */
#endif /* ROW_MERGE_IS_INDEX_USABLE */
#ifdef UNIV_DEBUG
ulint magic_n;/* magic number */
# define DICT_INDEX_MAGIC_N 76789786
#endif
};
/* Data structure for a foreign key constraint; an example:
FOREIGN KEY (A, B) REFERENCES TABLE2 (C, D). Most fields will be
initialized to 0, NULL or FALSE in dict_mem_foreign_create(). */
struct dict_foreign_struct{
mem_heap_t* heap; /* this object is allocated from
this memory heap */
char* id; /* id of the constraint as a
null-terminated string */
unsigned n_fields:10; /* number of indexes' first fields
for which the the foreign key
constraint is defined: we allow the
indexes to contain more fields than
mentioned in the constraint, as long
as the first fields are as mentioned */
unsigned type:6; /* 0 or DICT_FOREIGN_ON_DELETE_CASCADE
or DICT_FOREIGN_ON_DELETE_SET_NULL */
char* foreign_table_name;/* foreign table name */
dict_table_t* foreign_table; /* table where the foreign key is */
const char** foreign_col_names;/* names of the columns in the
foreign key */
char* referenced_table_name;/* referenced table name */
dict_table_t* referenced_table;/* table where the referenced key
is */
const char** referenced_col_names;/* names of the referenced
columns in the referenced table */
dict_index_t* foreign_index; /* foreign index; we require that
both tables contain explicitly defined
indexes for the constraint: InnoDB
does not generate new indexes
implicitly */
dict_index_t* referenced_index;/* referenced index */
UT_LIST_NODE_T(dict_foreign_t)
foreign_list; /* list node for foreign keys of the
table */
UT_LIST_NODE_T(dict_foreign_t)
referenced_list;/* list node for referenced keys of the
table */
};
/* The flags for ON_UPDATE and ON_DELETE can be ORed; the default is that
a foreign key constraint is enforced, therefore RESTRICT just means no flag */
#define DICT_FOREIGN_ON_DELETE_CASCADE 1
#define DICT_FOREIGN_ON_DELETE_SET_NULL 2
#define DICT_FOREIGN_ON_UPDATE_CASCADE 4
#define DICT_FOREIGN_ON_UPDATE_SET_NULL 8
#define DICT_FOREIGN_ON_DELETE_NO_ACTION 16
#define DICT_FOREIGN_ON_UPDATE_NO_ACTION 32
/* Data structure for a database table. Most fields will be
initialized to 0, NULL or FALSE in dict_mem_table_create(). */
struct dict_table_struct{
dulint id; /* id of the table */
mem_heap_t* heap; /* memory heap */
const char* name; /* table name */
const char* dir_path_of_temp_table;/* NULL or the directory path
where a TEMPORARY table that was explicitly
created by a user should be placed if
innodb_file_per_table is defined in my.cnf;
in Unix this is usually /tmp/..., in Windows
\temp\... */
unsigned space:32;
/* space where the clustered index of the
table is placed */
unsigned flags:DICT_TF_BITS;/* DICT_TF_COMPACT, ... */
unsigned ibd_file_missing:1;
/* TRUE if this is in a single-table
tablespace and the .ibd file is missing; then
we must return in ha_innodb.cc an error if the
user tries to query such an orphaned table */
unsigned tablespace_discarded:1;
/* this flag is set TRUE when the user
calls DISCARD TABLESPACE on this
table, and reset to FALSE in IMPORT
TABLESPACE */
unsigned cached:1;/* TRUE if the table object has been added
to the dictionary cache */
unsigned n_def:10;/* number of columns defined so far */
unsigned n_cols:10;/* number of columns */
dict_col_t* cols; /* array of column descriptions */
const char* col_names;
/* Column names packed in a character string
"name1\0name2\0...nameN\0". Until
the string contains n_cols, it will be
allocated from a temporary heap. The final
string will be allocated from table->heap. */
hash_node_t name_hash; /* hash chain node */
hash_node_t id_hash; /* hash chain node */
UT_LIST_BASE_NODE_T(dict_index_t)
indexes; /* list of indexes of the table */
UT_LIST_BASE_NODE_T(dict_foreign_t)
foreign_list;/* list of foreign key constraints
in the table; these refer to columns
in other tables */
UT_LIST_BASE_NODE_T(dict_foreign_t)
referenced_list;/* list of foreign key constraints
which refer to this table */
UT_LIST_NODE_T(dict_table_t)
table_LRU; /* node of the LRU list of tables */
ulint n_mysql_handles_opened;
/* count of how many handles MySQL has opened
to this table; dropping of the table is
NOT allowed until this count gets to zero;
MySQL does NOT itself check the number of
open handles at drop */
ulint n_foreign_key_checks_running;
/* count of how many foreign key check
operations are currently being performed
on the table: we cannot drop the table while
there are foreign key checks running on
it! */
dulint query_cache_inv_trx_id;
/* transactions whose trx id < than this
number are not allowed to store to the MySQL
query cache or retrieve from it; when a trx
with undo logs commits, it sets this to the
value of the trx id counter for the tables it
had an IX lock on */
UT_LIST_BASE_NODE_T(lock_t)
locks; /* list of locks on the table */
#ifdef UNIV_DEBUG
/*----------------------*/
ibool does_not_fit_in_memory;
/* this field is used to specify in simulations
tables which are so big that disk should be
accessed: disk access is simulated by
putting the thread to sleep for a while;
NOTE that this flag is not stored to the data
dictionary on disk, and the database will
forget about value TRUE if it has to reload
the table definition from disk */
#endif /* UNIV_DEBUG */
/*----------------------*/
unsigned big_rows:1;
/* flag: TRUE if the maximum length of
a single row exceeds BIG_ROW_SIZE;
initialized in dict_table_add_to_cache() */
unsigned stat_initialized:1; /* TRUE if statistics have
been calculated the first time
after database startup or table creation */
ib_int64_t stat_n_rows;
/* approximate number of rows in the table;
we periodically calculate new estimates */
ulint stat_clustered_index_size;
/* approximate clustered index size in
database pages */
ulint stat_sum_of_other_index_sizes;
/* other indexes in database pages */
ulint stat_modified_counter;
/* when a row is inserted, updated, or deleted,
we add 1 to this number; we calculate new
estimates for the stat_... values for the
table and the indexes at an interval of 2 GB
or when about 1 / 16 of table has been
modified; also when the estimate operation is
called for MySQL SHOW TABLE STATUS; the
counter is reset to zero at statistics
calculation; this counter is not protected by
any latch, because this is only used for
heuristics */
/*----------------------*/
/* The following fields are used by the
AUTOINC code. The actual collection of
tables locked during AUTOINC read/write is
kept in trx_t. In order to quickly determine
whether a transaction has locked the AUTOINC
lock we keep a pointer to the transaction
here in the autoinc_trx variable. This is to
avoid acquiring the kernel mutex and scanning
the vector in trx_t.
When an AUTOINC lock has to wait, the
corresponding lock instance is created on
the trx lock heap rather than use the
pre-allocated instance in autoinc_lock below.*/
lock_t* autoinc_lock;
/* a buffer for an AUTOINC lock
for this table: we allocate the memory here
so that individual transactions can get it
and release it without a need to allocate
space from the lock heap of the trx:
otherwise the lock heap would grow rapidly
if we do a large insert from a select */
mutex_t autoinc_mutex;
/* mutex protecting the autoincrement
counter */
ib_uint64_t autoinc;/* autoinc counter value to give to the
next inserted row */
ulong n_waiting_or_granted_auto_inc_locks;
/* This counter is used to track the number
of granted and pending autoinc locks on this
table. This value is set after acquiring the
kernel mutex but we peek the contents to
determine whether other transactions have
acquired the AUTOINC lock or not. Of course
only one transaction can be granted the
lock but there can be multiple waiters. */
const trx_t* autoinc_trx;
/* The transaction that currently holds the
the AUTOINC lock on this table. */
/*----------------------*/
#ifdef UNIV_DEBUG
ulint magic_n;/* magic number */
# define DICT_TABLE_MAGIC_N 76333786
#endif /* UNIV_DEBUG */
};
#ifndef UNIV_NONINL
#include "dict0mem.ic"
#endif
#endif