MySQL 8.4.3
Source Code Documentation
|
#include "sql/sql_union.h"
#include <sys/types.h>
#include <algorithm>
#include <atomic>
#include <cassert>
#include <cstdio>
#include <limits>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "mem_root_deque.h"
#include "my_alloc.h"
#include "my_base.h"
#include "my_dbug.h"
#include "my_sqlcommand.h"
#include "my_sys.h"
#include "mysql/udf_registration_types.h"
#include "mysqld_error.h"
#include "prealloced_array.h"
#include "scope_guard.h"
#include "sql/auth/auth_acls.h"
#include "sql/current_thd.h"
#include "sql/debug_sync.h"
#include "sql/field.h"
#include "sql/handler.h"
#include "sql/item.h"
#include "sql/item_subselect.h"
#include "sql/iterators/row_iterator.h"
#include "sql/join_optimizer/access_path.h"
#include "sql/join_optimizer/bit_utils.h"
#include "sql/join_optimizer/explain_access_path.h"
#include "sql/join_optimizer/join_optimizer.h"
#include "sql/join_optimizer/materialize_path_parameters.h"
#include "sql/mem_root_array.h"
#include "sql/mysqld.h"
#include "sql/opt_explain.h"
#include "sql/opt_explain_format.h"
#include "sql/opt_trace.h"
#include "sql/parse_tree_node_base.h"
#include "sql/parse_tree_nodes.h"
#include "sql/parser_yystype.h"
#include "sql/pfs_batch_mode.h"
#include "sql/protocol.h"
#include "sql/query_options.h"
#include "sql/sql_base.h"
#include "sql/sql_class.h"
#include "sql/sql_cmd.h"
#include "sql/sql_const.h"
#include "sql/sql_error.h"
#include "sql/sql_executor.h"
#include "sql/sql_lex.h"
#include "sql/sql_list.h"
#include "sql/sql_optimizer.h"
#include "sql/sql_select.h"
#include "sql/sql_tmp_table.h"
#include "sql/table_function.h"
#include "sql/thd_raii.h"
#include "sql/visible_fields.h"
#include "sql/window.h"
#include "template_utils.h"
Classes | |
class | Query_result_union_direct |
This class is effectively dead. More... | |
class | Change_current_query_block |
RAII class to automate saving/restoring of current_query_block() More... | |
Functions | |
static bool | create_tmp_table_for_set_op (THD *thd, Query_term *qt, mem_root_deque< Item * > &types, ulonglong create_options) |
Create a tmp table for a set operation. More... | |
static bool | finalize_full_text_functions (THD *thd, Query_expression *query_expression) |
Finalizes the initialization of all the full-text functions used in the given query expression, and recursively in every query expression inner to the given one. More... | |
static bool | optimize_set_operand (THD *thd, Query_expression *qe, Query_term *qt) |
Optimize the post processing query blocks of the query expression's query term tree recursively. More... | |
static bool | contributes_to_rowcount_estimate (Query_block *qb) |
Determine if we should set or add the contribution of the given query block to the total row count estimate for the query expression. More... | |
static bool | use_iterator (TABLE *materialize_destination, Query_term *query_term) |
static AccessPath * | add_materialized_access_path (THD *thd, Query_term *qt, Mem_root_array< MaterializePathParameters::Operand > &operands, TABLE *dest, ha_rows limit=HA_POS_ERROR) |
Helper method: create a materialized access path, estimate its cost and move it to the best place, cf. More... | |
AccessPath * | make_set_op_access_path (THD *thd, Query_term_set_op *parent, Query_term *qt, Mem_root_array< AppendPathParameters > *union_all_subpaths, bool calc_found_rows) |
Recursively constructs the access path of the set operation, possibly materializing in a tmp table if needed, cf. More... | |
static void | cleanup_tmp_tables (Table_ref *list) |
Closes (and, if last reference, drops) temporary tables created to materialize derived tables, schema tables and CTEs. More... | |
static void | destroy_tmp_tables (Table_ref *list) |
Destroy temporary tables created to materialize derived tables, schema tables and CTEs. More... | |
|
static |
Helper method: create a materialized access path, estimate its cost and move it to the best place, cf.
doc for MoveCompositeIteratorsFromTablePath
thd | session state |
qt | query term for which we want to create a materialized access path |
operands | the constituent operands (query blocks) we want to materialize |
dest | the destination temporary (materialized) table |
limit | If not HA_POS_ERROR, the maximum number of rows allowed in the materialized table |
|
static |
Closes (and, if last reference, drops) temporary tables created to materialize derived tables, schema tables and CTEs.
list | List of tables to search in |
|
static |
Determine if we should set or add the contribution of the given query block to the total row count estimate for the query expression.
If we have INTERSECT or EXCEPT, only set row estimate for left side since the total number of rows in the result set can only decrease as a result of the set operation.
qb | query block |
|
static |
Create a tmp table for a set operation.
thd | session context |
qt | query term holding the query result to hold the tmp table |
types | the fields of the tmp table, inherited from Query_expression::types |
create_options | create options for create_tmp_table |
|
static |
Destroy temporary tables created to materialize derived tables, schema tables and CTEs.
list | List of tables to search in |
|
static |
Finalizes the initialization of all the full-text functions used in the given query expression, and recursively in every query expression inner to the given one.
We do this fairly late, since we need to know whether or not the full-text function is to be used for a full-text index scan, and whether or not that scan is sorted. When the iterators have been created, we know that the final decision has been made, so we do it right after the iterators have been created.
AccessPath * make_set_op_access_path | ( | THD * | thd, |
Query_term_set_op * | parent, | ||
Query_term * | qt, | ||
Mem_root_array< AppendPathParameters > * | union_all_subpaths, | ||
bool | calc_found_rows | ||
) |
Recursively constructs the access path of the set operation, possibly materializing in a tmp table if needed, cf.
Query_term_set_op::m_is_materialized
thd | session context |
parent | the parent of qt |
qt | the query term at this level of the tree |
union_all_subpaths | if not nullptr, we are part of a UNION all, add constructed access to it. |
calc_found_rows | if true, do allow for calculation of number of found rows even in presence of LIMIT. |
|
static |
Optimize the post processing query blocks of the query expression's query term tree recursively.
thd | session context |
qe | the owning query expression |
qt | the current query term to optimize |
|
static |