1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

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

Make LATERAL DERIVED tables visible in EXPLAIN FORMAT=JSON output.
This commit is contained in:
Sergei Petrunia
2020-05-06 23:44:34 +03:00
parent 8648b9bed8
commit d01d94d77b
4 changed files with 17 additions and 0 deletions

View File

@ -15115,6 +15115,7 @@ EXPLAIN
"rows": 2, "rows": 2,
"filtered": 100, "filtered": 100,
"materialized": { "materialized": {
"lateral": 1,
"query_block": { "query_block": {
"select_id": 2, "select_id": 2,
"outer_ref_condition": "t1.a is not null", "outer_ref_condition": "t1.a is not null",
@ -15324,6 +15325,7 @@ EXPLAIN
"filtered": 100, "filtered": 100,
"attached_condition": "trigcond(trigcond(t1.a is not null))", "attached_condition": "trigcond(trigcond(t1.a is not null))",
"materialized": { "materialized": {
"lateral": 1,
"query_block": { "query_block": {
"select_id": 2, "select_id": 2,
"outer_ref_condition": "t1.a is not null", "outer_ref_condition": "t1.a is not null",
@ -15418,6 +15420,7 @@ EXPLAIN
"rows": 2, "rows": 2,
"filtered": 100, "filtered": 100,
"materialized": { "materialized": {
"lateral": 1,
"query_block": { "query_block": {
"select_id": 2, "select_id": 2,
"outer_ref_condition": "t3.a is not null and t3.c is not null", "outer_ref_condition": "t3.a is not null and t3.c is not null",
@ -15570,6 +15573,7 @@ EXPLAIN
"rows": 2, "rows": 2,
"filtered": 100, "filtered": 100,
"materialized": { "materialized": {
"lateral": 1,
"query_block": { "query_block": {
"select_id": 2, "select_id": 2,
"outer_ref_condition": "t3.a is not null and t3.c is not null", "outer_ref_condition": "t3.a is not null and t3.c is not null",
@ -15742,6 +15746,7 @@ EXPLAIN
"rows": 2, "rows": 2,
"filtered": 100, "filtered": 100,
"materialized": { "materialized": {
"lateral": 1,
"query_block": { "query_block": {
"select_id": 2, "select_id": 2,
"outer_ref_condition": "t3.c is not null", "outer_ref_condition": "t3.c is not null",
@ -15989,6 +15994,7 @@ EXPLAIN
"rows": 2, "rows": 2,
"filtered": 100, "filtered": 100,
"materialized": { "materialized": {
"lateral": 1,
"query_block": { "query_block": {
"select_id": 2, "select_id": 2,
"outer_ref_condition": "t3.c is not null", "outer_ref_condition": "t3.c is not null",
@ -16473,6 +16479,7 @@ EXPLAIN
"filtered": 100, "filtered": 100,
"first_match": "t4", "first_match": "t4",
"materialized": { "materialized": {
"lateral": 1,
"query_block": { "query_block": {
"select_id": 3, "select_id": 3,
"const_condition": "1", "const_condition": "1",
@ -16619,6 +16626,7 @@ EXPLAIN
"rows": 2, "rows": 2,
"filtered": 100, "filtered": 100,
"materialized": { "materialized": {
"lateral": 1,
"query_block": { "query_block": {
"select_id": 2, "select_id": 2,
"table": { "table": {

View File

@ -1756,6 +1756,11 @@ void Explain_table_access::print_explain_json(Explain_query *query,
/* This is a derived table. Print its contents here */ /* This is a derived table. Print its contents here */
writer->add_member("materialized").start_object(); writer->add_member("materialized").start_object();
Explain_node *node= query->get_node(derived_select_number); 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); node->print_explain_json(query, writer, is_analyze);
writer->end_object(); writer->end_object();
} }

View File

@ -211,6 +211,7 @@ public:
select_lex(NULL), select_lex(NULL),
#endif #endif
linkage(UNSPECIFIED_TYPE), linkage(UNSPECIFIED_TYPE),
is_lateral(false),
message(NULL), message(NULL),
having(NULL), having_value(Item::COND_UNDEF), having(NULL), having_value(Item::COND_UNDEF),
using_temporary(false), using_filesort(false), using_temporary(false), using_filesort(false),
@ -226,6 +227,7 @@ public:
#endif #endif
const char *select_type; const char *select_type;
enum sub_select_type linkage; enum sub_select_type linkage;
bool is_lateral;
/* /*
If message != NULL, this is a degenerate join plan, and all subsequent If message != NULL, this is a degenerate join plan, and all subsequent

View File

@ -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_id= join->select_lex->select_number;
xpl_sel->select_type= join->select_lex->type; xpl_sel->select_type= join->select_lex->type;
xpl_sel->linkage= select_lex->linkage; 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) if (select_lex->master_unit()->derived)
xpl_sel->connection_type= Explain_node::EXPLAIN_NODE_DERIVED; xpl_sel->connection_type= Explain_node::EXPLAIN_NODE_DERIVED;