//基本不下面几个系统表 table = dict_mem_table_create("SYS_TABLES", DICT_HDR_SPACE, 8, 0); dict_mem_table_add_col(table, heap, "NAME", DATA_BINARY, 0, 0); dict_mem_table_add_col(table, heap, "ID", DATA_BINARY, 0, 0); dict_mem_table_add_col(table, heap, "N_COLS", DATA_INT, 0, 4); dict_mem_table_add_col(table, heap, "TYPE", DATA_INT, 0, 4); dict_mem_table_add_col(table, heap, "MIX_ID", DATA_BINARY, 0, 0); dict_mem_table_add_col(table, heap, "MIX_LEN", DATA_INT, 0, 4); dict_mem_table_add_col(table, heap, "CLUSTER_NAME", DATA_BINARY, 0, 0); dict_mem_table_add_col(table, heap, "SPACE", DATA_INT, 0, 4); table = dict_mem_table_create("SYS_COLUMNS", DICT_HDR_SPACE, 7, 0); dict_mem_table_add_col(table, heap, "TABLE_ID", DATA_BINARY, 0, 0); dict_mem_table_add_col(table, heap, "POS", DATA_INT, 0, 4); dict_mem_table_add_col(table, heap, "NAME", DATA_BINARY, 0, 0); dict_mem_table_add_col(table, heap, "MTYPE", DATA_INT, 0, 4); dict_mem_table_add_col(table, heap, "PRTYPE", DATA_INT, 0, 4); dict_mem_table_add_col(table, heap, "LEN", DATA_INT, 0, 4); dict_mem_table_add_col(table, heap, "PREC", DATA_INT, 0, 4); table = dict_mem_table_create("SYS_INDEXES", DICT_HDR_SPACE, 7, 0); dict_mem_table_add_col(table, heap, "TABLE_ID", DATA_BINARY, 0, 0); dict_mem_table_add_col(table, heap, "ID", DATA_BINARY, 0, 0); dict_mem_table_add_col(table, heap, "NAME", DATA_BINARY, 0, 0); dict_mem_table_add_col(table, heap, "N_FIELDS", DATA_INT, 0, 4); dict_mem_table_add_col(table, heap, "TYPE", DATA_INT, 0, 4); dict_mem_table_add_col(table, heap, "SPACE", DATA_INT, 0, 4); dict_mem_table_add_col(table, heap, "PAGE_NO", DATA_INT, 0, 4); table = dict_mem_table_create("SYS_FIELDS", DICT_HDR_SPACE, 3, 0); dict_mem_table_add_col(table, heap, "INDEX_ID", DATA_BINARY, 0, 0); dict_mem_table_add_col(table, heap, "POS", DATA_INT, 0, 4); dict_mem_table_add_col(table, heap, "COL_NAME", DATA_BINARY, 0, 0); //外键表还是用SQL语句建的,包括更新也是拼SQL error = que_eval_sql(NULL, "PROCEDURE CREATE_FOREIGN_SYS_TABLES_PROC () IS/n" "BEGIN/n" "CREATE TABLE/n" "SYS_FOREIGN(ID CHAR, FOR_NAME CHAR," " REF_NAME CHAR, N_COLS INT);/n" "CREATE UNIQUE CLUSTERED INDEX ID_IND" " ON SYS_FOREIGN (ID);/n" "CREATE INDEX FOR_IND" " ON SYS_FOREIGN (FOR_NAME);/n" "CREATE INDEX REF_IND" " ON SYS_FOREIGN (REF_NAME);/n" "CREATE TABLE/n" "SYS_FOREIGN_COLS(ID CHAR, POS INT," " FOR_COL_NAME CHAR, REF_COL_NAME CHAR);/n" "CREATE UNIQUE CLUSTERED INDEX ID_IND" " ON SYS_FOREIGN_COLS (ID, POS);/n" "COMMIT WORK;/n" "END;/n" , FALSE, trx);

/* 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 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 */ 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 */ 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 */ unsigned space:32; /* space where the index tree is placed */ unsigned page:32;/* index tree root page number */ unsigned trx_id_offset:10;/* 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, 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 */ 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_longlong* 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 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) */ 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 */ 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 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 flags:8;/* DICT_TF_COMPACT, ... */ 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! */ lock_t* auto_inc_lock;/* a buffer for an auto-inc 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 */ 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_longlong 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 */ /*----------------------*/ mutex_t autoinc_mutex; /* mutex protecting the autoincrement counter */ ib_ulonglong 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. */ /*----------------------*/ #ifdef UNIV_DEBUG ulint magic_n;/* magic number */ # define DICT_TABLE_MAGIC_N 76333786 #endif /* UNIV_DEBUG */ };

