Commit fda46df6 authored by Sergey Petrunya's avatar Sergey Petrunya

MDEV-3798: EXPLAIN UPDATE/DELETE

- if EXPLAIN DELETE prints "Deleting all rows", it should show the 
  expected number of rows in the rows column.
parent 98a8642f
...@@ -59,6 +59,7 @@ void Delete_plan::save_explain_data(Explain_query *query) ...@@ -59,6 +59,7 @@ void Delete_plan::save_explain_data(Explain_query *query)
{ {
explain->deleting_all_rows= true; explain->deleting_all_rows= true;
explain->select_type= "SIMPLE"; explain->select_type= "SIMPLE";
explain->rows= table_rows;
} }
else else
{ {
......
...@@ -778,7 +778,7 @@ int Explain_delete::print_explain(Explain_query *query, ...@@ -778,7 +778,7 @@ int Explain_delete::print_explain(Explain_query *query,
const char *msg= "Deleting all rows"; const char *msg= "Deleting all rows";
int res= print_explain_message_line(output, explain_flags, int res= print_explain_message_line(output, explain_flags,
1 /*select number*/, 1 /*select number*/,
select_type, msg); select_type, &rows, msg);
return res; return res;
} }
...@@ -797,11 +797,13 @@ int Explain_update::print_explain(Explain_query *query, ...@@ -797,11 +797,13 @@ int Explain_update::print_explain(Explain_query *query,
if (impossible_where || no_partitions) if (impossible_where || no_partitions)
{ {
const char *msg= impossible_where ? const char *msg= impossible_where ?
"Impossible where" : "Impossible WHERE" :
"No matching rows after partition pruning"; "No matching rows after partition pruning";
int res= print_explain_message_line(output, explain_flags, int res= print_explain_message_line(output, explain_flags,
1 /*select number*/, 1 /*select number*/,
select_type, msg); select_type,
NULL, /* rows */
msg);
return res; return res;
} }
......
...@@ -22222,6 +22222,7 @@ int print_explain_message_line(select_result_sink *result, ...@@ -22222,6 +22222,7 @@ int print_explain_message_line(select_result_sink *result,
uint8 options, uint8 options,
uint select_number, uint select_number,
const char *select_type, const char *select_type,
ha_rows *rows,
const char *message) const char *message)
{ {
const CHARSET_INFO *cs= system_charset_info; const CHARSET_INFO *cs= system_charset_info;
...@@ -22231,13 +22232,31 @@ int print_explain_message_line(select_result_sink *result, ...@@ -22231,13 +22232,31 @@ int print_explain_message_line(select_result_sink *result,
item_list.push_back(new Item_int((int32) select_number)); item_list.push_back(new Item_int((int32) select_number));
item_list.push_back(new Item_string(select_type, item_list.push_back(new Item_string(select_type,
strlen(select_type), cs)); strlen(select_type), cs));
for (uint i=0 ; i < 7; i++) /* `table` */
item_list.push_back(item_null); item_list.push_back(item_null);
/* `partitions` */
if (options & DESCRIBE_PARTITIONS) if (options & DESCRIBE_PARTITIONS)
item_list.push_back(item_null); item_list.push_back(item_null);
/* type, possible_keys, key, key_len, ref */
for (uint i=0 ; i < 5; i++)
item_list.push_back(item_null);
/* `rows` */
if (rows)
{
item_list.push_back(new Item_int(*rows,
MY_INT64_NUM_DECIMAL_DIGITS));
}
else
item_list.push_back(item_null);
/* `filtered` */
if (options & DESCRIBE_EXTENDED) if (options & DESCRIBE_EXTENDED)
item_list.push_back(item_null); item_list.push_back(item_null);
/* `Extra` */
if (message) if (message)
item_list.push_back(new Item_string(message,strlen(message),cs)); item_list.push_back(new Item_string(message,strlen(message),cs));
else else
......
...@@ -1852,6 +1852,7 @@ int print_explain_message_line(select_result_sink *result, ...@@ -1852,6 +1852,7 @@ int print_explain_message_line(select_result_sink *result,
uint8 options, uint8 options,
uint select_number, uint select_number,
const char *select_type, const char *select_type,
ha_rows *rows,
const char *message); const char *message);
void explain_append_mrr_info(QUICK_RANGE_SELECT *quick, String *res); void explain_append_mrr_info(QUICK_RANGE_SELECT *quick, String *res);
int print_explain_row(select_result_sink *result, int print_explain_row(select_result_sink *result,
......
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