diff options
author | Igor Babaev <igor@askmonty.org> | 2021-02-21 22:01:24 -0800 |
---|---|---|
committer | Igor Babaev <igor@askmonty.org> | 2021-02-22 09:19:13 -0800 |
commit | a5b18613ec7966ff1aaa30fe0685fbd7fef8f7c9 (patch) | |
tree | ccf791fe733e976f93638c96d7c8721a181cc898 /sql/sql_tvc.cc | |
parent | a49ce0bf9328e995f5a980d9de4e000f4164c077 (diff) | |
download | mariadb-git-a5b18613ec7966ff1aaa30fe0685fbd7fef8f7c9.tar.gz |
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>
Diffstat (limited to 'sql/sql_tvc.cc')
-rw-r--r-- | sql/sql_tvc.cc | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/sql/sql_tvc.cc b/sql/sql_tvc.cc index 78607b61e6d..0a5f6687e17 100644 --- a/sql/sql_tvc.cc +++ b/sql/sql_tvc.cc @@ -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; } |