MDEV-3798: EXPLAIN UPDATE/DELETE

- Produce correct `key_len` when type=index.
This commit is contained in:
Sergey Petrunya 2013-10-09 17:15:34 +04:00
parent 3c6ac6694d
commit 7e919c52a5
2 changed files with 5 additions and 2 deletions

View File

@ -21,7 +21,7 @@ from t0 A, t0 B, t0 C;
# This should use an index, possible_keys=NULL because there is no WHERE
explain delete from t1 order by a limit 2;
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}
explain delete from t1 where a<20 and b < 10;
id select_type table type possible_keys key key_len ref rows Extra

View File

@ -158,8 +158,11 @@ void Update_plan::save_explain_data_intern(Explain_query *query,
if (index != MAX_KEY)
{
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;