MySQL  8.0.23
Source Code Documentation
sql_executor.h File Reference
#include <sys/types.h>
#include <cstring>
#include <memory>
#include <string>
#include <vector>
#include "my_alloc.h"
#include "my_compiler.h"
#include "my_inttypes.h"
#include "my_table_map.h"
#include "sql/row_iterator.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.


class  List< T >
class  Mem_root_array< Element_type >
 A typesafe replacement for DYNAMIC_ARRAY. More...
class  Semijoin_mat_exec
 Executor structure for the materialized semi-join info, which contains. More...
class  QEP_TAB
class  QEP_TAB_standalone
 Use this class when you need a QEP_TAB not connected to any JOIN_TAB. More...
struct  PendingCondition


#define QEP_AT(qtab, member)   (qtab->join()->qep_tab[qtab->member])


enum  Copy_func_type {


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 copy_fields_and_funcs (Temp_table_param *param, const THD *thd, Copy_func_type type=CFT_ALL)
bool construct_lookup_ref (THD *thd, TABLE *table, TABLE_REF *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 safe_index_read (QEP_TAB *tab)
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)
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)
 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, SELECT_LEX *select, Ref_item_array ref_item_array, mem_root_deque< Item * > *res_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_constraint (TABLE *table)
 Check unique_constraint. More...
ulonglong unique_hash (const Field *field, ulonglong *hash)
 Generate hash for a field. 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 (Item *item)
bool is_rollup_sum_wrapper (Item *item)
Itemunwrap_rollup_group (Item *item)
unique_ptr_destroy_only< RowIteratorPossiblyAttachFilterIterator (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)
bool process_buffered_windowing_record (THD *thd, Temp_table_param *param, const bool new_partition_or_eof, bool *output_row_ready)
 While there are more unprocessed rows ready to process given the current partition/frame state, process such buffered rows by evaluating/aggregating the window functions defined over this window on the current frame, moving the frame if required. More...
bool buffer_windowing_record (THD *thd, Temp_table_param *param, bool *new_partition)
 If we cannot evaluate all window functions for a window on the fly, buffer the current row for later processing by process_buffered_windowing_record. More...
bool bring_back_frame_row (THD *thd, Window *w, Temp_table_param *out_param, int64 rowno, Window_retrieve_cached_row_reason reason, int fno=0)
 Bring back buffered data to the record of qep_tab-1 [1], and optionally execute copy_fields() to the OUT table. More...
AccessPathGetAccessPathForDerivedTable (THD *thd, QEP_TAB *qep_tab, AccessPath *table_path)
AccessPathGetAccessPathForDerivedTable (THD *thd, TABLE_LIST *table_ref, TABLE *table, bool rematerialize, Mem_root_array< const AccessPath * > *invalidators, 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 TABLE_REF &ref, const KEY *key, bool include_nulls)
bool MaterializeIsDoingDeduplication (TABLE *table)
void ExtractConditions (Item *condition, Mem_root_array< Item * > *condition_parts)
 Split AND conditions into their constituent parts, recursively. More...

Detailed Description

Classes for query execution.

Macro Definition Documentation


#define QEP_AT (   qtab,
)    (qtab->join()->qep_tab[qtab->member])
a pointer to the QEP_TAB whose index is qtab->member. For example, QEP_AT(x,first_inner) is the first_inner table of x.

Enumeration Type Documentation

◆ Copy_func_type


In non-windowing step, copies functions.


In windowing step, copies framing window function, including all grouping aggregates, e.g.



In windowing step, copies non framing window function, e.g.

ROW_NUMBER, RANK, DENSE_RANK, except those that are two_pass cf. copy_two_pass_window_functions which are treated separately.


In windowing step, copies window functions that need frame cardinality, that is we need to read all rows of a partition before we can compute the wf's value for the the first row in the partition.


In windowing step, copies framing window functions that read only one row per frame.


In first windowing step, copies non-window functions which do not rely on window functions, i.e.

those that have Item::has_wf() == false.


In final windowing step, copies all non-wf functions.

Must be called after all wfs have been evaluated, as non-wf functions may reference wf, e.g. 1+RANK.


Copies all window functions.

Function Documentation

◆ MaterializeIsDoingDeduplication()

bool MaterializeIsDoingDeduplication ( TABLE table)

◆ PossiblyAttachFilterIterator()

unique_ptr_destroy_only<RowIterator> PossiblyAttachFilterIterator ( unique_ptr_destroy_only< RowIterator iterator,
const std::vector< Item * > &  conditions,
THD thd