MySQL  8.0.20
Source Code Documentation
sql_executor.h File Reference

Classes for query execution. More...

#include <string.h>
#include <sys/types.h>
#include <memory>
#include <vector>
#include "my_alloc.h"
#include "my_base.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.

Classes

class  List< T >
 
class  Mem_root_array< Element_type >
 A typesafe replacement for DYNAMIC_ARRAY. More...
 
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
 
class  QEP_TAB_standalone
 Use this class when you need a QEP_TAB not connected to any JOIN_TAB. More...
 
struct  PendingCondition
 

Macros

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

Enumerations

enum  Copy_func_type {
  CFT_ALL, CFT_WF_FRAMING, CFT_WF_NON_FRAMING, CFT_WF_NEEDS_CARD,
  CFT_WF_USES_ONLY_ONE_ROW, CFT_HAS_NO_WF, CFT_HAS_WF, CFT_WF,
  CFT_DEPENDING_ON_AGGREGATE
}
 

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 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 (List< Item > &all_fields, size_t num_select_elements, THD *thd, Ref_item_array ref_item_array, List< Item > *res_selected_fields, List< Item > *res_all_fields)
 Change all funcs and sum_funcs to fields in tmp table, and create new list of all items. More...
 
bool change_refs_to_tmp_fields (List< Item > &all_fields, size_t num_select_elements, THD *thd, Ref_item_array ref_item_array, List< Item > *res_selected_fields, List< Item > *res_all_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 setup_copy_fields (List< Item > &all_fields, size_t num_select_elements, THD *thd, Temp_table_param *param, Ref_item_array ref_item_array, List< Item > *res_selected_fields, List< Item > *res_all_fields)
 Sets up caches for holding the values of non-aggregated expressions. 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...
 
void copy_sum_funcs (Item_sum **func_ptr, Item_sum **end_ptr)
 Copy result of sum functions to record in tmp_table. More...
 
bool set_record_buffer (const QEP_TAB *tab)
 Allocate a data buffer that the storage engine can use for fetching batches of records. More...
 
bool init_sum_functions (Item_sum **func_ptr, Item_sum **end_ptr)
 
void init_tmptable_sum_functions (Item_sum **func_ptr)
 
bool update_sum_func (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...
 
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...
 
unique_ptr_destroy_only< RowIteratorGetIteratorForDerivedTable (THD *thd, QEP_TAB *qep_tab)
 
void ConvertItemsToCopy (List< Item > *items, Field **fields, Temp_table_param *param, JOIN *join)
 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)
 

Detailed Description

Classes for query execution.

Macro Definition Documentation

◆ QEP_AT

#define QEP_AT (   qtab,
  member 
)    (qtab->join()->qep_tab[qtab->member])
Returns
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

Enumerator
CFT_ALL 

In non-windowing step, copies functions.

CFT_WF_FRAMING 

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

SUM, AVG and FIRST_VALUE, LAST_VALUE.

CFT_WF_NON_FRAMING 

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.

CFT_WF_NEEDS_CARD 

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.

CFT_WF_USES_ONLY_ONE_ROW 

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

CFT_HAS_NO_WF 

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

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

CFT_HAS_WF 

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.

CFT_WF 

Copies all window functions.

CFT_DEPENDING_ON_AGGREGATE 

Copies all items that are expressions containing aggregates, but are not themselves aggregates.

Such expressions are typically split into their constituent parts during setup_fields(), such that the parts that are not aggregates are replaced by Item_refs that point into a slice. See AggregateIterator::Read() for more details.

Function Documentation

◆ PossiblyAttachFilterIterator()

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