From ab44e892d800f6d775df15e3829391a180675a64 Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Sun, 28 Feb 2016 18:18:29 +0300 Subject: [PATCH] MDEV-9652: EXPLAIN FORMAT=JSON should show outer_ref_cond Show outer_ref_condition in EXPLAIN FORMAT=JSON output. --- mysql-test/r/explain_json.result | 40 ++++++++++++++++++++++++++++++++ mysql-test/t/explain_json.test | 10 ++++++++ sql/sql_explain.cc | 6 +++++ sql/sql_explain.h | 3 ++- sql/sql_select.cc | 1 + 5 files changed, 59 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/explain_json.result b/mysql-test/r/explain_json.result index a42f5af114c..46d586ac29d 100644 --- a/mysql-test/r/explain_json.result +++ b/mysql-test/r/explain_json.result @@ -1543,3 +1543,43 @@ ANALYZE set optimizer_switch=@tmp_optimizer_switch; set join_cache_level=@tmp_join_cache_level; drop table t1,t2,t3,t4; +# +# MDEV-9652: EXPLAIN FORMAT=JSON should show outer_ref_cond +# +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int); +insert into t1 select a,a from t0; +explain format=json +select a, (select max(a) from t1 where t0.a<5 and t1.badd_member("const_condition"); write_item(writer, exec_const_cond); } + if (outer_ref_cond) + { + writer->add_member("outer_ref_condition"); + write_item(writer, outer_ref_cond); + } + /* we do not print HAVING which always evaluates to TRUE */ if (having || (having_value == Item::COND_FALSE)) { diff --git a/sql/sql_explain.h b/sql/sql_explain.h index 6a3e6c25a61..844773c4a47 100644 --- a/sql/sql_explain.h +++ b/sql/sql_explain.h @@ -232,9 +232,10 @@ public: /* Expensive constant condition */ Item *exec_const_cond; + Item *outer_ref_cond; /* HAVING condition */ - COND *having; + Item *having; Item::cond_result having_value; /* Global join attributes. In tabular form, they are printed on the first row */ diff --git a/sql/sql_select.cc b/sql/sql_select.cc index b1e46478aa6..4ce29f1d666 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -24252,6 +24252,7 @@ int JOIN::save_explain_data_intern(Explain_query *output, bool need_tmp_table, xpl_sel->using_filesort= true; xpl_sel->exec_const_cond= exec_const_cond; + xpl_sel->outer_ref_cond= outer_ref_cond; if (tmp_having) xpl_sel->having= tmp_having; else