diff options
author | Sergei Petrunia <psergey@askmonty.org> | 2020-05-06 23:44:34 +0300 |
---|---|---|
committer | Sergei Petrunia <psergey@askmonty.org> | 2020-05-06 23:44:34 +0300 |
commit | d01d94d77bbb663caca2f34f4b25d5db028f4c4d (patch) | |
tree | 18f1238255918309568e088d9017c5eda0ceab79 | |
parent | 8648b9bed86e9f52c027daec760d6ab5ce52e889 (diff) | |
download | mariadb-git-d01d94d77bbb663caca2f34f4b25d5db028f4c4d.tar.gz |
MDEV-17568: LATERAL DERIVED is not clearly visible in EXPLAIN FORMAT=JSON
Make LATERAL DERIVED tables visible in EXPLAIN FORMAT=JSON output.
-rw-r--r-- | mysql-test/main/derived_cond_pushdown.result | 8 | ||||
-rw-r--r-- | sql/sql_explain.cc | 5 | ||||
-rw-r--r-- | sql/sql_explain.h | 2 | ||||
-rw-r--r-- | sql/sql_select.cc | 2 |
4 files changed, 17 insertions, 0 deletions
diff --git a/mysql-test/main/derived_cond_pushdown.result b/mysql-test/main/derived_cond_pushdown.result index bd632e39dfc..542397755dc 100644 --- a/mysql-test/main/derived_cond_pushdown.result +++ b/mysql-test/main/derived_cond_pushdown.result @@ -15115,6 +15115,7 @@ EXPLAIN "rows": 2, "filtered": 100, "materialized": { + "lateral": 1, "query_block": { "select_id": 2, "outer_ref_condition": "t1.a is not null", @@ -15324,6 +15325,7 @@ EXPLAIN "filtered": 100, "attached_condition": "trigcond(trigcond(t1.a is not null))", "materialized": { + "lateral": 1, "query_block": { "select_id": 2, "outer_ref_condition": "t1.a is not null", @@ -15418,6 +15420,7 @@ EXPLAIN "rows": 2, "filtered": 100, "materialized": { + "lateral": 1, "query_block": { "select_id": 2, "outer_ref_condition": "t3.a is not null and t3.c is not null", @@ -15570,6 +15573,7 @@ EXPLAIN "rows": 2, "filtered": 100, "materialized": { + "lateral": 1, "query_block": { "select_id": 2, "outer_ref_condition": "t3.a is not null and t3.c is not null", @@ -15742,6 +15746,7 @@ EXPLAIN "rows": 2, "filtered": 100, "materialized": { + "lateral": 1, "query_block": { "select_id": 2, "outer_ref_condition": "t3.c is not null", @@ -15989,6 +15994,7 @@ EXPLAIN "rows": 2, "filtered": 100, "materialized": { + "lateral": 1, "query_block": { "select_id": 2, "outer_ref_condition": "t3.c is not null", @@ -16473,6 +16479,7 @@ EXPLAIN "filtered": 100, "first_match": "t4", "materialized": { + "lateral": 1, "query_block": { "select_id": 3, "const_condition": "1", @@ -16619,6 +16626,7 @@ EXPLAIN "rows": 2, "filtered": 100, "materialized": { + "lateral": 1, "query_block": { "select_id": 2, "table": { diff --git a/sql/sql_explain.cc b/sql/sql_explain.cc index 70b177a556d..95ff94273b4 100644 --- a/sql/sql_explain.cc +++ b/sql/sql_explain.cc @@ -1756,6 +1756,11 @@ void Explain_table_access::print_explain_json(Explain_query *query, /* This is a derived table. Print its contents here */ writer->add_member("materialized").start_object(); Explain_node *node= query->get_node(derived_select_number); + if (node->get_type() == Explain_node::EXPLAIN_SELECT && + ((Explain_select*)node)->is_lateral) + { + writer->add_member("lateral").add_ll(1); + } node->print_explain_json(query, writer, is_analyze); writer->end_object(); } diff --git a/sql/sql_explain.h b/sql/sql_explain.h index 7a814dfa3af..97fe07572cf 100644 --- a/sql/sql_explain.h +++ b/sql/sql_explain.h @@ -211,6 +211,7 @@ public: select_lex(NULL), #endif linkage(UNSPECIFIED_TYPE), + is_lateral(false), message(NULL), having(NULL), having_value(Item::COND_UNDEF), using_temporary(false), using_filesort(false), @@ -226,6 +227,7 @@ public: #endif const char *select_type; enum sub_select_type linkage; + bool is_lateral; /* If message != NULL, this is a degenerate join plan, and all subsequent diff --git a/sql/sql_select.cc b/sql/sql_select.cc index de66f8bc59e..dd12ef0aa17 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -26014,6 +26014,8 @@ int JOIN::save_explain_data_intern(Explain_query *output, xpl_sel->select_id= join->select_lex->select_number; xpl_sel->select_type= join->select_lex->type; xpl_sel->linkage= select_lex->linkage; + xpl_sel->is_lateral= ((select_lex->linkage == DERIVED_TABLE_TYPE) && + (select_lex->uncacheable & UNCACHEABLE_DEPENDENT)); if (select_lex->master_unit()->derived) xpl_sel->connection_type= Explain_node::EXPLAIN_NODE_DERIVED; |