Skip to content

Commit

Permalink
MDEV-7834: ANALYZE FORMAT=JSON output column should be named ANALYZE
Browse files Browse the repository at this point in the history
  • Loading branch information
sanja-byelkin committed Mar 25, 2015
1 parent e15d792 commit 01d7da6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
14 changes: 7 additions & 7 deletions mysql-test/r/analyze_format_json.result
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ create table t0 (a int);
INSERT INTO t0 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
# r_filtered=30%, because 3 rows match: 0,1,2
analyze format=json select * from t0 where a<3;
EXPLAIN
ANALYZE
{
"query_block": {
"select_id": 1,
Expand Down Expand Up @@ -31,7 +31,7 @@ id select_type table type possible_keys key key_len ref rows r_rows filtered r_f
1 SIMPLE t1 ref a a 5 test.t0.a 1 NULL 100.00 NULL
analyze format=json
select * from t0, t1 where t1.a=t0.a and t0.a > 9;
EXPLAIN
ANALYZE
{
"query_block": {
"select_id": 1,
Expand Down Expand Up @@ -71,7 +71,7 @@ id select_type table type possible_keys key key_len ref rows r_rows filtered r_f
1 SIMPLE t1 ref a a 5 test.t0.a 1 1.00 100.00 40.00 Using where
analyze format=json
select * from t0, t1 where t1.a=t0.a and t1.b<4;
EXPLAIN
ANALYZE
{
"query_block": {
"select_id": 1,
Expand Down Expand Up @@ -113,7 +113,7 @@ id select_type table type possible_keys key key_len ref rows r_rows filtered r_f
1 SIMPLE tbl2 ALL NULL NULL NULL NULL 100 100.00 100.00 94.00 Using where; Using join buffer (flat, BNL join)
analyze format=json
select * from t1 tbl1, t1 tbl2 where tbl1.b<20 and tbl2.b<60;
EXPLAIN
ANALYZE
{
"query_block": {
"select_id": 1,
Expand Down Expand Up @@ -150,7 +150,7 @@ EXPLAIN
}
analyze format=json
select * from t1 tbl1, t1 tbl2 where tbl1.b<20 and tbl2.b<60 and tbl1.c > tbl2.c;
EXPLAIN
ANALYZE
{
"query_block": {
"select_id": 1,
Expand Down Expand Up @@ -196,7 +196,7 @@ insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
create table t2 (a int, key(a));
insert into t2 values (0),(1);
analyze format=json select * from t1 straight_join t2 force index(a) where t2.a=t1.a;
EXPLAIN
ANALYZE
{
"query_block": {
"select_id": 1,
Expand Down Expand Up @@ -244,7 +244,7 @@ select database();
database()
NULL
analyze format=json select * from test.t1 where t1.a<5;
EXPLAIN
ANALYZE
{
"query_block": {
"select_id": 1,
Expand Down
9 changes: 6 additions & 3 deletions sql/sql_class.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2464,7 +2464,7 @@ int THD::send_explain_fields(select_result *result, uint8 explain_flags, bool is
{
List<Item> field_list;
if (lex->explain_json)
make_explain_json_field_list(field_list);
make_explain_json_field_list(field_list, is_analyze);
else
make_explain_field_list(field_list, explain_flags, is_analyze);

Expand All @@ -2475,9 +2475,12 @@ int THD::send_explain_fields(select_result *result, uint8 explain_flags, bool is
}


void THD::make_explain_json_field_list(List<Item> &field_list)
void THD::make_explain_json_field_list(List<Item> &field_list, bool is_analyze)
{
Item *item= new Item_empty_string("EXPLAIN", 78, system_charset_info);
Item *item= new Item_empty_string((is_analyze ?
"ANALYZE" :
"EXPLAIN"),
78, system_charset_info);
field_list.push_back(item);
}

Expand Down
2 changes: 1 addition & 1 deletion sql/sql_class.h
Original file line number Diff line number Diff line change
Expand Up @@ -3171,7 +3171,7 @@ class THD :public Statement,
bool is_analyze);
void make_explain_field_list(List<Item> &field_list, uint8 explain_flags,
bool is_analyze);
void make_explain_json_field_list(List<Item> &field_list);
void make_explain_json_field_list(List<Item> &field_list, bool is_analyze);

/**
Clear the current error, if any.
Expand Down

0 comments on commit 01d7da6

Please sign in to comment.