summaryrefslogtreecommitdiff
path: root/sql/sql_explain.cc
diff options
context:
space:
mode:
authorSergey Petrunya <psergey@askmonty.org>2013-10-09 09:40:33 +0400
committerSergey Petrunya <psergey@askmonty.org>2013-10-09 09:40:33 +0400
commit161d68759433b0315a6b95209d3db86be411a686 (patch)
tree8d7123f8b473ae696bf3bf89bf5191afcad986f8 /sql/sql_explain.cc
parent69e6a2bb22434d94d96312ba8a0540195273dfdd (diff)
downloadmariadb-git-161d68759433b0315a6b95209d3db86be411a686.tar.gz
MDEV-3798: EXPLAIN UPDATE/DELETE
- Generate correct contents of `Extra` column for UPDATEs/DELETEs that use quick selects - UPDATEs with used_key_is_modified=true will show "Using buffer"
Diffstat (limited to 'sql/sql_explain.cc')
-rw-r--r--sql/sql_explain.cc42
1 files changed, 38 insertions, 4 deletions
diff --git a/sql/sql_explain.cc b/sql/sql_explain.cc
index a8afc0ac6d3..91a73cfb7d3 100644
--- a/sql/sql_explain.cc
+++ b/sql/sql_explain.cc
@@ -793,6 +793,8 @@ int Explain_update::print_explain(Explain_query *query,
select_result_sink *output,
uint8 explain_flags)
{
+ StringBuffer<64> key_buf;
+ StringBuffer<64> key_len_buf;
StringBuffer<64> extra_str;
if (impossible_where || no_partitions)
{
@@ -807,8 +809,32 @@ int Explain_update::print_explain(Explain_query *query,
return res;
}
+
+ if (quick_info)
+ {
+ quick_info->print_key(&key_buf);
+ quick_info->print_key_len(&key_len_buf);
+
+ StringBuffer<64> quick_buf;
+ quick_info->print_extra(&quick_buf);
+ if (quick_buf.length())
+ {
+ extra_str.append(STRING_WITH_LEN("Using "));
+ extra_str.append(quick_buf);
+ }
+ }
+ else
+ {
+ key_buf.copy(key_str);
+ key_len_buf.copy(key_len_str);
+ }
+
if (using_where)
+ {
+ if (extra_str.length() !=0)
+ extra_str.append(STRING_WITH_LEN("; "));
extra_str.append(STRING_WITH_LEN("Using where"));
+ }
if (mrr_type.length() != 0)
{
@@ -816,7 +842,7 @@ int Explain_update::print_explain(Explain_query *query,
extra_str.append(STRING_WITH_LEN("; "));
extra_str.append(mrr_type);
}
-
+
if (using_filesort)
{
if (extra_str.length() !=0)
@@ -824,6 +850,13 @@ int Explain_update::print_explain(Explain_query *query,
extra_str.append(STRING_WITH_LEN("Using filesort"));
}
+ if (using_io_buffer)
+ {
+ if (extra_str.length() !=0)
+ extra_str.append(STRING_WITH_LEN("; "));
+ extra_str.append(STRING_WITH_LEN("Using buffer"));
+ }
+
/*
Single-table DELETE commands do not do "Using temporary".
"Using index condition" is also not possible (which is an unjustified limitation)
@@ -836,8 +869,8 @@ int Explain_update::print_explain(Explain_query *query,
used_partitions_set? used_partitions.c_ptr() : NULL,
jtype,
possible_keys_line.length()? possible_keys_line.c_ptr(): NULL,
- key_str.length()? key_str.c_ptr() : NULL,
- key_len_str.length() ? key_len_str.c_ptr() : NULL,
+ key_buf.length()? key_buf.c_ptr() : NULL,
+ key_len_buf.length() ? key_len_buf.c_ptr() : NULL,
NULL, /* 'ref' is always NULL in single-table EXPLAIN DELETE */
&rows,
extra_str.c_ptr());
@@ -846,7 +879,8 @@ int Explain_update::print_explain(Explain_query *query,
}
-int Explain_insert::print_explain(Explain_query *query, select_result_sink *output,
+int Explain_insert::print_explain(Explain_query *query,
+ select_result_sink *output,
uint8 explain_flags)
{
const char *select_type="INSERT";