mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
EXPLAIN FORMAT=JSON: support EXPLAIN FORMAT=JSON INSERT ...
This commit is contained in:
@ -343,7 +343,7 @@ EXPLAIN
|
||||
}
|
||||
drop table t1;
|
||||
#
|
||||
# Single-table UPDATE/DELETE
|
||||
# Single-table UPDATE/DELETE, INSERT
|
||||
#
|
||||
explain format=json delete from t0;
|
||||
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
|
||||
#
|
||||
|
@ -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;
|
||||
|
||||
--echo #
|
||||
--echo # Single-table UPDATE/DELETE
|
||||
--echo # Single-table UPDATE/DELETE, INSERT
|
||||
--echo #
|
||||
explain format=json delete from t0;
|
||||
explain format=json delete from t0 where 1 > 2;
|
||||
@ -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 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 # A derived table
|
||||
--echo #
|
||||
|
@ -194,10 +194,7 @@ void Explain_query::print_explain_json(select_result_sink *output, bool is_analy
|
||||
if (upd_del_plan)
|
||||
upd_del_plan->print_explain_json(this, &writer, is_analyze);
|
||||
else if (insert_plan)
|
||||
{
|
||||
//insert_plan->print_explain(this, output, explain_flags, is_analyze);
|
||||
DBUG_ASSERT(0);
|
||||
}
|
||||
insert_plan->print_explain_json(this, &writer, is_analyze);
|
||||
else
|
||||
{
|
||||
/* Start printing from node with id=1 */
|
||||
@ -1808,6 +1805,20 @@ int Explain_insert::print_explain(Explain_query *query,
|
||||
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)
|
||||
{
|
||||
|
@ -704,8 +704,7 @@ public:
|
||||
int print_explain(Explain_query *query, select_result_sink *output,
|
||||
uint8 explain_flags, bool is_analyze);
|
||||
void print_explain_json(Explain_query *query, Json_writer *writer,
|
||||
bool is_analyze)
|
||||
{ /* EXPLAIN_JSON_NOT_IMPL */}
|
||||
bool is_analyze);
|
||||
};
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user