Commit eeb67132 authored by Sergey Petrunya's avatar Sergey Petrunya

[SHOW] EXPLAIN UPDATE/DELETE

- Post-merge fixes (conflict with DELETE .. RETURNING)
- Add a testcase with EXPLAIN ... DELETE ... RETURNING
parent d2d9eb65
...@@ -84,3 +84,14 @@ explain update t0, t1 set t1.a=t1.a+1 where t0.a = t1.a; ...@@ -84,3 +84,14 @@ explain update t0, t1 set t1.a=t1.a+1 where t0.a = t1.a;
drop table t0, t1; drop table t0, t1;
--echo #
--echo # Try DELETE ... RETURNING ...
--echo #
create table t0 (a int);
insert into t0 values (1),(2),(3),(4);
explain delete from t0 where a=1 returning a;
explain delete from t0 returning a;
drop table t0;
...@@ -658,18 +658,18 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, ...@@ -658,18 +658,18 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
exit_without_my_ok: exit_without_my_ok:
query_plan.save_query_plan_footprint(thd->lex->query_plan_footprint); query_plan.save_query_plan_footprint(thd->lex->query_plan_footprint);
select_send *result; select_send *result2;
if (!(result= new select_send())) if (!(result2= new select_send()))
return 1; /* purecov: inspected */ return 1; /* purecov: inspected */
List<Item> dummy; /* note: looked in 5.6 and they too use a dummy list like this */ List<Item> dummy; /* note: looked in 5.6 and they too use a dummy list like this */
result->prepare(dummy, &thd->lex->unit); result2->prepare(dummy, &thd->lex->unit);
thd->send_explain_fields(result); thd->send_explain_fields(result2);
int err2= thd->lex->query_plan_footprint->print_explain(result, 0 /* explain flags*/); int err2= thd->lex->query_plan_footprint->print_explain(result2, 0 /* explain flags*/);
if (err2) if (err2)
result->abort_result_set(); result2->abort_result_set();
else else
result->send_eof(); result2->send_eof();
delete select; delete select;
free_underlaid_joins(thd, select_lex); free_underlaid_joins(thd, select_lex);
......
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