我试图理解 dict_col_t 结构中的变量 ord_part。
声明如下:
http://osxr.org/mysql/source/storage/innobase/include/dict0mem.h#0428
表示未签名
ord_part:1; /*!< nonzero if this column appears in the ordering fields
of an index */
由于没有意义,所以我在源代码中搜索所有用例中的ord_part
http://osxr.org/mysql/source/storage/innobase/row/row0row.cc#0134
http://osxr.org/mysql/source/storage/innobase/row/row0row.cc#0352
http://osxr.org/mysql/source/storage/innobase/dict/dict0dict.cc#1949
http://osxr.org/mysql/source/storage/innobase/dict/dict0dict.cc#2308
最后一个链接是唯一一个ord_part变成1的地方,当我们加上索引的时候,这个变量就变成了1。根据其他链接,我感觉1表示我们存储的是secondary key的前缀。
有人熟悉这个变量吗?这个变量是如何工作的?
最佳答案
仔细研究源码后,这里是我的答案
ord_part 本身没有任何意义。当我们添加索引时,它将始终变为 1。如果此列上有索引,则 ord_part 必须为 1。但是,如果 ord_part 为 1,则并不意味着此列上必须有索引。这是 MySQL 错误(https://bugs.launchpad.net/percona-server/+bug/1469901)。
它必须与其他变量或函数一起使用。当它们一起工作时,InnoDB 可以从外部页面获取实际数据。
有用的源代码: http://osxr.org/mysql/source/storage/innobase/row/row0row.cc#0058
关于mysql - MySQL 的 dict_col_struct 中的 ord_part 是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31343702/