Commit 7e919c52 authored by Sergey Petrunya's avatar Sergey Petrunya

MDEV-3798: EXPLAIN UPDATE/DELETE

- Produce correct `key_len` when type=index.
parent 3c6ac669
...@@ -21,7 +21,7 @@ from t0 A, t0 B, t0 C; ...@@ -21,7 +21,7 @@ from t0 A, t0 B, t0 C;
# This should use an index, possible_keys=NULL because there is no WHERE # This should use an index, possible_keys=NULL because there is no WHERE
explain delete from t1 order by a limit 2; explain delete from t1 order by a limit 2;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL a NULL NULL 2 1 SIMPLE t1 index NULL a 5 NULL 2
# This should use range, possible_keys={a,b} # This should use range, possible_keys={a,b}
explain delete from t1 where a<20 and b < 10; explain delete from t1 where a<20 and b < 10;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
......
...@@ -158,8 +158,11 @@ void Update_plan::save_explain_data_intern(Explain_query *query, ...@@ -158,8 +158,11 @@ void Update_plan::save_explain_data_intern(Explain_query *query,
if (index != MAX_KEY) if (index != MAX_KEY)
{ {
explain->key_str.append(table->key_info[index].name); explain->key_str.append(table->key_info[index].name);
char buf[64];
size_t length;
length= longlong10_to_str(table->key_info[index].key_length, buf, 10) - buf;
explain->key_len_str.append(buf, length);
} }
// key_len stays NULL
} }
explain->rows= scanned_rows; explain->rows= scanned_rows;
......
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