innodb system table相关推荐

  1. MySQL 5.6 解决InnoDB: Error: Table “mysql“.“innodb_table_stats“ not found.问题

    MySQL 5.6 解决InnoDB: Error: Table "mysql"."innodb_table_stats" not found.问题 参考文章: ...

  2. system table CRMC_BO_RANGES

    Created by Wang, Jerry, last modified on May 17, 2017 crm_order_objtype_r_select_cb - Controlled by ...

  3. UEFI原理与编程实践--EFI System Table中的输入输出

    这一节UEFI原理与编程的书籍里面貌似没有提到,不过在我上次使用飞腾源代码增加功能的过程中发现logo界面的左上角有个光标,后来发现源代码也有,这就让有强迫症的人非常不爽啦,这个光标怎么来的呢,我找了 ...

  4. 我在 MySQL 的那些年

    作者:赖铮(Allen Lai),前 MySQL 官方团队成员,专注数据库内核开发近二十年,先后就职于达梦,Teradata,北大方正以及 MySQL InnoDB 存储引擎团队,是达梦数据库内核,方 ...

  5. 转.我在MySQL的那些年

    Allen Lai) 前MySQL官方团队成员,专注数据库内核开发近二十年,先后就职于达梦,Teradata,北大方正以及MySQL InnoDB存储引擎团队,是达梦数据库内核,方正XML数据库,以及 ...

  6. rds mysql 表被删了_MySQL · 捉虫动态 · 删除索引导致表无法打开

    问题背景 最近线上遇到一个问题,用户重启实例后发现有张表打不开了,经调研后发现是用户之前的霸蛮操作导致的,下面给出复现步骤: create table t1 (id int not null prim ...

  7. 使用alter table tabname ENGINE=InnoDB后占用的空间更大

    alter table tabname ENGINE=InnoDB之后 原因: 这个表,本身就已经没有空洞的了,比如说刚刚做过一次重建表操作. 在 DDL 期间,如果刚好有外部的 DML 在执行,这期 ...

  8. [转载] 数据库分析手记 —— InnoDB锁机制分析

    作者:倪煜 InnoDB锁机制常常困扰大家,不同的条件下往往表现出不同的锁竞争,在实际工作中经常要分析各种锁超时.死锁的问题.本文通过不同条件下的实验,利用InnoDB系统给出的各种信息,分析了锁的工 ...

  9. mysql+如何开发存储引擎_干货!MySQL 的 InnoDB 存储引擎是怎么设计的?

    MySQL 里还有什么其他成员呢? 对于 MySQL,要记住.或者要放在你随时可以找到的地方的两张图,一张是 MySQL 架构图,另一张则是 InnoDB 架构图: 遇到问题,或者学习到新知识点时,就 ...

  10. MySQL存储引擎之InnoDB

    一.The InnoDB Engine Each InnoDB table is represented on disk by an .frm format file in the database ...

最新文章

  1. 推荐15个国外使用 CSS3 制作的漂亮网站
  2. Spring MVC与表单日期提交的问题
  3. 浙大计算机知识基础,计算机基础知识题浙大远程
  4. v4l打开video设备 ,执行VIDIOC_DQBUF,出现Resource temporarily unavailable 问题
  5. 视频语义显著实例分割数据集SESIV
  6. java语言程序设计基础篇课后答案_《Java语言程序设计:基础篇》课后复习题答案-第十五章.pdf...
  7. 白盒测试用例设计方法
  8. 网上抢购茅台催生黄牛党:必须严打各类抢购软件
  9. cim系统 是什么_CIM和IBM i:它是什么以及它如何工作
  10. c# 2进制 转16进制 ,16进制转2进制
  11. am相干解调matlab文档,AM调制与解调.doc
  12. 佳能尼康宾得等,说说查看各大单反品牌的快门次数方法
  13. 信托公司消金小额贷款项目的现金流预测
  14. IDA 逆向代码 --- _stack_chk_guard变量 之后的局部 怎么处理
  15. Linux 定时器 setitimer
  16. 01-计算机系统概述
  17. 贝宝年报解读:是谁贷走了4.3亿美元?
  18. 【图神经网络】GNN 图神经网络相关知识点
  19. WaaSMedicAgent是什么程序?又叫Windows更新医生服务
  20. Three.js MMDLoader.js Mmd模型的加载 pmx模型加载测试

热门文章

  1. 琼斯是计算体心立方弹性模量_本科阶段固体物理期末重点计算题.doc
  2. uniapp微信公众号跳转小程序(vue项目)
  3. 怎样写商业计划书 【转载】
  4. 视频播放控制:防盗链设置与视频加密及Android中的基础应用
  5. 史上最全面的C语言的学习路线及方法
  6. 字体外面怎么加边框_CSS如何给字体加边框
  7. 专业学习与职业发展之我见
  8. matlab 求矩阵奇异值,MATLAB矩阵特征值和奇异值.
  9. 如何在团队内做技术分享
  10. Word文档中标题前面的黑点如何去掉