innodb如何知道一个页面是叶页还是非叶页?

How does innodb know whether a page is leaf page or non-leaf page?

几周来我一直在阅读mysql内部资料,有一个问题困惑

我always.We都知道叶页在B+树数据结构中充当索引并且

非叶子上存储的真实数据page.But我怎么知道哪个是

单页还是非单页?有人请启发我吗?tks.

页眉中有一个 PAGE_LEVEL 字段。如果为零,则为叶页。

https://github.com/twindb/undrop-for-innodb/blob/master/c_parser.c#L657

int leaf_page = mach_read_from_2(page + PAGE_HEADER + PAGE_LEVEL) == 0;

We all know leaf page acts as index in a B+ tree data structure and the real data stored on the non-leaf page.

这句话没有道理。您可以说 table 存储在名为 PRIMARY 或(GEN_CLUSTER_INDEX 如果使用唯一索引作为主索引)的索引中。 PRIMARY 索引是一个 B+ 树。索引的键是主键字段。在非叶子页面中,键是键,值 - 是下面页面的页面 ID。在叶子页面中,键再次成为键,但值是 table 字段的其余部分。

二级索引也是B+树。索引的键是二级键字段,值是记录的主键。