Commit 702aee64 authored by Sergei Petrunia's avatar Sergei Petrunia

MDEV-6323: ‘explain_node’ may be used uninitialized in this function

- Remove the compiler warning, add assert statements.
- make select_describe() not call mysql_explain_union() for
  views that were "merged for INSERT".
parent da181fee
...@@ -23827,6 +23827,13 @@ int JOIN::save_explain_data_intern(Explain_query *output, bool need_tmp_table, ...@@ -23827,6 +23827,13 @@ int JOIN::save_explain_data_intern(Explain_query *output, bool need_tmp_table,
(ulong)join->select_lex, join->select_lex->type, (ulong)join->select_lex, join->select_lex->type,
message ? message : "NULL")); message ? message : "NULL"));
DBUG_ASSERT(have_query_plan == QEP_AVAILABLE); DBUG_ASSERT(have_query_plan == QEP_AVAILABLE);
/* fake_select_lex is created/printed by Explain_union */
DBUG_ASSERT(join->select_lex != join->unit->fake_select_lex);
/* There should be no attempts to save query plans for merged selects */
DBUG_ASSERT(!join->select_lex->master_unit()->derived ||
join->select_lex->master_unit()->derived->is_materialized_derived());
/* Don't log this into the slow query log */ /* Don't log this into the slow query log */
if (message) if (message)
...@@ -23843,12 +23850,7 @@ int JOIN::save_explain_data_intern(Explain_query *output, bool need_tmp_table, ...@@ -23843,12 +23850,7 @@ int JOIN::save_explain_data_intern(Explain_query *output, bool need_tmp_table,
/* Setting xpl_sel->message means that all other members are invalid */ /* Setting xpl_sel->message means that all other members are invalid */
output->add_node(xpl_sel); output->add_node(xpl_sel);
} }
else if (join->select_lex == join->unit->fake_select_lex) else
{
/* Do nothing, Explain_union will create and print fake_select_lex */
}
else if (!join->select_lex->master_unit()->derived ||
join->select_lex->master_unit()->derived->is_materialized_derived())
{ {
Explain_select *xpl_sel; Explain_select *xpl_sel;
explain_node= xpl_sel= new (output->mem_root) Explain_select(output->mem_root); explain_node= xpl_sel= new (output->mem_root) Explain_select(output->mem_root);
...@@ -24013,10 +24015,12 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, ...@@ -24013,10 +24015,12 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
} }
/* /*
Display subqueries only if they are not parts of eliminated WHERE/ON Save plans for child subqueries, when
clauses. (1) they are not parts of eliminated WHERE/ON clauses.
(2) they are not VIEWs that were "merged for INSERT".
*/ */
if (!(unit->item && unit->item->eliminated)) if (!(unit->item && unit->item->eliminated) && // (1)
!(unit->derived && unit->derived->merged_for_insert)) // (2)
{ {
if (mysql_explain_union(thd, unit, result)) if (mysql_explain_union(thd, unit, result))
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment