1#ifndef SQL_EXECUTOR_INCLUDED
2#define SQL_EXECUTOR_INCLUDED
73template <
typename Element_type>
168 bool reverse_copy =
false);
246 size_t added_non_hidden_fields);
252 size_t added_non_hidden_fields);
524 const std::vector<Item *> &conditions,
THD *thd);
527 std::vector<Item *> *predicates_below_join,
528 std::vector<PendingCondition> *predicates_above_join,
529 std::vector<PendingCondition> *join_conditions,
578 bool count_examined_rows);
588 POSITION *position,
bool ignore_not_found_rows,
bool count_examined_rows);
596 THD *thd,
TABLE *table,
bool ignore_not_found_rows,
597 bool count_examined_rows) {
599 ignore_not_found_rows, count_examined_rows);
605 std::vector<PendingCondition> *pending_conditions,
606 std::vector<PendingInvalidator> *pending_invalidators,
607 std::vector<PendingCondition> *pending_join_conditions,
609 table_map *conditions_depend_on_outer_tables);
An iterator that helps invalidating caches.
Definition: composite_iterators.h:392
This is used for segregating rows in groups (e.g.
Definition: item.h:6333
Sorting related info.
Definition: filesort.h:52
FollowTailIterator is a special version of TableScanIterator that is used as part of WITH RECURSIVE q...
Definition: basic_row_iterators.h:439
Class Item_sum is the base class used for special expressions that SQL calls 'set functions'.
Definition: item_sum.h:399
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:853
Query optimization plan node.
Definition: sql_select.h:599
Definition: sql_optimizer.h:133
Definition: sql_list.h:434
A typesafe replacement for DYNAMIC_ARRAY.
Definition: mem_root_array.h:426
The iterator actually doing the reads from the inner table during BKA.
Definition: bka_iterator.h:264
A JSON object (unordered set of key/value pairs).
Definition: opt_trace.h:799
Definition: sql_executor.h:260
uint loosescan_key_len
Definition: sql_executor.h:371
bool dynamic_range() const
Definition: sql_executor.h:331
Setup_func materialize_table
Definition: sql_executor.h:390
void set_reversed_access(bool arg)
Definition: sql_executor.h:294
Item * m_condition_optim
Condition as it was set by the optimizer, used for EXPLAIN.
Definition: sql_executor.h:447
bool rematerialize
Dependent table functions have to be materialized on each new scan.
Definition: sql_executor.h:382
bool keyread_optim() const
Definition: sql_executor.h:289
Filesort * filesort
Definition: sql_executor.h:431
bool reversed_access() const
Definition: sql_executor.h:293
void set_table(TABLE *t)
Definition: sql_executor.h:296
uint ref_item_slice
Slice number of the ref items array to switch to before reading rows from this table.
Definition: sql_executor.h:443
bool m_reversed_access
True if reversed scan is used.
Definition: sql_executor.h:458
qep_tab_map lateral_derived_tables_depend_on_me
Maps of all lateral derived tables which should be refreshed when execution reads a new row from this...
Definition: sql_executor.h:468
bool needs_duplicate_removal
true <=> remove duplicates on this table.
Definition: sql_executor.h:394
plan_idx firstmatch_return
Definition: sql_executor.h:365
enum QEP_TAB::enum_op_type op_type
bool do_firstmatch() const
Return true if join_tab should perform a FirstMatch action.
Definition: sql_executor.h:305
ORDER * filesort_pushed_order
If we pushed a global ORDER BY down onto this first table, that ORDER BY list will be preserved here.
Definition: sql_executor.h:437
Setup_func
Definition: sql_executor.h:384
@ NO_SETUP
Definition: sql_executor.h:385
@ MATERIALIZE_TABLE_FUNCTION
Definition: sql_executor.h:386
@ MATERIALIZE_SEMIJOIN
Definition: sql_executor.h:388
@ MATERIALIZE_DERIVED
Definition: sql_executor.h:387
QEP_TAB()
Definition: sql_executor.h:262
Item * condition_optim() const
Definition: sql_executor.h:287
QEP_TAB & operator=(const QEP_TAB &)
bool not_used_in_distinct
Definition: sql_executor.h:401
bool starts_weedout() const
Return true if join_tab starts a Duplicate Weedout action.
Definition: sql_executor.h:311
bool m_keyread_optim
True if only index is going to be read for this table.
Definition: sql_executor.h:453
bool using_dynamic_range
Definition: sql_executor.h:391
bool finishes_weedout() const
Return true if join_tab finishes a Duplicate Weedout action.
Definition: sql_executor.h:314
bool do_loosescan() const
Return true if join_tab should perform a LooseScan action.
Definition: sql_executor.h:308
Item * having
HAVING condition for checking prior saving a record into tmp table.
Definition: sql_executor.h:404
SJ_TMP_TABLE * flush_weedout_table
Definition: sql_executor.h:357
Temp_table_param * tmp_table_param
Definition: sql_executor.h:428
void set_condition_optim()
Definition: sql_executor.h:288
plan_idx match_tab
Definition: sql_executor.h:379
Table_ref * table_ref
Pointer to table reference.
Definition: sql_executor.h:354
SJ_TMP_TABLE * check_weed_out_table
Definition: sql_executor.h:358
enum_op_type
Definition: sql_executor.h:407
@ OT_MATERIALIZE
Definition: sql_executor.h:415
@ OT_BKA
Definition: sql_executor.h:424
@ OT_AGGREGATE_INTO_TMP_TABLE
Definition: sql_executor.h:417
@ OT_AGGREGATE
Definition: sql_executor.h:412
@ OT_BNL
Definition: sql_executor.h:421
@ OT_AGGREGATE_THEN_MATERIALIZE
Definition: sql_executor.h:416
@ OT_WINDOWING_FUNCTION
Definition: sql_executor.h:418
@ OT_NONE
Definition: sql_executor.h:409
Mem_root_array< const AccessPath * > * invalidators
Definition: sql_executor.h:470
void set_keyread_optim()
Definition: sql_executor.h:290
Owner of a QEP_shared; parent of JOIN_TAB and QEP_TAB.
Definition: sql_opt_exec_shared.h:478
JOIN * join() const
Definition: sql_opt_exec_shared.h:491
TABLE * table() const
Definition: sql_opt_exec_shared.h:504
QEP_shared * m_qs
Definition: sql_opt_exec_shared.h:574
Item * condition() const
Definition: sql_opt_exec_shared.h:526
POSITION * position() const
Definition: sql_opt_exec_shared.h:505
void set_table(TABLE *t)
Definition: sql_opt_exec_shared.h:277
This class represents a query block, aka a query specification, which is a query consisting of a SELE...
Definition: sql_lex.h:1156
A context for reading through a single table using a chosen access method: index read,...
Definition: row_iterator.h:82
Definition: sql_executor.h:104
uint rowid_len
Definition: sql_executor.h:128
TABLE * tmp_table
Definition: sql_executor.h:131
SJ_TMP_TABLE_TAB * tabs
Definition: sql_executor.h:107
SJ_TMP_TABLE * next
Definition: sql_executor.h:134
uint null_bits
Definition: sql_executor.h:126
SJ_TMP_TABLE_TAB * tabs_end
Definition: sql_executor.h:108
bool have_confluent_row
Definition: sql_executor.h:123
SJ_TMP_TABLE()
Definition: sql_executor.h:106
uint null_bytes
Definition: sql_executor.h:127
bool is_confluent
Definition: sql_executor.h:117
Field_longlong * hash_field
Definition: sql_executor.h:136
Executor structure for the materialized semi-join info, which contains.
Definition: sql_executor.h:144
const bool is_scan
true if executing a scan, false if lookup
Definition: sql_executor.h:157
TABLE * table
Reference to temporary table.
Definition: sql_executor.h:162
Table_ref *const sj_nest
Semi-join nest for this materialization.
Definition: sql_executor.h:156
const uint inner_table_index
Index in join_tab for first inner table.
Definition: sql_executor.h:160
const uint mat_table_index
Index in join_tab for materialized table.
Definition: sql_executor.h:159
Temp_table_param table_param
The temptable and its related info.
Definition: sql_executor.h:161
~Semijoin_mat_exec()=default
const uint table_count
Number of tables in the sj-nest.
Definition: sql_executor.h:158
Semijoin_mat_exec(Table_ref *sj_nest, bool is_scan, uint table_count, uint mat_table_index, uint inner_table_index)
Definition: sql_executor.h:146
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:34
Object containing parameters used when creating and using temporary tables.
Definition: temp_table_param.h:95
Represents the (explicit) window of a SQL 2003 section 7.11 <window clause>, or the implicit (inlined...
Definition: window.h:105
A (partial) implementation of std::deque allocating its blocks on a MEM_ROOT.
Definition: mem_root_deque.h:110
Fido Client Authentication nullptr
Definition: fido_client_plugin.cc:222
Item * unwrap_rollup_group(Item *item)
Definition: sql_executor.cc:338
void init_tmptable_sum_functions(Item_sum **func_ptr)
Definition: sql_executor.cc:398
bool pfs_batch_update(const JOIN *join) const
Definition: sql_executor.cc:4635
bool setup_sum_funcs(THD *thd, Item_sum **func_ptr)
Call setup() for all sum functions.
Definition: sql_executor.cc:389
bool copy_funcs(Temp_table_param *, const THD *thd, Copy_func_type type=CFT_ALL)
Copy result of functions to record in tmp_table.
Definition: sql_executor.cc:430
bool has_rollup_result(Item *item)
Checks if an item has a ROLLUP NULL which needs to be written to temp table.
Definition: sql_executor.cc:308
int join_read_const_table(JOIN_TAB *tab, POSITION *pos)
Reads content of constant table.
Definition: sql_executor.cc:3482
bool construct_lookup(THD *thd, TABLE *table, Index_lookup *ref)
Copy the lookup key into the table ref's key buffer.
Definition: sql_executor.cc:4063
ulonglong unique_hash(const Field *field, ulonglong *hash)
Generate hash for a field.
Definition: sql_executor.cc:3942
int do_sj_dups_weedout(THD *thd, SJ_TMP_TABLE *sjtbl)
SemiJoinDuplicateElimination: Weed out duplicate row combinations.
Definition: sql_executor.cc:3385
AccessPath * MoveCompositeIteratorsFromTablePath(AccessPath *path, const Query_block &query_block)
For a MATERIALIZE access path, move any non-basic iterators (e.g.
Definition: sql_executor.cc:1535
int report_handler_error(TABLE *table, int error)
Help function when we get some an error from the table handler.
Definition: sql_executor.cc:3455
void setup_tmptable_write_func(QEP_TAB *tab, Opt_trace_object *trace)
Setup write_func of QEP_tmp_table object.
Definition: sql_executor.cc:519
int update_item_cache_if_changed(List< Cached_item > &list)
Definition: sql_executor.cc:4145
AccessPath * access_path()
Construct an access path for reading from this table in the query, using the access method that has b...
Definition: sql_executor.cc:3699
int read_const(TABLE *table, Index_lookup *ref)
Definition: sql_executor.cc:3613
bool use_order() const
Use ordering provided by chosen index?
Definition: sql_executor.cc:3673
bool is_rollup_group_wrapper(const Item *item)
Definition: sql_executor.cc:332
AccessPath * GetAccessPathForDerivedTable(THD *thd, QEP_TAB *qep_tab, AccessPath *table_path)
Definition: sql_executor.cc:1473
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.
Definition: sql_executor.cc:4407
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)
Change all funcs and sum_funcs to fields in tmp table, and create new list of all items.
Definition: sql_executor.cc:4255
bool check_unique_constraint(TABLE *table)
Check unique_constraint.
Definition: sql_executor.cc:4035
std::string RefToString(const Index_lookup &ref, const KEY *key, bool include_nulls)
Definition: sql_executor.cc:131
bool make_group_fields(JOIN *main_join, JOIN *curr_join)
allocate group fields or take prepared (cached).
Definition: sql_executor.cc:4103
void update_tmptable_sum_func(Item_sum **func_ptr, TABLE *tmp_table)
Update record 0 in tmp_table from record 1.
Definition: sql_executor.cc:406
Item * CreateConjunction(List< Item > *items)
Create an AND conjunction of all given items.
Definition: sql_executor.cc:736
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.
Definition: sql_executor.cc:655
bool copy_fields(Temp_table_param *param, const THD *thd, bool reverse_copy=false)
Make a copy of all simple SELECT'ed fields.
Definition: sql_executor.cc:4192
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 spec...
Definition: sql_executor.cc:927
bool ExtractConditions(Item *condition, Mem_root_array< Item * > *condition_parts)
Split AND conditions into their constituent parts, recursively.
Definition: sql_executor.cc:708
bool prepare_sum_aggregators(Item_sum **func_ptr, bool need_distinct)
Definition: sql_executor.cc:363
void init(JOIN_TAB *jt)
Initializes the object from a JOIN_TAB.
Definition: sql_optimizer.cc:1319
void init_join_cache(JOIN_TAB *join_tab)
A helper function that allocates appropriate join cache object and sets next_query_block function of ...
Definition: sql_select.cc:3241
void push_index_cond(const JOIN_TAB *join_tab, uint keyno, Opt_trace_object *trace_obj)
Try to extract and push the index condition down to table handler.
Definition: sql_select.cc:2912
void cleanup()
Definition: sql_select.cc:3512
uint sjm_query_block_id() const
Definition: sql_select.cc:3568
uint effective_index() const
Return the index used for a table in a QEP.
Definition: sql_optimizer.cc:1346
uint get_sj_strategy() const
Definition: sql_optimizer.cc:1326
This file follows Google coding style, except for the name MEM_ROOT (which is kept for historical rea...
std::unique_ptr< T, Destroy_only< T > > unique_ptr_destroy_only
std::unique_ptr, but only destroying.
Definition: my_alloc.h:489
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:56
unsigned char uchar
Definition: my_inttypes.h:52
uint64_t table_map
Definition: my_table_map.h:30
uint64_t qep_tab_map
Definition: my_table_map.h:32
static char * path
Definition: mysqldump.cc:137
PT & ref(PT *tp)
Definition: tablespace_impl.cc:359
std::list< T, ut::allocator< T > > list
Specialization of list which uses ut_allocator.
Definition: ut0new.h:2878
required string key
Definition: replication_asynchronous_connection_failover.proto:60
required string type
Definition: replication_group_member_actions.proto:34
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)
bool MaterializeIsDoingDeduplication(TABLE *table)
(end of group Query_Executor)
Definition: sql_executor.cc:4653
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.
Definition: sql_executor.cc:4688
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)
CallingContext
Definition: sql_executor.h:509
@ DIRECTLY_UNDER_OUTER_JOIN
Definition: sql_executor.h:512
@ TOP_LEVEL
Definition: sql_executor.h:510
@ DIRECTLY_UNDER_WEEDOUT
Definition: sql_executor.h:513
@ DIRECTLY_UNDER_SEMIJOIN
Definition: sql_executor.h:511
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.
Definition: sql_executor.cc:4708
Copy_func_type
Definition: sql_executor.h:170
@ CFT_HAS_NO_WF
In first windowing step, copies non-window functions which do not rely on window functions,...
Definition: sql_executor.h:201
@ CFT_WF_NON_FRAMING
In windowing step, copies non framing window function, e.g.
Definition: sql_executor.h:185
@ CFT_WF_NEEDS_PARTITION_CARDINALITY
In windowing step, copies window functions that need frame cardinality, that is we need to read all r...
Definition: sql_executor.h:191
@ CFT_WF_FRAMING
In windowing step, copies framing window function, including all grouping aggregates,...
Definition: sql_executor.h:179
@ CFT_ALL
In non-windowing step, copies functions.
Definition: sql_executor.h:174
@ CFT_FIELDS
Copies Item_field only (typically because other functions might depend on those fields).
Definition: sql_executor.h:216
@ CFT_HAS_WF
In final windowing step, copies all non-wf functions.
Definition: sql_executor.h:207
@ CFT_WF_USES_ONLY_ONE_ROW
In windowing step, copies framing window functions that read only one row per frame.
Definition: sql_executor.h:196
@ CFT_WF
Copies all window functions.
Definition: sql_executor.h:211
Common types of the Optimizer, used by optimization and execution.
int plan_idx
This represents the index of a JOIN_TAB/QEP_TAB in an array.
Definition: sql_opt_exec_shared.h:54
@ REF_SLICE_SAVED_BASE
The slice with pointers to columns of table(s), ie., the actual Items.
Definition: sql_opt_exec_shared.h:638
#define NO_PLAN_IDX
undefined index
Definition: sql_opt_exec_shared.h:55
Access paths are a query planning structure that correspond 1:1 to iterators, in that an access path ...
Definition: access_path.h:193
Structure used for index-based lookups.
Definition: sql_opt_exec_shared.h:67
A position of table within a join order.
Definition: sql_select.h:352
Definition: sql_executor.h:489
Item * cond
Definition: sql_executor.h:490
int table_index_to_attach_to
Definition: sql_executor.h:491
Cache invalidator iterators we need to apply, but cannot yet due to outer joins.
Definition: sql_executor.h:500
QEP_TAB * qep_tab
The table whose every (post-join) row invalidates one or more derived lateral tables.
Definition: sql_executor.h:505
plan_idx table_index_to_invalidate
Definition: sql_executor.h:506
Definition: sql_executor.h:80
QEP_TAB * qep_tab
Definition: sql_executor.h:81
ushort null_byte
Definition: sql_executor.h:83
uchar null_bit
Definition: sql_executor.h:84
uint rowid_offset
Definition: sql_executor.h:82
class QEP_TAB * qep_tab
Definition: table.h:1833
bool key_read
If set, the optimizer has found that row retrieval should access index tree only.
Definition: table.h:1758
struct TABLE::@179 reginfo
unsigned int uint
Definition: uca9-dump.cc:75
Window_retrieve_cached_row_reason
Position hints for the frame buffer are saved for these kind of row accesses, cf.
Definition: window.h:65