标签:
typedef struct dict_table_struct dict_table_t; /** 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{ table_id_t id; /*!< id of the table */ mem_heap_t* heap; /*!< memory heap */ 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_TF2_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 */ unsigned corrupted:1; /*!< TRUE if table is corrupted */ 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. */ #ifndef UNIV_HOTBACKUP 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 */ ib_rbt_t* foreign_rbt; /*!< a rb-tree of all foreign keys listed in foreign_list, sorted by foreign->id */ ib_rbt_t* referenced_rbt; /*!< a rb-tree of all foreign keys listed in referenced_list, sorted by foreign->id */ 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 */ unsigned fk_max_recusive_level:8; /*!< maximum recursive level we support when loading tables chained together with FK constraints. If exceeds this level, we will stop loading child table into memory along with its parent table */ 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! */ trx_id_t query_cache_inv_trx_id; /*!< transactions whose trx id is smaller 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() */ /** Statistics for query optimization. The following stat_* members are usually protected by dict_table_stats_lock(). In some exceptional cases (performance critical code paths) we access or modify stat_n_rows and stat_modified_counter without any protection. */ /* @{ */ 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. */ /* @} */ /*----------------------*/ #endif /* !UNIV_HOTBACKUP */ #ifdef UNIV_DEBUG ulint magic_n;/*!< magic number */ /** Value of dict_table_struct::magic_n */ # define DICT_TABLE_MAGIC_N 76333786 #endif /* UNIV_DEBUG */ };
标签:
原文地址:http://www.cnblogs.com/taek/p/4956794.html