参考文献

词法分析&语法分析过程

初始化字段

  • 对于select子句中的每个字段,都会创建一个Item_field类(或子类)的实例。

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    // sql/item.h
    class Item_field : public Item_ident {
    typedef Item_ident super;

    private:
    Field *result_field{nullptr};
    Field *last_org_destination_field{nullptr};
    Field *last_destination_field{nullptr};
    uint32_t last_org_destination_field_memcpyable = ~0U;
    uint32_t last_destination_field_memcpyable = ~0U;
    const Item_field *m_base_item_field{nullptr};
    bool m_protected_by_any_value{false};
    Item_equal *m_multi_equality{nullptr};
  • select子句中,字段可能有2种类型,一种是星号*,一种是普通字段,星号会用Item_asterisk类实例化,而Item_asterisk类是Item_field类的子类。普通字段就直接用Item_field类实例化。

    1
    2
    3
    4
    // sql/item.h
    class Item_asterisk : public Item_field {
    typedef Item_field super;
    };
  • 词法分析&语法分析阶段,各字段只是完成了Item_field类的实例化,但是还没有对应到表中真实的字段。

初始化表