📄 dict0mem.h
字号:
/******************************************************Data dictionary memory object creation(c) 1996 Innobase OyCreated 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"/* Type flags of an index: OR'ing of the flags is allowed to define acombination 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 */ /* Flags for ordering an index field: OR'ing of the flags allowed */#define DICT_DESCEND 1 /* in descending order (default ascending) *//* Types for a table object */#define DICT_TABLE_ORDINARY 1#define DICT_TABLE_CLUSTER_MEMBER 2#define DICT_TABLE_CLUSTER 3 /* this means that the table is really a cluster definition *//**************************************************************************Creates a table memory object. */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 */ ibool comp); /* in: TRUE=compact page format *//**************************************************************************Creates a cluster memory object. */dict_cluster_t*dict_mem_cluster_create(/*====================*/ /* out, own: cluster object (where the type dict_cluster_t == dict_table_t) */ const char* name, /* in: cluster name */ ulint space, /* in: space where the clustered indexes of the member tables are placed */ ulint n_cols, /* in: number of columns */ ulint mix_len); /* in: length of the common key prefix in the cluster *//**************************************************************************Declares a non-published table as a member in a cluster. */voiddict_mem_table_make_cluster_member(/*===============================*/ dict_table_t* table, /* in: non-published table */ const char* cluster_name); /* in: cluster name *//**************************************************************************Adds a column definition to a table. */voiddict_mem_table_add_col(/*===================*/ dict_table_t* table, /* in: table */ const char* name, /* in: column name */ ulint mtype, /* in: main datatype */ ulint prtype, /* in: precise type */ ulint len, /* in: length */ ulint prec); /* in: precision *//**************************************************************************Creates an index memory object. */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 copyof the column name if the field is a column. The memory occupiedby the column name may be released only after publishing the index. */voiddict_mem_index_add_field(/*=====================*/ dict_index_t* index, /* in: index */ const char* name, /* in: column name */ ulint order, /* in: order criterion; 0 means an ascending order */ ulint prefix_len); /* in: 0 or the column prefix length in a MySQL index like INDEX (textcol(25)) *//**************************************************************************Frees an index memory object. */voiddict_mem_index_free(/*================*/ dict_index_t* index); /* in: index *//**************************************************************************Creates and initializes a foreign constraint memory object. */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{ hash_node_t hash; /* hash chain node */ ulint ind; /* table column position (they are numbered starting from 0) */ ulint clust_pos;/* position of the column in the clustered index */ ulint ord_part;/* count of how many times this column appears in ordering fields of an index */ const char* name; /* name */ dtype_t type; /* data type */ dict_table_t* table; /* back pointer to table of this column */ ulint aux; /* this is used as an auxiliary variable in some of the functions below */};/* DICT_MAX_INDEX_COL_LEN is measured in bytes and is the max index columnlength + 1. Starting from 4.1.6, we set it to < 3 * 256, so that one cancreate a column prefix index on 255 characters of a TEXT field also in theUTF-8 charset. In that charset, a character may take at most 3 bytes. */#define DICT_MAX_INDEX_COL_LEN 768/* 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 */ ulint order; /* flags for ordering this field: DICT_DESCEND, ... */ ulint prefix_len; /* 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 */ ulint fixed_len; /* 0 or the fixed length of the column if smaller than DICT_MAX_INDEX_COL_LEN */ ulint fixed_offs; /* offset to the field, or ULINT_UNDEFINED if it is not fixed within the record (due to preceding variable-length fields) */};/* Data structure for an index tree */struct dict_tree_struct{ ulint type; /* tree type */ dulint id; /* id of the index stored in the tree, in the case of a mixed index, the id of the clustered index of the cluster table */ ulint space; /* space of index tree */ ulint page; /* index tree root page number */ byte pad[64];/* Padding to prevent other memory hotspots on the same memory cache line */ rw_lock_t lock; /* read-write lock protecting the upper levels of the index tree */ ulint mem_fix;/* count of how many times this tree struct has been memoryfixed (by mini- transactions wanting to access the index tree) */ UT_LIST_BASE_NODE_T(dict_index_t) tree_indexes; /* list of indexes stored in the index tree: if the tree is not of the mixed type there is only one index in the list; if the tree is of the mixed type, the first index in the list is the index of the cluster which owns the tree */ ulint magic_n;/* magic number */};#define DICT_TREE_MAGIC_N 7545676/* Data structure for an index */struct dict_index_struct{ dulint id; /* id of the index */ mem_heap_t* heap; /* memory heap */ ulint type; /* index type */ const char* name; /* index name */ const char* table_name; /* table name */ dict_table_t* table; /* back pointer to table */ ulint space; /* space where the index tree is placed */ ulint trx_id_offset;/* position of the the trx id column in a clustered index record, if the fields before it are known to be of a fixed size,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -