MySQL 8.4.2
Source Code Documentation
anonymous_namespace{opt_explain.cc}::Explain Class Reference

A base for all Explain_* classes. More...

Inheritance diagram for anonymous_namespace{opt_explain.cc}::Explain:
[legend]

Classes

class  Lazy_condition
 

Public Member Functions

virtual ~Explain ()=default
 
bool send ()
 Explain class main function. More...
 
bool can_print_clauses () const
 Tells if it is allowed to print the WHERE / GROUP BY / etc clauses. More...
 

Protected Member Functions

 Explain (enum_parsing_context context_type_arg, THD *explain_thd_arg, const THD *query_thd_arg, Query_block *query_block_arg)
 
virtual bool shallow_explain ()
 Explain everything but subqueries. More...
 
bool explain_subqueries ()
 Explain the rest of things after the shallow_explain() call. More...
 
bool mark_subqueries (Item *item, qep_row *destination)
 Qualify subqueries with WHERE/HAVING/ORDER BY/GROUP BY clause type marker. More...
 
bool prepare_columns ()
 Pre-calculate table property values for further EXPLAIN output. More...
 
bool push_extra (Extra_tag tag)
 Push a part of the "extra" column into formatter. More...
 
bool push_extra (Extra_tag tag, const String &arg)
 Push a part of the "extra" column into formatter. More...
 
bool push_extra (Extra_tag tag, const char *arg)
 Push a part of the "extra" column into formatter. More...
 
virtual bool explain_id ()
 
virtual bool explain_select_type ()
 
virtual bool explain_table_name ()
 
virtual bool explain_partitions ()
 
virtual bool explain_join_type ()
 
virtual bool explain_possible_keys ()
 
virtual bool explain_key_and_len ()
 fill col_key and and col_key_len fields together More...
 
virtual bool explain_ref ()
 
virtual bool explain_rows_and_filtered ()
 fill col_rows and col_filtered fields together More...
 
virtual bool explain_extra ()
 
virtual bool explain_modify_flags ()
 
virtual bool can_walk_clauses ()
 Returns true if the WHERE, ORDER BY, GROUP BY, etc clauses can safely be traversed: it means that we can iterate through them (no element is added/removed/replaced); the internal details of an element can change though (in particular if that element is an Item_subselect). More...
 
virtual enum_parsing_context get_subquery_context (Query_expression *unit) const
 

Protected Attributes

THD *const explain_thd
 cached THD which runs the EXPLAIN command More...
 
const THDquery_thd
 THD which runs the query to be explained. More...
 
const CHARSET_INFO *const cs
 cached pointer to system_charset_info More...
 
Query_block *const query_block
 Cached Query_block of the explained query. More...
 
Explain_format *const fmt
 shortcut for thd->lex->explain_format More...
 
enum_parsing_context context_type
 associated value for struct. explain More...
 
bool order_list
 if query block has ORDER BY More...
 
const bool explain_other
 if we explain other thread than us More...
 

Private Member Functions

virtual bool skip_subqueries () const
 Returns true if EXPLAIN should not produce any information about subqueries. More...
 

Detailed Description

A base for all Explain_* classes.

Explain_* classes collect and output EXPLAIN data.

This class hierarchy is a successor of the old select_describe() function of 5.5.

Constructor & Destructor Documentation

◆ Explain()

anonymous_namespace{opt_explain.cc}::Explain::Explain ( enum_parsing_context  context_type_arg,
THD explain_thd_arg,
const THD query_thd_arg,
Query_block query_block_arg 
)
inlineexplicitprotected

◆ ~Explain()

virtual anonymous_namespace{opt_explain.cc}::Explain::~Explain ( )
virtualdefault

Member Function Documentation

◆ can_print_clauses()

bool anonymous_namespace{opt_explain.cc}::Explain::can_print_clauses ( ) const
inline

Tells if it is allowed to print the WHERE / GROUP BY / etc clauses.

◆ can_walk_clauses()

virtual bool anonymous_namespace{opt_explain.cc}::Explain::can_walk_clauses ( )
inlineprotectedvirtual

Returns true if the WHERE, ORDER BY, GROUP BY, etc clauses can safely be traversed: it means that we can iterate through them (no element is added/removed/replaced); the internal details of an element can change though (in particular if that element is an Item_subselect).

By default, if we are explaining another connection, this is not safe.

Reimplemented in anonymous_namespace{opt_explain.cc}::Explain_setop_result, anonymous_namespace{opt_explain.cc}::Explain_join, and anonymous_namespace{opt_explain.cc}::Explain_table.

◆ explain_extra()

◆ explain_id()

bool Explain::explain_id ( )
protectedvirtual

◆ explain_join_type()

virtual bool anonymous_namespace{opt_explain.cc}::Explain::explain_join_type ( )
inlineprotectedvirtual

◆ explain_key_and_len()

virtual bool anonymous_namespace{opt_explain.cc}::Explain::explain_key_and_len ( )
inlineprotectedvirtual

fill col_key and and col_key_len fields together

Reimplemented in anonymous_namespace{opt_explain.cc}::Explain_join, and anonymous_namespace{opt_explain.cc}::Explain_table.

◆ explain_modify_flags()

virtual bool anonymous_namespace{opt_explain.cc}::Explain::explain_modify_flags ( )
inlineprotectedvirtual

