MySQL 9.1.0
Source Code Documentation
|
Classes for query execution. More...
#include <sys/types.h>
#include <string>
#include <vector>
#include "my_alloc.h"
#include "my_inttypes.h"
#include "my_table_map.h"
#include "sql/sql_lex.h"
#include "sql/sql_opt_exec_shared.h"
#include "sql/table.h"
#include "sql/temp_table_param.h"
Go to the source code of this file.
Classes | |
struct | SJ_TMP_TABLE_TAB |
class | SJ_TMP_TABLE |
class | Semijoin_mat_exec |
Executor structure for the materialized semi-join info, which contains. More... | |
class | QEP_TAB |
struct | PendingCondition |
struct | PendingInvalidator |
Cache invalidator iterators we need to apply, but cannot yet due to outer joins. More... | |
Enumerations | |
enum | Copy_func_type : int { CFT_ALL , CFT_WF_FRAMING , CFT_WF_NON_FRAMING , CFT_WF_NEEDS_PARTITION_CARDINALITY , CFT_WF_USES_ONLY_ONE_ROW , CFT_HAS_NO_WF , CFT_HAS_WF , CFT_WF , CFT_FIELDS } |
enum | CallingContext { TOP_LEVEL , DIRECTLY_UNDER_SEMIJOIN , DIRECTLY_UNDER_OUTER_JOIN , DIRECTLY_UNDER_WEEDOUT } |
Functions | |
void | setup_tmptable_write_func (QEP_TAB *tab, Opt_trace_object *trace) |
Setup write_func of QEP_tmp_table object. More... | |
bool | copy_fields (Temp_table_param *param, const THD *thd, bool reverse_copy=false) |
Make a copy of all simple SELECT'ed fields. More... | |
bool | copy_funcs (Temp_table_param *, const THD *thd, Copy_func_type type=CFT_ALL) |
Copy result of functions to record in tmp_table. More... | |
bool | construct_lookup (THD *thd, TABLE *table, Index_lookup *ref) |
Copy the lookup key into the table ref's key buffer. More... | |
int | report_handler_error (TABLE *table, int error) |
Help function when we get some an error from the table handler. More... | |
int | join_read_const_table (JOIN_TAB *tab, POSITION *pos) |
Reads content of constant table. More... | |
int | do_sj_dups_weedout (THD *thd, SJ_TMP_TABLE *sjtbl) |
SemiJoinDuplicateElimination: Weed out duplicate row combinations. More... | |
int | update_item_cache_if_changed (List< Cached_item > &list) |
size_t | compute_ria_idx (const mem_root_deque< Item * > &fields, size_t i, size_t added_non_hidden_fields, size_t border) |
Compute the position mapping from fields to ref_item_array, cf. More... | |
bool | change_to_use_tmp_fields (mem_root_deque< Item * > *fields, THD *thd, Ref_item_array ref_item_array, mem_root_deque< Item * > *res_fields, size_t added_non_hidden_fields, bool windowing=false) |
Change all funcs and sum_funcs to fields in tmp table, and create new list of all items. More... | |
bool | change_to_use_tmp_fields_except_sums (mem_root_deque< Item * > *fields, THD *thd, Query_block *select, Ref_item_array ref_item_array, mem_root_deque< Item * > *res_fields, size_t added_non_hidden_fields) |
Change all sum_func refs to fields to point at fields in tmp table. More... | |
bool | prepare_sum_aggregators (Item_sum **func_ptr, bool need_distinct) |
bool | setup_sum_funcs (THD *thd, Item_sum **func_ptr) |
Call setup() for all sum functions. More... | |
bool | make_group_fields (JOIN *main_join, JOIN *curr_join) |
allocate group fields or take prepared (cached). More... | |
bool | check_unique_fields (TABLE *table) |
Check whether a row is already present in the tmp table. More... | |
ulonglong | calc_row_hash (TABLE *table) |
Generate hash for unique_constraint for all visible fields of a table. More... | |
ulonglong | calc_field_hash (const Field *field, ulonglong *hash) |
Generate hash for a field. More... | |
int | read_const (TABLE *table, Index_lookup *ref) |
bool | table_rec_cmp (TABLE *table) |
Compare GROUP BY in from tmp table's record[0] and record[1]. More... | |
bool | set_record_buffer (TABLE *table, double expected_rows_to_fetch) |
Allocate a data buffer that the storage engine can use for fetching batches of records. More... | |
void | init_tmptable_sum_functions (Item_sum **func_ptr) |
void | update_tmptable_sum_func (Item_sum **func_ptr, TABLE *tmp_table) |
Update record 0 in tmp_table from record 1. More... | |
bool | has_rollup_result (Item *item) |
Checks if an item has a ROLLUP NULL which needs to be written to temp table. More... | |
bool | is_rollup_group_wrapper (const Item *item) |
Item * | unwrap_rollup_group (Item *item) |
Item * | CreateConjunction (List< Item > *items) |
Create an AND conjunction of all given items. More... | |
unique_ptr_destroy_only< RowIterator > | PossiblyAttachFilterIterator (unique_ptr_destroy_only< RowIterator > iterator, const std::vector< Item * > &conditions, THD *thd) |
void | SplitConditions (Item *condition, QEP_TAB *current_table, std::vector< Item * > *predicates_below_join, std::vector< PendingCondition > *predicates_above_join, std::vector< PendingCondition > *join_conditions, plan_idx semi_join_table_idx, qep_tab_map left_tables) |
AccessPath * | MoveCompositeIteratorsFromTablePath (THD *thd, AccessPath *path, const Query_block &query_block) |
For a MATERIALIZE access path, move any non-basic iterators (e.g. More... | |
AccessPath * | GetAccessPathForDerivedTable (THD *thd, Table_ref *table_ref, TABLE *table, bool rematerialize, Mem_root_array< const AccessPath * > *invalidators, bool need_rowid, AccessPath *table_path) |
void | ConvertItemsToCopy (const mem_root_deque< Item * > &items, Field **fields, Temp_table_param *param) |
For historical reasons, derived table materialization and temporary table materialization didn't specify the fields to materialize in the same way. More... | |
std::string | RefToString (const Index_lookup &ref, const KEY &key, bool include_nulls) |
bool | MaterializeIsDoingDeduplication (TABLE *table) |
(end of group Query_Executor) More... | |
bool | ExtractConditions (Item *condition, Mem_root_array< Item * > *condition_parts) |
Split AND conditions into their constituent parts, recursively. More... | |
AccessPath * | create_table_access_path (THD *thd, TABLE *table, AccessPath *range_scan, Table_ref *table_ref, POSITION *position, bool count_examined_rows) |
create_table_access_path is used to scan by using a number of different methods. More... | |
unique_ptr_destroy_only< RowIterator > | init_table_iterator (THD *thd, TABLE *table, AccessPath *range_scan, Table_ref *table_ref, POSITION *position, bool ignore_not_found_rows, bool count_examined_rows) |
Creates an iterator for the given table, then calls Init() on the resulting iterator. More... | |
unique_ptr_destroy_only< RowIterator > | init_table_iterator (THD *thd, TABLE *table, bool ignore_not_found_rows, bool count_examined_rows) |
A short form for when there's no range scan, recursive CTEs or cost information; just a unique_result or a simple table scan. More... | |
AccessPath * | ConnectJoins (plan_idx upper_first_idx, plan_idx first_idx, plan_idx last_idx, QEP_TAB *qep_tabs, THD *thd, CallingContext calling_context, std::vector< PendingCondition > *pending_conditions, std::vector< PendingInvalidator > *pending_invalidators, std::vector< PendingCondition > *pending_join_conditions, qep_tab_map *unhandled_duplicates, table_map *conditions_depend_on_outer_tables) |
void | set_count_examined_rows (AccessPath *path, bool count_examined_rows) |
For the given access path, set "count_examined_rows" to the value specified. More... | |
Classes for query execution.
enum CallingContext |
enum Copy_func_type : int |
AccessPath * ConnectJoins | ( | plan_idx | upper_first_idx, |
plan_idx | first_idx, | ||
plan_idx | last_idx, | ||
QEP_TAB * | qep_tabs, | ||
THD * | thd, | ||
CallingContext | calling_context, | ||
std::vector< PendingCondition > * | pending_conditions, | ||
std::vector< PendingInvalidator > * | pending_invalidators, | ||
std::vector< PendingCondition > * | pending_join_conditions, | ||
qep_tab_map * | unhandled_duplicates, | ||
table_map * | conditions_depend_on_outer_tables | ||
) |
AccessPath * create_table_access_path | ( | THD * | thd, |
TABLE * | table, | ||
AccessPath * | range_scan, | ||
Table_ref * | table_ref, | ||
POSITION * | position, | ||
bool | count_examined_rows | ||
) |
create_table_access_path is used to scan by using a number of different methods.
Which method to use is set-up in this call so that you can create an iterator from the returned access path and fetch rows through said iterator afterwards.
thd | Thread handle |
table | Table the data [originally] comes from |
range_scan | AccessPath to scan the table with, or nullptr |
table_ref | Position for the table, must be non-nullptr for WITH RECURSIVE |
position | Place to get cost information from, or nullptr |
count_examined_rows | See AccessPath::count_examined_rows. |
unique_ptr_destroy_only< RowIterator > init_table_iterator | ( | THD * | thd, |
TABLE * | table, | ||
AccessPath * | range_scan, | ||
Table_ref * | table_ref, | ||
POSITION * | position, | ||
bool | ignore_not_found_rows, | ||
bool | count_examined_rows | ||
) |
Creates an iterator for the given table, then calls Init() on the resulting iterator.
Unlike create_table_iterator(), this can create iterators for sort buffer results (which are set in the TABLE object during query execution). Returns nullptr on failure.
|
inline |
A short form for when there's no range scan, recursive CTEs or cost information; just a unique_result or a simple table scan.
Normally, you should prefer just instantiating an iterator yourself – this is for legacy use only.
bool MaterializeIsDoingDeduplication | ( | TABLE * | table | ) |
(end of group Query_Executor)
unique_ptr_destroy_only< RowIterator > PossiblyAttachFilterIterator | ( | unique_ptr_destroy_only< RowIterator > | iterator, |
const std::vector< Item * > & | conditions, | ||
THD * | thd | ||
) |
void set_count_examined_rows | ( | AccessPath * | path, |
bool | count_examined_rows | ||
) |
For the given access path, set "count_examined_rows" to the value specified.
For index merge scans, we set "count_examined_rows" for all the child paths too.
path | Access path (A range scan) |
count_examined_rows | See AccessPath::count_examined_rows. |
void SplitConditions | ( | Item * | condition, |
QEP_TAB * | current_table, | ||
std::vector< Item * > * | predicates_below_join, | ||
std::vector< PendingCondition > * | predicates_above_join, | ||
std::vector< PendingCondition > * | join_conditions, | ||
plan_idx | semi_join_table_idx, | ||
qep_tab_map | left_tables | ||
) |