1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

MDEV-24936 EXPLAIN for query based on table value constructor lacks info

on used subqueries

If a query was based on a table value constructor that contained subqueries
then EXPLAIN for such query did not contain any lines explaining the
execution plans of the subqueries.
This happened because
- no optimize() method was called for any subquery used by the table value
  constructor when EXPLAIN command for the query was processed;
- EXPLAIN node created for the table value constructor itself did not
  assume that some child nodes could be attached to it.

Approved by Oleksandr Byelkin <sanja@mariadb.com>
This commit is contained in:
Igor Babaev
2021-02-21 22:01:24 -08:00
parent a49ce0bf93
commit a5b18613ec
3 changed files with 72 additions and 2 deletions

View File

@ -342,6 +342,13 @@ int table_value_constr::save_explain_data_intern(THD *thd,
if (select_lex->master_unit()->derived)
explain->connection_type= Explain_node::EXPLAIN_NODE_DERIVED;
for (SELECT_LEX_UNIT *unit= select_lex->first_inner_unit();
unit;
unit= unit->next_unit())
{
explain->add_child(unit->first_select()->select_number);
}
output->add_node(explain);
if (select_lex->is_top_level_node())
@ -366,9 +373,14 @@ bool table_value_constr::optimize(THD *thd)
thd->lex->explain && // for "SET" command in SPs.
(!thd->lex->explain->get_select(select_lex->select_number)))
{
return save_explain_data_intern(thd, thd->lex->explain);
if (save_explain_data_intern(thd, thd->lex->explain))
return true;
}
return 0;
if (select_lex->optimize_unflattened_subqueries(true))
return true;
return false;
}