Commit c46eadb2 authored by Sergei Petrunia's avatar Sergei Petrunia

EXPLAIN FORMAT=JSON: support EXPLAIN FORMAT=JSON INSERT ...

parent e235bb86
...@@ -343,7 +343,7 @@ EXPLAIN ...@@ -343,7 +343,7 @@ EXPLAIN
} }
drop table t1; drop table t1;
# #
# Single-table UPDATE/DELETE # Single-table UPDATE/DELETE, INSERT
# #
explain format=json delete from t0; explain format=json delete from t0;
EXPLAIN EXPLAIN
...@@ -393,6 +393,41 @@ EXPLAIN ...@@ -393,6 +393,41 @@ EXPLAIN
} }
} }
} }
explain format=json insert into t0 values (1);
EXPLAIN
{
"query_block": {
"select_id": 1,
"table": {
"table_name": "t0"
}
}
}
create table t1 like t0;
explain format=json insert into t1 values ((select max(a) from t0));
EXPLAIN
{
"query_block": {
"select_id": 1,
"table": {
"table_name": "t1"
},
"subqueries": [
{
"query_block": {
"select_id": 2,
"table": {
"table_name": "t0",
"access_type": "ALL",
"rows": 10,
"filtered": 100
}
}
}
]
}
}
drop table t1;
# #
# A derived table # A derived table
# #
......
...@@ -71,7 +71,7 @@ select * from t1 tbl1, t1 tbl2 where tbl1.a=tbl2.a and tbl1.b < 3 and tbl2.b < 5 ...@@ -71,7 +71,7 @@ select * from t1 tbl1, t1 tbl2 where tbl1.a=tbl2.a and tbl1.b < 3 and tbl2.b < 5
drop table t1; drop table t1;
--echo # --echo #
--echo # Single-table UPDATE/DELETE --echo # Single-table UPDATE/DELETE, INSERT
--echo # --echo #
explain format=json delete from t0; explain format=json delete from t0;
explain format=json delete from t0 where 1 > 2; explain format=json delete from t0 where 1 > 2;
...@@ -80,6 +80,13 @@ explain format=json delete from t0 where a < 3; ...@@ -80,6 +80,13 @@ explain format=json delete from t0 where a < 3;
explain format=json update t0 set a=3 where a in (2,3,4); explain format=json update t0 set a=3 where a in (2,3,4);
explain format=json insert into t0 values (1);
create table t1 like t0;
explain format=json insert into t1 values ((select max(a) from t0));
drop table t1;
--echo # --echo #
--echo # A derived table --echo # A derived table
--echo # --echo #
......
...@@ -194,10 +194,7 @@ void Explain_query::print_explain_json(select_result_sink *output, bool is_analy ...@@ -194,10 +194,7 @@ void Explain_query::print_explain_json(select_result_sink *output, bool is_analy
if (upd_del_plan) if (upd_del_plan)
upd_del_plan->print_explain_json(this, &writer, is_analyze); upd_del_plan->print_explain_json(this, &writer, is_analyze);
else if (insert_plan) else if (insert_plan)
{ insert_plan->print_explain_json(this, &writer, is_analyze);
//insert_plan->print_explain(this, output, explain_flags, is_analyze);
DBUG_ASSERT(0);
}
else else
{ {
/* Start printing from node with id=1 */ /* Start printing from node with id=1 */
...@@ -1808,6 +1805,20 @@ int Explain_insert::print_explain(Explain_query *query, ...@@ -1808,6 +1805,20 @@ int Explain_insert::print_explain(Explain_query *query,
return print_explain_for_children(query, output, explain_flags, is_analyze); return print_explain_for_children(query, output, explain_flags, is_analyze);
} }
void Explain_insert::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(1);
writer->add_member("table").start_object();
writer->add_member("table_name").add_str(table_name.c_ptr());
writer->end_object(); // table
print_explain_json_for_children(query, writer, is_analyze);
writer->end_object(); // query_block
}
void delete_explain_query(LEX *lex) void delete_explain_query(LEX *lex)
{ {
......
...@@ -704,8 +704,7 @@ class Explain_insert : public Explain_node ...@@ -704,8 +704,7 @@ class Explain_insert : public Explain_node
int print_explain(Explain_query *query, select_result_sink *output, int print_explain(Explain_query *query, select_result_sink *output,
uint8 explain_flags, bool is_analyze); uint8 explain_flags, bool is_analyze);
void print_explain_json(Explain_query *query, Json_writer *writer, void print_explain_json(Explain_query *query, Json_writer *writer,
bool is_analyze) bool is_analyze);
{ /* EXPLAIN_JSON_NOT_IMPL */}
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment