Commit d01d94d7 authored by Sergei Petrunia's avatar Sergei Petrunia

MDEV-17568: LATERAL DERIVED is not clearly visible in EXPLAIN FORMAT=JSON

Make LATERAL DERIVED tables visible in EXPLAIN FORMAT=JSON output.
parent 8648b9be
......@@ -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": {
......
......@@ -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();
}
......
......@@ -211,6 +211,7 @@ class Explain_select : public Explain_basic_join
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 @@ class Explain_select : public Explain_basic_join
#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
......
......@@ -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;
......
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