diff options
author | Alexey Botchkov <holyfoot@askmonty.org> | 2020-07-28 02:51:48 +0400 |
---|---|---|
committer | Alexey Botchkov <holyfoot@askmonty.org> | 2020-07-28 02:51:48 +0400 |
commit | 077d1c837ba10931f21a718dcfeb7bdc0cc073b2 (patch) | |
tree | 3c26fe777813e5d0c129f6ea243bf7f1006f33da | |
parent | e0c0a15ee9e45ef17283b3a65ed4647b1477622a (diff) | |
download | mariadb-git-bb-mdev-17399-hf.tar.gz |
MDEV-17399 Add support for JSON_TABLE.bb-mdev-17399-hf
EXPLAIN and EXPLAIN FORMAT=JSON added for the JSON_TABLE.
-rw-r--r-- | mysql-test/suite/json/r/json_table.result | 19 | ||||
-rw-r--r-- | mysql-test/suite/json/t/json_table.test | 5 | ||||
-rw-r--r-- | sql/mysqld.cc | 1 | ||||
-rw-r--r-- | sql/sql_explain.cc | 6 | ||||
-rw-r--r-- | sql/sql_explain.h | 1 | ||||
-rw-r--r-- | sql/sql_select.cc | 3 |
6 files changed, 34 insertions, 1 deletions
diff --git a/mysql-test/suite/json/r/json_table.result b/mysql-test/suite/json/r/json_table.result index c5cd0998133..de80649a9ff 100644 --- a/mysql-test/suite/json/r/json_table.result +++ b/mysql-test/suite/json/r/json_table.result @@ -215,6 +215,25 @@ select * from v2; color blue drop view v2; +explain format=json select * from +json_table('[{"a": 1, "b": [11,111]}, {"a": 2, "b": [22,222]}]', '$[*]' COLUMNS( a INT PATH '$.a')) as tt; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "table_name": "tt", + "access_type": "ALL", + "rows": 40, + "filtered": 100, + "table_function": "json_table" + } + } +} +explain select * from +json_table('[{"a": 1, "b": [11,111]}, {"a": 2, "b": [22,222]}]', '$[*]' COLUMNS( a INT PATH '$.a')) as tt; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE tt ALL NULL NULL NULL NULL 40 Table function: json_table # # End of 10.5 tests # diff --git a/mysql-test/suite/json/t/json_table.test b/mysql-test/suite/json/t/json_table.test index b57127299fb..5861c9fc2e6 100644 --- a/mysql-test/suite/json/t/json_table.test +++ b/mysql-test/suite/json/t/json_table.test @@ -162,6 +162,11 @@ create view v2 as select * from json_table('[{"co\\\\lor": "blue", "price": 50 select * from v2; drop view v2; +explain format=json select * from + json_table('[{"a": 1, "b": [11,111]}, {"a": 2, "b": [22,222]}]', '$[*]' COLUMNS( a INT PATH '$.a')) as tt; +explain select * from + json_table('[{"a": 1, "b": [11,111]}, {"a": 2, "b": [22,222]}]', '$[*]' COLUMNS( a INT PATH '$.a')) as tt; + --echo # --echo # End of 10.5 tests --echo # diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 936c6871b6e..ebac83bc00d 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -4,7 +4,6 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. - test This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/sql/sql_explain.cc b/sql/sql_explain.cc index 353217982e2..c4d1ae6f70a 100644 --- a/sql/sql_explain.cc +++ b/sql/sql_explain.cc @@ -1635,6 +1635,9 @@ void Explain_table_access::tag_to_json(Json_writer *writer, enum explain_extra_t case ET_DISTINCT: writer->add_member("distinct").add_bool(true); break; + case ET_TABLE_FUNCTION: + writer->add_member("table_function").add_str("json_table"); + break; default: DBUG_ASSERT(0); @@ -2028,6 +2031,9 @@ void Explain_table_access::append_tag_name(String *str, enum explain_extra_tag t str->append(" (scanning)"); break; } + case ET_TABLE_FUNCTION: + str->append("Table function: json_table"); + break; default: str->append(extra_tag_text[tag]); } diff --git a/sql/sql_explain.h b/sql/sql_explain.h index 9090416847f..6587f0e4178 100644 --- a/sql/sql_explain.h +++ b/sql/sql_explain.h @@ -550,6 +550,7 @@ enum explain_extra_tag ET_CONST_ROW_NOT_FOUND, ET_UNIQUE_ROW_NOT_FOUND, ET_IMPOSSIBLE_ON_CONDITION, + ET_TABLE_FUNCTION, ET_total }; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 7c8290d2b9f..bae1ab65f47 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -26694,6 +26694,9 @@ bool JOIN_TAB::save_explain_data(Explain_table_access *eta, !((QUICK_ROR_INTERSECT_SELECT*)cur_quick)->need_to_fetch_row) key_read=1; + if (table_list->table_function) + eta->push_extra(ET_TABLE_FUNCTION); + if (info) { eta->push_extra(info); |