summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorSergei Petrunia <psergey@askmonty.org>2014-12-06 20:33:25 +0300
committerSergei Petrunia <psergey@askmonty.org>2014-12-06 20:33:25 +0300
commit913b7672c5fe2db750a382685f0810d383b43faa (patch)
tree98f8456628e218820a1e4bfd35b72d457682f7d1 /sql
parentdb21fddc3740dfa48f3443751c48282467afac5e (diff)
parenteeef80d09f8045d99963a2bf2fa92595c55bb26d (diff)
downloadmariadb-git-913b7672c5fe2db750a382685f0810d383b43faa.tar.gz
Merge bb-10.1-explain-json into 10.1
Diffstat (limited to 'sql')
-rw-r--r--sql/my_json_writer.cc6
-rw-r--r--sql/sql_explain.cc29
-rw-r--r--sql/sql_explain.h6
-rw-r--r--sql/sql_select.cc2
4 files changed, 38 insertions, 5 deletions
diff --git a/sql/my_json_writer.cc b/sql/my_json_writer.cc
index 4f933583347..7a3dc776093 100644
--- a/sql/my_json_writer.cc
+++ b/sql/my_json_writer.cc
@@ -218,7 +218,8 @@ bool Single_line_formatting_helper::on_start_array()
}
else
{
- state= INACTIVE;
+ if (state != DISABLED)
+ state= INACTIVE;
// TODO: what if we have accumulated some stuff already? shouldn't we
// flush it?
return false; // not handled
@@ -313,6 +314,9 @@ void Single_line_formatting_helper::flush_on_one_line()
void Single_line_formatting_helper::disable_and_flush()
{
+ if (state == DISABLED)
+ return;
+
bool start_array= (state == IN_ARRAY);
state= DISABLED;
// deactivate ourselves and flush all accumulated calls.
diff --git a/sql/sql_explain.cc b/sql/sql_explain.cc
index 800f2ce309b..c68f86ce72c 100644
--- a/sql/sql_explain.cc
+++ b/sql/sql_explain.cc
@@ -27,6 +27,8 @@ const char * STR_DELETING_ALL_ROWS= "Deleting all rows";
const char * STR_IMPOSSIBLE_WHERE= "Impossible WHERE";
const char * STR_NO_ROWS_AFTER_PRUNING= "No matching rows after partition pruning";
+static void write_item(Json_writer *writer, Item *item);
+
Explain_query::Explain_query(THD *thd_arg, MEM_ROOT *root) :
mem_root(root), upd_del_plan(NULL), insert_plan(NULL),
unions(root), selects(root), thd(thd_arg), apc_enabled(false),
@@ -732,7 +734,17 @@ void Explain_select::print_explain_json(Explain_query *query,
Explain_basic_join does not have ORDER/GROUP.
A: factor out join tab printing loop into a common func.
*/
- Explain_basic_join::print_explain_json(query, writer, is_analyze);
+ writer->add_member("query_block").start_object();
+ writer->add_member("select_id").add_ll(select_id);
+
+ if (exec_const_cond)
+ {
+ writer->add_member("const_condition");
+ write_item(writer, exec_const_cond);
+ }
+
+ Explain_basic_join::print_explain_json_interns(query, writer, is_analyze);
+ writer->end_object();
}
}
@@ -742,10 +754,20 @@ void Explain_basic_join::print_explain_json(Explain_query *query,
Json_writer *writer,
bool is_analyze)
{
- Json_writer_nesting_guard guard(writer);
-
writer->add_member("query_block").start_object();
writer->add_member("select_id").add_ll(select_id);
+
+ print_explain_json_interns(query, writer, is_analyze);
+
+ writer->end_object();
+}
+
+
+void Explain_basic_join::print_explain_json_interns(Explain_query *query,
+ Json_writer *writer,
+ bool is_analyze)
+{
+ Json_writer_nesting_guard guard(writer);
for (uint i=0; i< n_join_tabs; i++)
{
if (join_tabs[i]->start_dups_weedout)
@@ -757,7 +779,6 @@ void Explain_basic_join::print_explain_json(Explain_query *query,
writer->end_object();
}
print_explain_json_for_children(query, writer, is_analyze);
- writer->end_object();
}
diff --git a/sql/sql_explain.h b/sql/sql_explain.h
index a7ef0beb649..c4bfa4d09bf 100644
--- a/sql/sql_explain.h
+++ b/sql/sql_explain.h
@@ -175,6 +175,9 @@ public:
void print_explain_json(Explain_query *query, Json_writer *writer,
bool is_analyze);
+ void print_explain_json_interns(Explain_query *query, Json_writer *writer,
+ bool is_analyze);
+
/* A flat array of Explain structs for tables. */
Explain_table_access** join_tabs;
uint n_join_tabs;
@@ -222,6 +225,9 @@ public:
*/
const char *message;
+ /* Expensive constant condition */
+ Item *exec_const_cond;
+
/* Global join attributes. In tabular form, they are printed on the first row */
bool using_temporary;
bool using_filesort;
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index a1231152254..cbb5868623c 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -23768,6 +23768,8 @@ int JOIN::save_explain_data_intern(Explain_query *output, bool need_tmp_table,
if (need_order)
xpl_sel->using_filesort= true;
+ xpl_sel->exec_const_cond= exec_const_cond;
+
JOIN_TAB* const first_top_tab= first_breadth_first_tab(join, WALK_OPTIMIZATION_TABS);
JOIN_TAB* prev_bush_root_tab= NULL;