diff options
author | Oleksandr Byelkin <sanja@mariadb.com> | 2015-03-25 18:27:10 +0100 |
---|---|---|
committer | Sergei Petrunia <psergey@askmonty.org> | 2015-06-30 23:07:14 +0300 |
commit | c6aee27b73232fc6ba3e8b55adbb0abba4f0171b (patch) | |
tree | c996b7f96ff4d063b2112e8b863825a2cff906b2 /sql/sql_lex.cc | |
parent | 498a264d19f041c36d71e41a32c16ac40a014a3e (diff) | |
download | mariadb-git-c6aee27b73232fc6ba3e8b55adbb0abba4f0171b.tar.gz |
MDEV-7811: EXPLAIN/ANALYZE FORMAT=JSON should show subquery cache
Diffstat (limited to 'sql/sql_lex.cc')
-rw-r--r-- | sql/sql_lex.cc | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index ac2eda2d0de..6c835c4293f 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -3505,6 +3505,8 @@ bool st_select_lex::optimize_unflattened_subqueries(bool const_only) bool empty_union_result= true; bool is_correlated_unit= false; + bool first= true; + bool union_plan_saved= false; /* If the subquery is a UNION, optimize all the subqueries in the UNION. If there is no UNION, then the loop will execute once for the subquery. @@ -3512,6 +3514,17 @@ bool st_select_lex::optimize_unflattened_subqueries(bool const_only) for (SELECT_LEX *sl= un->first_select(); sl; sl= sl->next_select()) { JOIN *inner_join= sl->join; + if (first) + first= false; + else + { + if (!union_plan_saved) + { + union_plan_saved= true; + if (un->save_union_explain(un->thd->lex->explain)) + return true; /* Failure */ + } + } if (!inner_join) continue; SELECT_LEX *save_select= un->thd->lex->current_select; @@ -4365,10 +4378,15 @@ void LEX::restore_set_statement_var() int st_select_lex_unit::save_union_explain(Explain_query *output) { SELECT_LEX *first= first_select(); + + if (output->get_union(first->select_number)) + return 0; /* Already added */ + Explain_union *eu= new (output->mem_root) Explain_union(output->mem_root, thd->lex->analyze_stmt); + if (derived) eu->connection_type= Explain_node::EXPLAIN_NODE_DERIVED; /* |