◆ explain_partitions()

virtual bool anonymous_namespace{opt_explain.cc}::Explain::explain_partitions ( )
inlineprotectedvirtual

◆ explain_possible_keys()

virtual bool anonymous_namespace{opt_explain.cc}::Explain::explain_possible_keys ( )
inlineprotectedvirtual

◆ explain_ref()

virtual bool anonymous_namespace{opt_explain.cc}::Explain::explain_ref ( )
inlineprotectedvirtual

◆ explain_rows_and_filtered()

virtual bool anonymous_namespace{opt_explain.cc}::Explain::explain_rows_and_filtered ( )
inlineprotectedvirtual

◆ explain_select_type()

bool Explain::explain_select_type ( )
protectedvirtual

◆ explain_subqueries()

bool Explain::explain_subqueries ( )
protected

Explain the rest of things after the shallow_explain() call.

Traverses SQL clauses of this query specification to identify children subqueries, marks each of them with the clause they belong to.

Then goes though all children subqueries and produces their EXPLAIN output, attached to the proper clause's context.

Return values
falseOk
trueError (OOM)

◆ explain_table_name()

virtual bool anonymous_namespace{opt_explain.cc}::Explain::explain_table_name ( )
inlineprotectedvirtual

◆ get_subquery_context()

enum_parsing_context anonymous_namespace{opt_explain.cc}::Explain::get_subquery_context ( Query_expression unit) const
protectedvirtual

◆ mark_subqueries()

bool Explain::mark_subqueries ( Item item,
qep_row destination 
)
protected

Qualify subqueries with WHERE/HAVING/ORDER BY/GROUP BY clause type marker.

Parameters
itemItem tree to find subqueries
destinationFor WHERE clauses
Note
WHERE clause belongs to TABLE or QEP_TAB. The destination parameter provides a pointer to QEP data for such a table to associate a future subquery EXPLAIN output with table QEP provided.
Return values
falseOK
trueError

◆ prepare_columns()

bool Explain::prepare_columns ( )
protected

Pre-calculate table property values for further EXPLAIN output.

◆ push_extra() [1/3]

bool anonymous_namespace{opt_explain.cc}::Explain::push_extra ( Extra_tag  tag)
inlineprotected

Push a part of the "extra" column into formatter.

Traditional formatter outputs traditional_extra_tags[tag] as is. Hierarchical formatter outputs a property with the json_extra_tags[tag] name and a boolean value of true.

Parameters
tagtype of the "extra" part
Return values
falseOk
trueError (OOM)

◆ push_extra() [2/3]

bool anonymous_namespace{opt_explain.cc}::Explain::push_extra ( Extra_tag  tag,
const char *  arg 
)
inlineprotected

Push a part of the "extra" column into formatter.

Parameters
tagtype of the "extra" part
argfor traditional formatter: rest of the part text, for hierarchical format: string value of the property

NOTE: arg must be a long-living string constant.

Return values
falseOk
trueError (OOM)

◆ push_extra() [3/3]

bool anonymous_namespace{opt_explain.cc}::Explain::push_extra ( Extra_tag  tag,
const String arg 
)
inlineprotected

Push a part of the "extra" column into formatter.

Parameters
tagtype of the "extra" part
argfor traditional formatter: rest of the part text, for hierarchical format: string value of the property
Return values
falseOk
trueError (OOM)

◆ send()

bool Explain::send ( )

Explain class main function.

This function: a) allocates a Query_result_send object (if no one pre-allocated available), b) calculates and sends whole EXPLAIN data.

Returns
false if success, true if error

◆ shallow_explain()

bool Explain::shallow_explain ( )
protectedvirtual

◆ skip_subqueries()

virtual bool anonymous_namespace{opt_explain.cc}::Explain::skip_subqueries ( ) const
inlineprivatevirtual

Returns true if EXPLAIN should not produce any information about subqueries.

Reimplemented in anonymous_namespace{opt_explain.cc}::Explain_secondary_engine.

Member Data Documentation

◆ context_type

enum_parsing_context anonymous_namespace{opt_explain.cc}::Explain::context_type
protected

associated value for struct. explain

◆ cs

const CHARSET_INFO* const anonymous_namespace{opt_explain.cc}::Explain::cs
protected

cached pointer to system_charset_info

◆ explain_other

const bool anonymous_namespace{opt_explain.cc}::Explain::explain_other
protected

if we explain other thread than us

◆ explain_thd

THD* const anonymous_namespace{opt_explain.cc}::Explain::explain_thd
protected

cached THD which runs the EXPLAIN command

◆ fmt

Explain_format* const anonymous_namespace{opt_explain.cc}::Explain::fmt
protected

shortcut for thd->lex->explain_format

◆ order_list

bool anonymous_namespace{opt_explain.cc}::Explain::order_list
protected

if query block has ORDER BY

◆ query_block

Query_block* const anonymous_namespace{opt_explain.cc}::Explain::query_block
protected

Cached Query_block of the explained query.

Used for all explained stmts, including single-table UPDATE (provides way to access ORDER BY of UPDATE).

◆ query_thd

const THD* anonymous_namespace{opt_explain.cc}::Explain::query_thd
protected

THD which runs the query to be explained.


The documentation for this class was generated from the following file: