cleanup st_select_lex_unit::explainable
This commit is contained in:
parent
721a9df751
commit
57a09a72a3
@ -199,23 +199,12 @@ bool Update_plan::save_explain_data_intern(MEM_ROOT *mem_root,
|
|||||||
&explain->mrr_type);
|
&explain->mrr_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool skip= updating_a_view;
|
|
||||||
|
|
||||||
/* Save subquery children */
|
/* Save subquery children */
|
||||||
for (SELECT_LEX_UNIT *unit= select_lex->first_inner_unit();
|
for (SELECT_LEX_UNIT *unit= select_lex->first_inner_unit();
|
||||||
unit;
|
unit;
|
||||||
unit= unit->next_unit())
|
unit= unit->next_unit())
|
||||||
{
|
{
|
||||||
if (skip)
|
if (unit->explainable())
|
||||||
{
|
|
||||||
skip= false;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
Display subqueries only if they are not parts of eliminated WHERE/ON
|
|
||||||
clauses.
|
|
||||||
*/
|
|
||||||
if (!(unit->item && unit->item->eliminated))
|
|
||||||
explain->add_child(unit->first_select()->select_number);
|
explain->add_child(unit->first_select()->select_number);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -395,7 +384,6 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
|
|||||||
table->map=1;
|
table->map=1;
|
||||||
query_plan.select_lex= thd->lex->first_select_lex();
|
query_plan.select_lex= thd->lex->first_select_lex();
|
||||||
query_plan.table= table;
|
query_plan.table= table;
|
||||||
query_plan.updating_a_view= MY_TEST(table_list->view);
|
|
||||||
|
|
||||||
if (mysql_prepare_delete(thd, table_list, select_lex->with_wild,
|
if (mysql_prepare_delete(thd, table_list, select_lex->with_wild,
|
||||||
select_lex->item_list, &conds,
|
select_lex->item_list, &conds,
|
||||||
|
@ -657,24 +657,12 @@ static void save_insert_query_plan(THD* thd, TABLE_LIST *table_list)
|
|||||||
|
|
||||||
thd->lex->explain->add_insert_plan(explain);
|
thd->lex->explain->add_insert_plan(explain);
|
||||||
|
|
||||||
/* See Update_plan::updating_a_view for details */
|
|
||||||
bool skip= MY_TEST(table_list->view);
|
|
||||||
|
|
||||||
/* Save subquery children */
|
/* Save subquery children */
|
||||||
for (SELECT_LEX_UNIT *unit= thd->lex->first_select_lex()->first_inner_unit();
|
for (SELECT_LEX_UNIT *unit= thd->lex->first_select_lex()->first_inner_unit();
|
||||||
unit;
|
unit;
|
||||||
unit= unit->next_unit())
|
unit= unit->next_unit())
|
||||||
{
|
{
|
||||||
if (skip)
|
if (unit->explainable())
|
||||||
{
|
|
||||||
skip= false;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
Table elimination doesn't work for INSERTS, but let's still have this
|
|
||||||
here for consistency
|
|
||||||
*/
|
|
||||||
if (!(unit->item && unit->item->eliminated))
|
|
||||||
explain->add_child(unit->first_select()->select_number);
|
explain->add_child(unit->first_select()->select_number);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5225,10 +5225,8 @@ int st_select_lex_unit::save_union_explain_part2(Explain_query *output)
|
|||||||
for (SELECT_LEX_UNIT *unit= fake_select_lex->first_inner_unit();
|
for (SELECT_LEX_UNIT *unit= fake_select_lex->first_inner_unit();
|
||||||
unit; unit= unit->next_unit())
|
unit; unit= unit->next_unit())
|
||||||
{
|
{
|
||||||
if (!(unit->item && unit->item->eliminated))
|
if (unit->explainable())
|
||||||
{
|
|
||||||
eu->add_child(unit->first_select()->select_number);
|
eu->add_child(unit->first_select()->select_number);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
fake_select_lex->join->explain= &eu->fake_select_lex_explain;
|
fake_select_lex->join->explain= &eu->fake_select_lex_explain;
|
||||||
}
|
}
|
||||||
|
@ -995,6 +995,19 @@ public:
|
|||||||
int save_union_explain_part2(Explain_query *output);
|
int save_union_explain_part2(Explain_query *output);
|
||||||
unit_common_op common_op();
|
unit_common_op common_op();
|
||||||
|
|
||||||
|
bool explainable()
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Save plans for child subqueries, when
|
||||||
|
(1) they are not parts of eliminated WHERE/ON clauses.
|
||||||
|
(2) they are not merged derived tables
|
||||||
|
(3) they are not hanging CTEs (they are needed for execution)
|
||||||
|
*/
|
||||||
|
return !(item && item->eliminated) &&
|
||||||
|
!(derived && !derived->is_materialized_derived()) &&
|
||||||
|
!(with_element && (!derived || !derived->derived_result));
|
||||||
|
}
|
||||||
|
|
||||||
void reset_distinct();
|
void reset_distinct();
|
||||||
void fix_distinct();
|
void fix_distinct();
|
||||||
|
|
||||||
@ -2942,15 +2955,6 @@ protected:
|
|||||||
bool impossible_where;
|
bool impossible_where;
|
||||||
bool no_partitions;
|
bool no_partitions;
|
||||||
public:
|
public:
|
||||||
/*
|
|
||||||
When single-table UPDATE updates a VIEW, that VIEW's select is still
|
|
||||||
listed as the first child. When we print EXPLAIN, it looks like a
|
|
||||||
subquery.
|
|
||||||
In order to get rid of it, updating_a_view=TRUE means that first child
|
|
||||||
select should not be shown when printing EXPLAIN.
|
|
||||||
*/
|
|
||||||
bool updating_a_view;
|
|
||||||
|
|
||||||
/* Allocate things there */
|
/* Allocate things there */
|
||||||
MEM_ROOT *mem_root;
|
MEM_ROOT *mem_root;
|
||||||
|
|
||||||
|
@ -26745,21 +26745,8 @@ int JOIN::save_explain_data_intern(Explain_query *output,
|
|||||||
tmp_unit;
|
tmp_unit;
|
||||||
tmp_unit= tmp_unit->next_unit())
|
tmp_unit= tmp_unit->next_unit())
|
||||||
{
|
{
|
||||||
/*
|
if (tmp_unit->explainable())
|
||||||
Display subqueries only if
|
|
||||||
(1) they are not parts of ON clauses that were eliminated by table
|
|
||||||
elimination.
|
|
||||||
(2) they are not merged derived tables
|
|
||||||
(3) they are not hanging CTEs (they are needed for execution)
|
|
||||||
*/
|
|
||||||
if (!(tmp_unit->item && tmp_unit->item->eliminated) && // (1)
|
|
||||||
(!tmp_unit->derived ||
|
|
||||||
tmp_unit->derived->is_materialized_derived()) && // (2)
|
|
||||||
!(tmp_unit->with_element &&
|
|
||||||
(!tmp_unit->derived || !tmp_unit->derived->derived_result))) // (3)
|
|
||||||
{
|
|
||||||
explain->add_child(tmp_unit->first_select()->select_number);
|
explain->add_child(tmp_unit->first_select()->select_number);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (select_lex->is_top_level_node())
|
if (select_lex->is_top_level_node())
|
||||||
@ -26813,16 +26800,7 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
|
|||||||
DBUG_ASSERT(ref == unit->item);
|
DBUG_ASSERT(ref == unit->item);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
if (unit->explainable())
|
||||||
Save plans for child subqueries, when
|
|
||||||
(1) they are not parts of eliminated WHERE/ON clauses.
|
|
||||||
(2) they are not VIEWs that were "merged for INSERT".
|
|
||||||
(3) they are not hanging CTEs (they are needed for execution)
|
|
||||||
*/
|
|
||||||
if (!(unit->item && unit->item->eliminated) && // (1)
|
|
||||||
!(unit->derived && unit->derived->merged_for_insert) && // (2)
|
|
||||||
!(unit->with_element &&
|
|
||||||
(!unit->derived || !unit->derived->derived_result))) // (3)
|
|
||||||
{
|
{
|
||||||
if (mysql_explain_union(thd, unit, result))
|
if (mysql_explain_union(thd, unit, result))
|
||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
|
@ -438,7 +438,6 @@ int mysql_update(THD *thd,
|
|||||||
my_error(ER_NON_UPDATABLE_TABLE, MYF(0), table_list->alias.str, "UPDATE");
|
my_error(ER_NON_UPDATABLE_TABLE, MYF(0), table_list->alias.str, "UPDATE");
|
||||||
DBUG_RETURN(1);
|
DBUG_RETURN(1);
|
||||||
}
|
}
|
||||||
query_plan.updating_a_view= MY_TEST(table_list->view);
|
|
||||||
|
|
||||||
/* Calculate "table->covering_keys" based on the WHERE */
|
/* Calculate "table->covering_keys" based on the WHERE */
|
||||||
table->covering_keys= table->s->keys_in_use;
|
table->covering_keys= table->s->keys_in_use;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user