summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormariadb-LuisLizardo <luis.lizardo@mariadb.com>2022-07-14 12:06:00 +0200
committermariadb-LuisLizardo <luis.lizardo@mariadb.com>2022-07-14 12:06:00 +0200
commitd807c630d18564816a4c0d9128539fdb23fabf4e (patch)
tree35c3a250216c70e8fc604359ec97641900d91595
parent82ab6c0a38d6ce9998c5b638bc00a804869d44c1 (diff)
downloadmariadb-git-MDEV-28926-query-optimizer-json.tar.gz
Change logic to always close the writer after printing query blocksMDEV-28926-query-optimizer-json
-rw-r--r--sql/sql_explain.cc15
-rw-r--r--sql/sql_explain.h2
2 files changed, 9 insertions, 8 deletions
diff --git a/sql/sql_explain.cc b/sql/sql_explain.cc
index 0710ef9d64f..361d56ae9df 100644
--- a/sql/sql_explain.cc
+++ b/sql/sql_explain.cc
@@ -276,13 +276,14 @@ int Explain_query::print_explain_json(select_result_sink *output,
is_show_cmd = true;
}
- if( print_query_blocks_json(&writer, is_analyze, is_show_cmd) ){
- return 1;
- }
+ bool were_query_plans_found = print_query_blocks_json(&writer, is_analyze, is_show_cmd);
writer.end_object();
- send_explain_json_to_output(&writer, output);
+ if(were_query_plans_found){
+ send_explain_json_to_output(&writer, output);
+ }
+
return 0;
}
@@ -298,7 +299,7 @@ void Explain_query::print_query_optimization_json(Json_writer *writer)
}
}
-int Explain_query::print_query_blocks_json(Json_writer *writer, const bool is_analyze, const bool is_show_cmd)
+bool Explain_query::print_query_blocks_json(Json_writer *writer, const bool is_analyze, const bool is_show_cmd)
{
if (upd_del_plan)
upd_del_plan->print_explain_json(this, writer, is_analyze, is_show_cmd);
@@ -309,11 +310,11 @@ int Explain_query::print_query_blocks_json(Json_writer *writer, const bool is_an
/* Start printing from root node with id=1 */
Explain_node *node= get_node(1);
if (!node)
- return 1; /* No query plan */
+ return false; /* No query plan */
node->print_explain_json(this, writer, is_analyze, is_show_cmd);
}
- return 0;
+ return true;
}
void Explain_query::send_explain_json_to_output(Json_writer *writer, select_result_sink *output)
diff --git a/sql/sql_explain.h b/sql/sql_explain.h
index ff748aafff2..f96b9e7f4ea 100644
--- a/sql/sql_explain.h
+++ b/sql/sql_explain.h
@@ -512,7 +512,7 @@ public:
Explain_update *get_upd_del_plan() { return upd_del_plan; }
private:
- int print_query_blocks_json(Json_writer *writer, const bool is_analyze, const bool is_show_cmd);
+ bool print_query_blocks_json(Json_writer *writer, const bool is_analyze, const bool is_show_cmd);
void print_query_optimization_json(Json_writer *writer);
void send_explain_json_to_output(Json_writer *writer, select_result_sink *output);