MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / mysql_sql_parse

Function mysql_sql_parse

sqladvisor/main.cc:1145–1211  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1143}
1144
1145void mysql_sql_parse(Item *item_where) {
1146 const Item::Type item_where_type = item_where->type();
1147 switch (item_where_type) {
1148 case Item::FUNC_ITEM: {
1149 Item_func *item_func = (Item_func*) item_where;
1150 if (item_func->argument_count() > 0) {
1151 Item **item_end = (item_func->arguments())
1152 + item_func->argument_count() - 1;
1153 if (item_func->argument_count() == 2
1154 && (*(item_func->arguments()))->type() == Item::FIELD_ITEM
1155 && (*item_end)->type() == Item::FIELD_ITEM) {
1156 mysql_sql_parse_join(item_where);
1157 } else {
1158 String * field_print = new (thd->mem_root) String();
1159 item_func->print(field_print, QT_ORDINARY);
1160 for (Item **child = item_func->arguments(); child <= item_end;
1161 child++) {
1162 if ((*child)->type() == Item::FIELD_ITEM) {
1163 if (options.verbose)
1164 sql_print_information("第%d步:开始解析where中的条件:%s \n",
1165 STEP_CNT++, field_print->c_ptr_safe());
1166 if (item_func->functype() == Item_func::LIKE_FUNC
1167 && is_like_pre(field_print->c_ptr_safe())) {
1168 if (options.verbose)
1169 sql_print_information(
1170 "第%d步:条件%s 是like前缀匹配,跳过不分析. \n",
1171 STEP_CNT++, field_print->c_ptr_safe());
1172 continue;
1173 }
1174 mysql_sql_parse_field(((Item_field *) (*child)),
1175 item_func->functype(),
1176 field_print->c_ptr_safe());
1177 }
1178 }
1179 }
1180 }
1181 break;
1182 }
1183 case Item::COND_ITEM: {
1184 Item_cond *item_cond = (Item_cond*) item_where;
1185 switch (item_cond->functype()) {
1186 case Item_func::COND_AND_FUNC: {
1187 List_iterator<Item> li_item_cond(*item_cond->argument_list());
1188 Item *item_abc;
1189 while ((item_abc = li_item_cond++)) {
1190 mysql_sql_parse(item_abc);
1191 }
1192 break;
1193 }
1194 case Item_func::COND_OR_FUNC: {
1195 break;
1196 }
1197 default: {
1198 break;
1199 }
1200 }
1201 break;
1202 }

Callers 2

mysql_sql_parse_joinFunction · 0.85
mainFunction · 0.85

Calls 11

mysql_sql_parse_joinFunction · 0.85
sql_print_informationFunction · 0.85
is_like_preFunction · 0.85
mysql_sql_parse_fieldFunction · 0.85
argument_countMethod · 0.80
argumentsMethod · 0.80
c_ptr_safeMethod · 0.80
argument_listMethod · 0.80
typeMethod · 0.45
printMethod · 0.45
functypeMethod · 0.45

Tested by

no test coverage detected