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

Method can_be_merged

sql/sql_lex.cc:2823–2853  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2821*/
2822
2823bool LEX::can_be_merged()
2824{
2825 // TODO: do not forget implement case when select_lex.table_list.elements==0
2826
2827 /* find non VIEW subqueries/unions */
2828 bool selects_allow_merge= select_lex.next_select() == 0;
2829 if (selects_allow_merge)
2830 {
2831 for (SELECT_LEX_UNIT *tmp_unit= select_lex.first_inner_unit();
2832 tmp_unit;
2833 tmp_unit= tmp_unit->next_unit())
2834 {
2835 if (tmp_unit->first_select()->parent_lex == this &&
2836 (tmp_unit->item == 0 ||
2837 (tmp_unit->item->place() != IN_WHERE &&
2838 tmp_unit->item->place() != IN_ON)))
2839 {
2840 selects_allow_merge= 0;
2841 break;
2842 }
2843 }
2844 }
2845
2846 return (selects_allow_merge &&
2847 select_lex.group_list.elements == 0 &&
2848 select_lex.having == 0 &&
2849 select_lex.with_sum_func == 0 &&
2850 select_lex.table_list.elements >= 1 &&
2851 !(select_lex.options & SELECT_DISTINCT) &&
2852 select_lex.select_limit == 0);
2853}
2854
2855
2856/*

Callers

nothing calls this directly

Calls 5

next_selectMethod · 0.80
first_inner_unitMethod · 0.80
next_unitMethod · 0.80
first_selectMethod · 0.80
placeMethod · 0.80

Tested by

no test coverage detected