MySQL源码 解析器
%token SELECT_SYM select: select_init { LEX *lex= Lex; lex->sql_command= SQLCOM_SELECT; }; select_item_list: select_item_list ‘,‘ select_item | select_item | ‘*‘ { THD *thd= YYTHD; Item *item= new (thd->mem_root) Item_field(&thd->lex->current_select->context,NULL, NULL, "*"); if (item == NULL) MYSQL_YYABORT; if (add_item_to_list(thd, item)) MYSQL_YYABORT; (thd->lex->current_select->with_wild)++; }; where_clause: /* empty */ { Select->where= 0; } | WHERE { Select->parsing_place= IN_WHERE; } expr { SELECT_LEX *select= Select; select->where= $3; select->parsing_place= NO_MATTER; if ($3) $3->top_level_item(); };
(gdb) print select_lex->table_list $33 = { <Sql_alloc> = {<No data fields>}, members of SQL_I_List<TABLE_LIST>: elements = 1, first = 0x8ca04818, next = 0x8ca04818
(gdb) print select_lex->where->type() $32 = Item::FUNC_ITEM (gdb) p select_lex->where)->args))->type() $30 = Item::FIELD_ITEM (gdb) p select_lex->where)->args++))->type() $29 = Item::INT_ITEM
结构如下:
where |-->FUNC_ITEM |-->FIELD_ITEM("id") |-->INT_ITEM(1)
3. item_list
(gdb) print *(Item_field*)(select_lex->item_list->first->info) name = 0x8ca04758 "id", (gdb) print *(Item_field*)(select_lex->item_list->first->next->info) name = 0x8cb047f8 "name",
结构如下:
item_list: |-->Item_field("id") |-->Item_field("name")
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。