From 3c5ce8a0a32a74cd8e0ddc81bcfacf7c85f0d90a Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Fri, 21 Nov 2014 21:44:06 +0300 Subject: [PATCH] Make testsuite to pass - Drop all tables in explain_json.test - Tabular form should print ref='' when type='fulltext' (another peculiarity of the traditional EXPLAIN format) - String_list::append_str should allocate memory for \0, too - Some temporary code for EXPLAIN JSON and join buffering. --- mysql-test/r/explain_json.result | 2 +- mysql-test/t/explain_json.test | 2 +- sql/sql_explain.cc | 15 +++++++++++++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/explain_json.result b/mysql-test/r/explain_json.result index 2b2a4bf8fc9..7621332f226 100644 --- a/mysql-test/r/explain_json.result +++ b/mysql-test/r/explain_json.result @@ -174,5 +174,5 @@ EXPLAIN } } } -drop table t1; +drop table t1,t2; drop table t0; diff --git a/mysql-test/t/explain_json.test b/mysql-test/t/explain_json.test index 887ef66bff9..0b7bfb030d9 100644 --- a/mysql-test/t/explain_json.test +++ b/mysql-test/t/explain_json.test @@ -38,5 +38,5 @@ explain format=json select * from t2 where a1=1 or (b1=2 and b2=3); explain format=json select * from t0,t2 where t2.b1=t0.a and t2.b2=4; -drop table t1; +drop table t1,t2; drop table t0; diff --git a/sql/sql_explain.cc b/sql/sql_explain.cc index a468d16bbe4..e8bc907a9fb 100644 --- a/sql/sql_explain.cc +++ b/sql/sql_explain.cc @@ -721,7 +721,15 @@ int Explain_table_access::print_explain(select_result_sink *output, uint8 explai /* `ref` */ StringBuffer<64> ref_list_buf; if (ref_list.is_empty()) - item_list.push_back(item_null); + { + if (type == JT_FT) + { + /* Traditionally, EXPLAIN lines with type=fulltext have ref='' */ + push_str(&item_list, ""); + } + else + item_list.push_back(item_null); + } else push_string_list(&item_list, ref_list, &ref_list_buf); @@ -819,7 +827,7 @@ bool String_list::append_str(MEM_ROOT *mem_root, const char *str) { size_t len= strlen(str); char *cp; - if (!(cp = (char*)alloc_root(mem_root, len))) + if (!(cp = (char*)alloc_root(mem_root, len+1))) return 1; memcpy(cp, str, len+1); push_back(cp); @@ -880,6 +888,9 @@ void Explain_table_access::tag_to_json(Json_writer *writer, enum explain_extra_t case ET_USING: // index merge: case ET_USING break; + case ET_USING_JOIN_BUFFER: + // TODO TODO + break; default: DBUG_ASSERT(0); }