Commit 8346a498 authored by Sergey Petrunya's avatar Sergey Petrunya

MDEV-3798: EXPLAIN UPDATE/DELETE

- Run probes like MYSQL_INSERT_SELECT_START or 
  MYSQL_MULTI_DELETE_START for EXPLAIN, too.
  We should run them, because 1. EXPLAIN SELECT does it, and 
  2. MySQL also does it.
parent 062b7bfa
...@@ -2553,16 +2553,16 @@ enum_nested_loop_state JOIN_CACHE::join_null_complements(bool skip_last) ...@@ -2553,16 +2553,16 @@ enum_nested_loop_state JOIN_CACHE::join_null_complements(bool skip_last)
/* /*
Add a comment on the join algorithm employed by the join cache Save data on the join algorithm employed by the join cache
SYNOPSIS SYNOPSIS
print_explain_comment() save_explain_data()
str string to add the comment on the employed join algorithm to str string to add the comment on the employed join algorithm to
DESCRIPTION DESCRIPTION
This function adds info on the type of the used join buffer (flat or This function puts info about the type of the used join buffer (flat or
incremental) and on the type of the the employed join algorithm (BNL, incremental) and on the type of the the employed join algorithm (BNL,
BNLH, BKA or BKAH) to the the end of the sring str. BNLH, BKA or BKAH) to the data structure
RETURN VALUE RETURN VALUE
none none
......
...@@ -3205,11 +3205,8 @@ case SQLCOM_PREPARE: ...@@ -3205,11 +3205,8 @@ case SQLCOM_PREPARE:
unit->set_limit(select_lex); unit->set_limit(select_lex);
if (!(res= open_and_lock_tables(thd, all_tables, TRUE, 0))) if (!(res= open_and_lock_tables(thd, all_tables, TRUE, 0)))
{
if (!explain)
{ {
MYSQL_INSERT_SELECT_START(thd->query()); MYSQL_INSERT_SELECT_START(thd->query());
}
/* /*
Only the INSERT table should be merged. Other will be handled by Only the INSERT table should be merged. Other will be handled by
select. select.
...@@ -3258,10 +3255,7 @@ case SQLCOM_PREPARE: ...@@ -3258,10 +3255,7 @@ case SQLCOM_PREPARE:
} }
/* revert changes for SP */ /* revert changes for SP */
if (!explain)
{
MYSQL_INSERT_SELECT_DONE(res, (ulong) thd->get_row_count_func()); MYSQL_INSERT_SELECT_DONE(res, (ulong) thd->get_row_count_func());
}
select_lex->table_list.first= first_table; select_lex->table_list.first= first_table;
} }
/* /*
...@@ -3316,17 +3310,10 @@ case SQLCOM_PREPARE: ...@@ -3316,17 +3310,10 @@ case SQLCOM_PREPARE:
if ((res= open_and_lock_tables(thd, all_tables, TRUE, 0))) if ((res= open_and_lock_tables(thd, all_tables, TRUE, 0)))
break; break;
if (!explain)
{
MYSQL_MULTI_DELETE_START(thd->query()); MYSQL_MULTI_DELETE_START(thd->query());
}
if ((res= mysql_multi_delete_prepare(thd))) if ((res= mysql_multi_delete_prepare(thd)))
{
if (!explain)
{ {
MYSQL_MULTI_DELETE_DONE(1, 0); MYSQL_MULTI_DELETE_DONE(1, 0);
}
goto error; goto error;
} }
...@@ -3348,15 +3335,12 @@ case SQLCOM_PREPARE: ...@@ -3348,15 +3335,12 @@ case SQLCOM_PREPARE:
result, unit, select_lex); result, unit, select_lex);
res|= thd->is_error(); res|= thd->is_error();
if (!explain)
{
MYSQL_MULTI_DELETE_DONE(res, del_result->num_deleted()); MYSQL_MULTI_DELETE_DONE(res, del_result->num_deleted());
if (res) if (res)
result->abort_result_set(); /* for both DELETE and EXPLAIN DELETE */ result->abort_result_set(); /* for both DELETE and EXPLAIN DELETE */
}
else else
{ {
if (!res) if (explain)
{ {
select_result *result= new select_send(); select_result *result= new select_send();
LEX *lex= thd->lex; LEX *lex= thd->lex;
...@@ -3365,8 +3349,6 @@ case SQLCOM_PREPARE: ...@@ -3365,8 +3349,6 @@ case SQLCOM_PREPARE:
result->send_eof()) result->send_eof())
res= 1; res= 1;
} }
else
result->abort_result_set(); /* for both DELETE and EXPLAIN DELETE */
} }
delete result; delete result;
} }
...@@ -3374,11 +3356,8 @@ case SQLCOM_PREPARE: ...@@ -3374,11 +3356,8 @@ case SQLCOM_PREPARE:
else else
{ {
res= TRUE; // Error res= TRUE; // Error
if (!explain)
{
MYSQL_MULTI_DELETE_DONE(1, 0); MYSQL_MULTI_DELETE_DONE(1, 0);
} }
}
break; break;
} }
case SQLCOM_DROP_TABLE: case SQLCOM_DROP_TABLE:
......
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