summaryrefslogtreecommitdiff
path: root/sql/sql_parse.cc
diff options
context:
space:
mode:
authorSergei Petrunia <psergey@askmonty.org>2014-08-09 01:52:54 +0400
committerSergei Petrunia <psergey@askmonty.org>2014-08-09 01:52:54 +0400
commit83f0ddc6294ea8d4e424a540a043bf88ee4a8c8d (patch)
tree04280aba1544710aac2a6971a8d86a41c11cbecc /sql/sql_parse.cc
parentd87ffeb49133aa459e134f09924cd7b7b5013632 (diff)
parent5cfd3270ec79238b27765af3062ae7d97f6f06d0 (diff)
downloadmariadb-git-83f0ddc6294ea8d4e424a540a043bf88ee4a8c8d.tar.gz
Merge 10.1 (with ANALYZE) and 10.1-explain-json
Diffstat (limited to 'sql/sql_parse.cc')
-rw-r--r--sql/sql_parse.cc42
1 files changed, 32 insertions, 10 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 019fd55e3d8..ab2ef71d22b 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -97,6 +97,8 @@
#include "log_slow.h"
#include "sql_bootstrap.h"
+#include "my_json_writer.h"
+
#define FLAGSTR(V,F) ((V)&(F)?#F" ":"")
#ifdef WITH_ARIA_STORAGE_ENGINE
@@ -5267,19 +5269,39 @@ static bool execute_sqlcom_select(THD *thd, TABLE_LIST *all_tables)
top-level LIMIT
*/
result->reset_offset_limit();
- lex->explain->print_explain(result, lex->describe, lex->analyze_stmt);
- if (lex->describe & DESCRIBE_EXTENDED)
+ if (thd->lex->explain_json)
{
- char buff[1024];
- String str(buff,(uint32) sizeof(buff), system_charset_info);
- str.length(0);
/*
- The warnings system requires input in utf8, @see
- mysqld_show_warnings().
+ Json_writer writer;
+ writer.start_object();
+ thd->lex->explain->print_explain_json(&writer, thd->lex->analyze_stmt);
+ writer.end_object();
+
+ const CHARSET_INFO *cs= system_charset_info;
+ List<Item> item_list;
+ String *buf= &writer.output;
+ item_list.push_back(new Item_string(buf->ptr(), buf->length(), cs));
+ result->send_data(item_list);
*/
- lex->unit.print(&str, QT_TO_SYSTEM_CHARSET);
- push_warning(thd, Sql_condition::WARN_LEVEL_NOTE,
- ER_YES, str.c_ptr_safe());
+ thd->lex->explain->print_explain_json(result, thd->lex->analyze_stmt);
+ }
+ else
+ {
+ lex->explain->print_explain(result, thd->lex->describe,
+ thd->lex->analyze_stmt);
+ if (lex->describe & DESCRIBE_EXTENDED)
+ {
+ char buff[1024];
+ String str(buff,(uint32) sizeof(buff), system_charset_info);
+ str.length(0);
+ /*
+ The warnings system requires input in utf8, @see
+ mysqld_show_warnings().
+ */
+ lex->unit.print(&str, QT_TO_SYSTEM_CHARSET);
+ push_warning(thd, Sql_condition::WARN_LEVEL_NOTE,
+ ER_YES, str.c_ptr_safe());
+ }
}
}