Commit d1a1ad4c authored by Oleg Smirnov's avatar Oleg Smirnov Committed by Sergei Petrunia

MDEV-27021 Add support of FORMAT=JSON for SHOW ANALYZE

parent e7fcd496
This diff is collapsed.
This diff is collapsed.
...@@ -26,17 +26,17 @@ connection con1; ...@@ -26,17 +26,17 @@ connection con1;
SET @old_debug= @@session.debug; SET @old_debug= @@session.debug;
connection default; connection default;
show explain format=JSON for $thr2; show explain format=JSON for $thr2;
ERROR HY000: Target is not running an EXPLAINable command ERROR HY000: Target is not executing an operation with a query plan
explain format=json for connection $thr2; explain format=json for connection $thr2;
ERROR HY000: Target is not running an EXPLAINable command ERROR HY000: Target is not executing an operation with a query plan
show explain format=json for $thr1; show explain format=json for $thr1;
ERROR HY000: Target is not running an EXPLAINable command ERROR HY000: Target is not executing an operation with a query plan
explain FORMAT=JSON for connection $thr1; explain FORMAT=JSON for connection $thr1;
ERROR HY000: Target is not running an EXPLAINable command ERROR HY000: Target is not executing an operation with a query plan
show explain FORMAT=HTML for $thr1; show explain FORMAT=HTML for $thr1;
ERROR HY000: Unknown EXPLAIN format name: 'HTML' ERROR HY000: Unknown EXPLAIN/ANALYZE format name: 'HTML'
explain FORMAT=XML for connection $thr1; explain FORMAT=XML for connection $thr1;
ERROR HY000: Unknown EXPLAIN format name: 'XML' ERROR HY000: Unknown EXPLAIN/ANALYZE format name: 'XML'
connection con1; connection con1;
set @show_explain_probe_select_id=1; set @show_explain_probe_select_id=1;
SET debug_dbug='+d,show_explain_probe_join_exec_start'; SET debug_dbug='+d,show_explain_probe_join_exec_start';
...@@ -523,7 +523,7 @@ SET debug_dbug='+d,show_explain_probe_join_exec_start'; ...@@ -523,7 +523,7 @@ SET debug_dbug='+d,show_explain_probe_join_exec_start';
set @foo= (select max(a) from t0 where sin(a) >0); set @foo= (select max(a) from t0 where sin(a) >0);
connection default; connection default;
show explain format=JSON for $thr2; show explain format=JSON for $thr2;
ERROR HY000: Target is not running an EXPLAINable command ERROR HY000: Target is not executing an operation with a query plan
kill query $thr2; kill query $thr2;
connection con1; connection con1;
ERROR 70100: Query execution was interrupted ERROR 70100: Query execution was interrupted
......
...@@ -1025,7 +1025,8 @@ enum enum_schema_tables ...@@ -1025,7 +1025,8 @@ enum enum_schema_tables
SCH_EVENTS, SCH_EVENTS,
SCH_EXPLAIN_TABULAR, SCH_EXPLAIN_TABULAR,
SCH_EXPLAIN_JSON, SCH_EXPLAIN_JSON,
SCH_ANALYZE, SCH_ANALYZE_TABULAR,
SCH_ANALYZE_JSON,
SCH_FILES, SCH_FILES,
SCH_GLOBAL_STATUS, SCH_GLOBAL_STATUS,
SCH_GLOBAL_VARIABLES, SCH_GLOBAL_VARIABLES,
......
...@@ -3242,13 +3242,14 @@ int fill_show_explain_tabular(THD *thd, TABLE_LIST *table, COND *cond) ...@@ -3242,13 +3242,14 @@ int fill_show_explain_tabular(THD *thd, TABLE_LIST *table, COND *cond)
int fill_show_explain_json(THD *thd, TABLE_LIST *table, COND *cond) int fill_show_explain_json(THD *thd, TABLE_LIST *table, COND *cond)
{ {
return fill_show_explain_or_analyze( return fill_show_explain_or_analyze(
thd, table, cond, TRUE /* json_format */, TRUE /* is_analyze */); thd, table, cond, TRUE /* json_format */, FALSE /* is_analyze */);
}
int fill_show_analyze_tabular(THD * thd, TABLE_LIST * table, COND * cond) int fill_show_analyze_tabular(THD * thd, TABLE_LIST * table, COND * cond)
{ {
return fill_show_explain_or_analyze( return fill_show_explain_or_analyze(
thd, table, cond, FALSE /* json_format */, TRUE /* is_analyze */); thd, table, cond, FALSE /* json_format */, TRUE /* is_analyze */);
} }
...@@ -9676,7 +9677,7 @@ ST_FIELD_INFO show_explain_json_fields_info[]= ...@@ -9676,7 +9677,7 @@ ST_FIELD_INFO show_explain_json_fields_info[]=
}; };
ST_FIELD_INFO show_analyze_fields_info[]= ST_FIELD_INFO show_analyze_tabular_fields_info[]=
{ {
Column("id", SLonglong(3), NULLABLE, "id"), Column("id", SLonglong(3), NULLABLE, "id"),
Column("select_type", Varchar(19), NOT_NULL, "select_type"), Column("select_type", Varchar(19), NOT_NULL, "select_type"),
...@@ -9699,6 +9700,11 @@ ST_FIELD_INFO show_analyze_fields_info[]= ...@@ -9699,6 +9700,11 @@ ST_FIELD_INFO show_analyze_fields_info[]=
}; };
ST_FIELD_INFO show_analyze_json_fields_info[]= {
Column("EXPLAIN", Longtext(MAX_FIELD_VARCHARLENGTH), NOT_NULL, "ANALYZE"),
CEnd()};
ST_FIELD_INFO check_constraints_fields_info[]= ST_FIELD_INFO check_constraints_fields_info[]=
{ {
Column("CONSTRAINT_CATALOG", Catalog(), NOT_NULL, OPEN_FULL_TABLE), Column("CONSTRAINT_CATALOG", Catalog(), NOT_NULL, OPEN_FULL_TABLE),
...@@ -9759,12 +9765,18 @@ ST_SCHEMA_TABLE schema_tables[]= ...@@ -9759,12 +9765,18 @@ ST_SCHEMA_TABLE schema_tables[]=
{"EVENTS", Show::events_fields_info, 0, {"EVENTS", Show::events_fields_info, 0,
0, make_old_format, 0, -1, -1, 0, 0}, 0, make_old_format, 0, -1, -1, 0, 0},
#endif #endif
{"EXPLAIN", Show::show_explain_tabular_fields_info, 0, fill_show_explain_tabular, {"EXPLAIN", Show::show_explain_tabular_fields_info, 0,
make_old_format, 0, -1, -1, TRUE /*hidden*/ , 0}, fill_show_explain_tabular, make_old_format, 0, -1, -1,
{"EXPLAIN_JSON", Show::show_explain_json_fields_info, 0, fill_show_explain_json, TRUE /*hidden*/ , 0},
make_old_format, 0, -1, -1, TRUE /*hidden*/, 0}, {"EXPLAIN_JSON", Show::show_explain_json_fields_info, 0,
{"ANALYZE", Show::show_analyze_fields_info, 0, fill_show_analyze_tabular, fill_show_explain_json, make_old_format, 0, -1, -1,
make_old_format, 0, -1, -1, TRUE /*hidden*/, 0}, TRUE /*hidden*/ , 0},
{"ANALYZE", Show::show_analyze_tabular_fields_info, 0,
fill_show_analyze_tabular, make_old_format, 0, -1, -1,
TRUE /*hidden*/, 0},
{"ANALYZE_JSON", Show::show_analyze_json_fields_info, 0,
fill_show_analyze_json, make_old_format, 0, -1, -1,
TRUE /*hidden*/, 0},
{"FILES", Show::files_fields_info, 0, {"FILES", Show::files_fields_info, 0,
hton_fill_schema_table, 0, 0, -1, -1, 0, 0}, hton_fill_schema_table, 0, 0, -1, -1, 0, 0},
{"GLOBAL_STATUS", Show::variables_fields_info, 0, {"GLOBAL_STATUS", Show::variables_fields_info, 0,
......
...@@ -13944,16 +13944,17 @@ show_param: ...@@ -13944,16 +13944,17 @@ show_param:
{ {
Lex->sql_command= SQLCOM_SHOW_EXPLAIN; Lex->sql_command= SQLCOM_SHOW_EXPLAIN;
if (unlikely(prepare_schema_table(thd, Lex, 0, if (unlikely(prepare_schema_table(thd, Lex, 0,
Lex->explain_json ? SCH_EXPLAIN_JSON : SCH_EXPLAIN_TABULAR))) Lex->explain_json ? SCH_EXPLAIN_JSON : SCH_EXPLAIN_TABULAR)))
MYSQL_YYABORT; MYSQL_YYABORT;
add_value_to_list(thd, $4); add_value_to_list(thd, $4);
} }
| ANALYZE_SYM FOR_SYM expr | ANALYZE_SYM opt_format_json FOR_SYM expr
{ {
Lex->sql_command= SQLCOM_SHOW_ANALYZE; Lex->sql_command= SQLCOM_SHOW_ANALYZE;
if (unlikely(prepare_schema_table(thd, Lex, 0, SCH_ANALYZE))) if (unlikely(prepare_schema_table(thd, Lex, 0,
Lex->explain_json ? SCH_ANALYZE_JSON : SCH_ANALYZE_TABULAR)))
MYSQL_YYABORT; MYSQL_YYABORT;
add_value_to_list(thd, $3); add_value_to_list(thd, $4);
} }
| IDENT_sys remember_tok_start wild_and_where | IDENT_sys remember_tok_start wild_and_where
{ {
...@@ -14107,8 +14108,8 @@ opt_format_json: ...@@ -14107,8 +14108,8 @@ opt_format_json:
else if (lex_string_eq(&$3, STRING_WITH_LEN("TRADITIONAL"))) else if (lex_string_eq(&$3, STRING_WITH_LEN("TRADITIONAL")))
DBUG_ASSERT(Lex->explain_json==false); DBUG_ASSERT(Lex->explain_json==false);
else else
my_yyabort_error((ER_UNKNOWN_EXPLAIN_FORMAT, MYF(0), "EXPLAIN", my_yyabort_error((ER_UNKNOWN_EXPLAIN_FORMAT, MYF(0),
$3.str)); "EXPLAIN/ANALYZE", $3.str));
} }
; ;
......
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