MySQL 8.0.29
Source Code Documentation
sql_executor.h
Go to the documentation of this file.
1#ifndef SQL_EXECUTOR_INCLUDED
2#define SQL_EXECUTOR_INCLUDED
3
4/* Copyright (c) 2000, 2022, Oracle and/or its affiliates.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License, version 2.0,
8 as published by the Free Software Foundation.
9
10 This program is also distributed with certain software (including
11 but not limited to OpenSSL) that is licensed under separate terms,
12 as designated in a particular file or component or in included license
13 documentation. The authors of MySQL hereby grant you an additional
14 permission to link the program and your derivative works with the
15 separately licensed software that they have included with MySQL.
16
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License, version 2.0, for more details.
21
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
25
26/**
27 @file sql/sql_executor.h
28 Classes for query execution.
29*/
30
31#include <sys/types.h>
32#include <cstring>
33#include <memory>
34#include <string>
35#include <vector>
36
37#include "my_alloc.h"
38#include "my_inttypes.h"
39#include "my_table_map.h"
41#include "sql/sql_lex.h"
42#include "sql/sql_opt_exec_shared.h" // QEP_shared_owner
43#include "sql/table.h"
44#include "sql/temp_table_param.h" // Temp_table_param
45
47class Cached_item;
48class Field;
49class Field_longlong;
50class Filesort;
52class Item;
53class Item_sum;
54class JOIN;
55class JOIN_TAB;
56class KEY;
59class QEP_TAB;
60class RowIterator;
61class THD;
62class Window;
63template <class T>
64class mem_root_deque;
65
67struct AccessPath;
68struct CACHE_FIELD;
69struct POSITION;
70template <class T>
71class List;
72template <typename Element_type>
73class Mem_root_array;
74
75/*
76 Array of pointers to tables whose rowids compose the temporary table
77 record.
78*/
82 ushort null_byte;
84};
85
86/*
87 Temporary table used by semi-join DuplicateElimination strategy
88
89 This consists of the temptable itself and data needed to put records
90 into it. The table's DDL is as follows:
91
92 CREATE TABLE tmptable (col VARCHAR(n) BINARY, PRIMARY KEY(col));
93
94 where the primary key can be replaced with unique constraint if n exceeds
95 the limit (as it is always done for query execution-time temptables).
96
97 The record value is a concatenation of rowids of tables from the join we're
98 executing. If a join table is on the inner side of the outer join, we
99 assume that its rowid can be NULL and provide means to store this rowid in
100 the tuple.
101*/
102
104 public:
108
109 /*
110 is_confluent==true means this is a special case where the temptable record
111 has zero length (and presence of a unique key means that the temptable can
112 have either 0 or 1 records).
113 In this case we don't create the physical temptable but instead record
114 its state in SJ_TMP_TABLE::have_confluent_record.
115 */
117
118 /*
119 When is_confluent==true: the contents of the table (whether it has the
120 record or not).
121 */
123
124 /* table record parameters */
128
129 /* The temporary table itself (NULL means not created yet) */
131
132 /* Pointer to next table (next->start_idx > this->end_idx) */
134 /* Calc hash instead of too long key */
136};
137
138/**
139 Executor structure for the materialized semi-join info, which contains
140 - Description of expressions selected from subquery
141 - The sj-materialization temporary table
142*/
144 public:
147 : sj_nest(sj_nest),
152 table_param(),
153 table(nullptr) {}
155 TABLE_LIST *const sj_nest; ///< Semi-join nest for this materialization
156 const bool is_scan; ///< true if executing a scan, false if lookup
157 const uint table_count; ///< Number of tables in the sj-nest
158 const uint mat_table_index; ///< Index in join_tab for materialized table
159 const uint inner_table_index; ///< Index in join_tab for first inner table
160 Temp_table_param table_param; ///< The temptable and its related info
161 TABLE *table; ///< Reference to temporary table
162};
163
165
166[[nodiscard]] bool copy_fields(Temp_table_param *param, const THD *thd,
167 bool reverse_copy = false);
168
169enum Copy_func_type : int {
170 /**
171 In non-windowing step, copies functions
172 */
174 /**
175 In windowing step, copies framing window function, including
176 all grouping aggregates, e.g. SUM, AVG and FIRST_VALUE, LAST_VALUE.
177 */
179 /**
180 In windowing step, copies non framing window function, e.g.
181 ROW_NUMBER, RANK, DENSE_RANK, except those that are two_pass cf.
182 copy_two_pass_window_functions which are treated separately.
183 */
185 /**
186 In windowing step, copies window functions that need frame cardinality,
187 that is we need to read all rows of a partition before we can compute the
188 wf's value for the the first row in the partition.
189 */
191 /**
192 In windowing step, copies framing window functions that read only one row
193 per frame.
194 */
196 /**
197 In first windowing step, copies non-window functions which do not rely on
198 window functions, i.e. those that have Item::has_wf() == false.
199 */
201 /**
202 In final windowing step, copies all non-wf functions. Must be called after
203 all wfs have been evaluated, as non-wf functions may reference wf,
204 e.g. 1+RANK.
205 */
207 /**
208 Copies all window functions.
209 */
211 /**
212 Copies Item_field only (typically because other functions might depend
213 on those fields).
214 */
216};
217
218bool copy_funcs(Temp_table_param *, const THD *thd,
220
221/**
222 Copy the lookup key into the table ref's key buffer.
223
224 @param thd pointer to the THD object
225 @param table the table to read
226 @param ref information about the index lookup key
227
228 @retval false ref key copied successfully
229 @retval true error dectected during copying of key
230*/
231bool construct_lookup_ref(THD *thd, TABLE *table, TABLE_REF *ref);
232
233/** Help function when we get some an error from the table handler. */
234int report_handler_error(TABLE *table, int error);
235
237
238int do_sj_dups_weedout(THD *thd, SJ_TMP_TABLE *sjtbl);
240
241// Create list for using with tempory table
243 Ref_item_array ref_item_array,
244 mem_root_deque<Item *> *res_fields,
245 size_t added_non_hidden_fields);
246// Create list for using with tempory table
248 THD *thd, Query_block *select,
249 Ref_item_array ref_item_array,
250 mem_root_deque<Item *> *res_fields,
251 size_t added_non_hidden_fields);
252bool prepare_sum_aggregators(Item_sum **func_ptr, bool need_distinct);
253bool setup_sum_funcs(THD *thd, Item_sum **func_ptr);
254bool make_group_fields(JOIN *main_join, JOIN *curr_join);
255bool check_unique_constraint(TABLE *table);
256ulonglong unique_hash(const Field *field, ulonglong *hash);
257int read_const(TABLE *table, TABLE_REF *ref);
258
259class QEP_TAB : public QEP_shared_owner {
260 public:
269 rematerialize(false),
275 m_keyread_optim(false),
276 m_reversed_access(false),
278
279 /// Initializes the object from a JOIN_TAB
280 void init(JOIN_TAB *jt);
281 // Cleans up.
282 void cleanup();
283
284 // Getters and setters
285
288 bool keyread_optim() const { return m_keyread_optim; }
291 }
292 bool reversed_access() const { return m_reversed_access; }
293 void set_reversed_access(bool arg) { m_reversed_access = arg; }
294
295 void set_table(TABLE *t) {
296 m_qs->set_table(t);
297 if (t) t->reginfo.qep_tab = this;
298 }
299
300 /// @returns semijoin strategy for this table.
301 uint get_sj_strategy() const;
302
303 /// Return true if join_tab should perform a FirstMatch action
304 bool do_firstmatch() const { return firstmatch_return != NO_PLAN_IDX; }
305
306 /// Return true if join_tab should perform a LooseScan action
307 bool do_loosescan() const { return loosescan_key_len; }
308
309 /// Return true if join_tab starts a Duplicate Weedout action
310 bool starts_weedout() const { return flush_weedout_table; }
311
312 /// Return true if join_tab finishes a Duplicate Weedout action
313 bool finishes_weedout() const { return check_weed_out_table; }
314
315 /**
316 A helper function that allocates appropriate join cache object and
317 sets next_query_block function of previous tab.
318 */
319 void init_join_cache(JOIN_TAB *join_tab);
320
321 /**
322 @returns query block id for an inner table of materialized semi-join, and
323 0 for all other tables.
324 @note implementation is not efficient (loops over all tables) - use this
325 function only in EXPLAIN.
326 */
327 uint sjm_query_block_id() const;
328
329 /// @returns whether this is doing QS_DYNAMIC_RANGE
330 bool dynamic_range() const {
331 if (!position()) return false; // tmp table
332 return using_dynamic_range;
333 }
334
335 bool use_order() const; ///< Use ordering provided by chosen index?
336
337 /**
338 Construct an access path for reading from this table in the query,
339 using the access method that has been determined previously
340 (e.g., table scan, ref access, optional sort afterwards, etc.).
341 */
343 void push_index_cond(const JOIN_TAB *join_tab, uint keyno,
344 Opt_trace_object *trace_obj);
345
346 /// @return the index used for a table in a QEP
347 uint effective_index() const;
348
349 bool pfs_batch_update(const JOIN *join) const;
350
351 public:
352 /// Pointer to table reference
354
355 /* Variables for semi-join duplicate elimination */
358
359 /*
360 If set, means we should stop join enumeration after we've got the first
361 match and return to the specified join tab. May be PRE_FIRST_PLAN_IDX
362 which means stopping join execution after the first match.
363 */
365
366 /*
367 Length of key tuple (depends on #keyparts used) to use for loose scan.
368 If zero, means that loosescan is not used.
369 */
371
372 /*
373 If doing a LooseScan, this QEP is the first (i.e. "driving")
374 QEP_TAB, and match_tab points to the last QEP_TAB handled by the strategy.
375 match_tab->found_match should be checked to see if the current value group
376 had a match.
377 */
379
380 /// Dependent table functions have to be materialized on each new scan
382
388 };
391
392 /** true <=> remove duplicates on this table. */
394
395 // If we have a query of the type SELECT DISTINCT t1.* FROM t1 JOIN t2
396 // ON ..., (ie., we join in one or more tables that we don't actually
397 // read any columns from), we can stop scanning t2 as soon as we see the
398 // first row. This pattern seems to be a workaround for lack of semijoins
399 // in older versions of MySQL.
401
402 /** HAVING condition for checking prior saving a record into tmp table*/
404
405 // Operation between the previous QEP_TAB and this one.
407 // Regular nested loop.
409
410 // Aggregate (GROUP BY).
412
413 // Various temporary table operations, used at the end of the join.
418
419 // Block-nested loop (rewritten to hash join).
421
422 // Batch key access.
423 OT_BKA
425
426 /* Tmp table info */
428
429 /* Sorting related info */
431
432 /**
433 If we pushed a global ORDER BY down onto this first table, that ORDER BY
434 list will be preseved here.
435 */
437
438 /**
439 Slice number of the ref items array to switch to before reading rows from
440 this table.
441 */
443
444 /// Condition as it was set by the optimizer, used for EXPLAIN.
445 /// m_condition may be overwritten at a later stage.
447
448 /**
449 True if only index is going to be read for this table. This is the
450 optimizer's decision.
451 */
453
454 /**
455 True if reversed scan is used. This is the optimizer's decision.
456 */
458
459 /**
460 Maps of all lateral derived tables which should be refreshed when
461 execution reads a new row from this table.
462 @note that if a LDT depends on t1 and t2, and t2 is after t1 in the plan,
463 then only t2::lateral_derived_tables_depend_on_me gets the map of the
464 LDT, for efficiency (less useless calls to QEP_TAB::refresh_lateral())
465 and clarity in EXPLAIN.
466 */
468
470
471 QEP_TAB(const QEP_TAB &); // not defined
472 QEP_TAB &operator=(const QEP_TAB &); // not defined
473};
474
475bool set_record_buffer(TABLE *table, double expected_rows_to_fetch);
477void update_tmptable_sum_func(Item_sum **func_ptr, TABLE *tmp_table);
478bool has_rollup_result(Item *item);
479bool is_rollup_group_wrapper(Item *item);
481
482/*
483 If a condition cannot be applied right away, for instance because it is a
484 WHERE condition and we're on the right side of an outer join, we have to
485 return it up so that it can be applied on a higher recursion level.
486 This structure represents such a condition.
487 */
490 int table_index_to_attach_to; // -1 means “on the last possible outer join”.
491};
492
493/**
494 Create an AND conjuction of all given items. If there are no items, returns
495 nullptr. If there's only one item, returns that item.
496 */
498
501 const std::vector<Item *> &conditions, THD *thd);
502
503void SplitConditions(Item *condition, QEP_TAB *current_table,
504 std::vector<Item *> *predicates_below_join,
505 std::vector<PendingCondition> *predicates_above_join,
506 std::vector<PendingCondition> *join_conditions);
507
508/**
509 For a MATERIALIZE access path, move any non-basic iterators (e.g. sorts and
510 filters) from table_path to above the path, for easier EXPLAIN and generally
511 simpler structure. Note the assert in CreateIteratorFromAccessPath() that we
512 succeeded. (ALTERNATIVE counts as a basic iterator in this regard.)
513
514 We do this by finding the second-bottommost access path, and inserting our
515 materialize node as its child. The bottommost one becomes the actual table
516 access path.
517
518 If a ZERO_ROWS access path is materialized, we simply replace the MATERIALIZE
519 path with the ZERO_ROWS path, since there is nothing to materialize.
520 */
522
524 AccessPath *table_path);
526 THD *thd, TABLE_LIST *table_ref, TABLE *table, bool rematerialize,
527 Mem_root_array<const AccessPath *> *invalidators, bool need_rowid,
528 AccessPath *table_path);
529
530void ConvertItemsToCopy(const mem_root_deque<Item *> &items, Field **fields,
531 Temp_table_param *param);
532std::string RefToString(const TABLE_REF &ref, const KEY *key,
533 bool include_nulls);
534
536
537/**
538 Split AND conditions into their constituent parts, recursively.
539 Conditions that are not AND conditions are appended unchanged onto
540 condition_parts. E.g. if you have ((a AND b) AND c), condition_parts
541 will contain [a, b, c], plus whatever it contained before the call.
542 */
543void ExtractConditions(Item *condition,
544 Mem_root_array<Item *> *condition_parts);
545
547 AccessPath *range_scan,
548 TABLE_LIST *table_ref, POSITION *position,
549 bool count_examined_rows);
550
551/**
552 Creates an iterator for the given table, then calls Init() on the resulting
553 iterator. Unlike create_table_iterator(), this can create iterators for sort
554 buffer results (which are set in the TABLE object during query execution).
555 Returns nullptr on failure.
556 */
558 THD *thd, TABLE *table, AccessPath *range_scan, TABLE_LIST *table_ref,
559 POSITION *position, bool ignore_not_found_rows, bool count_examined_rows);
560
561/**
562 A short form for when there's no range scan, recursive CTEs or cost
563 information; just a unique_result or a simple table scan. Normally, you should
564 prefer just instantiating an iterator yourself -- this is for legacy use only.
565 */
567 THD *thd, TABLE *table, bool ignore_not_found_rows,
568 bool count_examined_rows) {
569 return init_table_iterator(thd, table, nullptr, nullptr, nullptr,
570 ignore_not_found_rows, count_examined_rows);
571}
572
573#endif /* SQL_EXECUTOR_INCLUDED */
An iterator that helps invalidating caches.
Definition: composite_iterators.h:390
This is used for segregating rows in groups (e.g.
Definition: item.h:6188
Definition: field.h:2352
Definition: field.h:573
Sorting related info.
Definition: filesort.h:51
FollowTailIterator is a special version of TableScanIterator that is used as part of WITH RECURSIVE q...
Definition: basic_row_iterators.h:414
Class Item_sum is the base class used for special expressions that SQL calls 'set functions'.
Definition: item_sum.h:398
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:802
Query optimization plan node.
Definition: sql_select.h:598
Definition: sql_optimizer.h:125
Definition: key.h:112
Definition: sql_list.h:433
A typesafe replacement for DYNAMIC_ARRAY.
Definition: mem_root_array.h:421
The iterator actually doing the reads from the inner table during BKA.
Definition: bka_iterator.h:263
A JSON object (unordered set of key/value pairs).
Definition: opt_trace.h:801
Definition: sql_executor.h:259
uint loosescan_key_len
Definition: sql_executor.h:370
bool dynamic_range() const
Definition: sql_executor.h:330
Setup_func materialize_table
Definition: sql_executor.h:389
void set_reversed_access(bool arg)
Definition: sql_executor.h:293
Item * m_condition_optim
Condition as it was set by the optimizer, used for EXPLAIN.
Definition: sql_executor.h:446
bool rematerialize
Dependent table functions have to be materialized on each new scan.
Definition: sql_executor.h:381
bool keyread_optim() const
Definition: sql_executor.h:288
TABLE_LIST * table_ref
Pointer to table reference.
Definition: sql_executor.h:353
Filesort * filesort
Definition: sql_executor.h:430
bool reversed_access() const
Definition: sql_executor.h:292
void set_table(TABLE *t)
Definition: sql_executor.h:295
uint ref_item_slice
Slice number of the ref items array to switch to before reading rows from this table.
Definition: sql_executor.h:442
bool m_reversed_access
True if reversed scan is used.
Definition: sql_executor.h:457
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:467
bool needs_duplicate_removal
true <=> remove duplicates on this table.
Definition: sql_executor.h:393
plan_idx firstmatch_return
Definition: sql_executor.h:364
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:304
ORDER * filesort_pushed_order
If we pushed a global ORDER BY down onto this first table, that ORDER BY list will be preseved here.
Definition: sql_executor.h:436
Setup_func
Definition: sql_executor.h:383
@ NO_SETUP
Definition: sql_executor.h:384
@ MATERIALIZE_TABLE_FUNCTION
Definition: sql_executor.h:385
@ MATERIALIZE_SEMIJOIN
Definition: sql_executor.h:387
@ MATERIALIZE_DERIVED
Definition: sql_executor.h:386
QEP_TAB()
Definition: sql_executor.h:261
Item * condition_optim() const
Definition: sql_executor.h:286
QEP_TAB & operator=(const QEP_TAB &)
bool not_used_in_distinct
Definition: sql_executor.h:400
bool starts_weedout() const
Return true if join_tab starts a Duplicate Weedout action.
Definition: sql_executor.h:310
bool m_keyread_optim
True if only index is going to be read for this table.
Definition: sql_executor.h:452
bool using_dynamic_range
Definition: sql_executor.h:390
bool finishes_weedout() const
Return true if join_tab finishes a Duplicate Weedout action.
Definition: sql_executor.h:313
bool do_loosescan() const
Return true if join_tab should perform a LooseScan action.
Definition: sql_executor.h:307
Item * having
HAVING condition for checking prior saving a record into tmp table.
Definition: sql_executor.h:403
SJ_TMP_TABLE * flush_weedout_table
Definition: sql_executor.h:356
Temp_table_param * tmp_table_param
Definition: sql_executor.h:427
void set_condition_optim()
Definition: sql_executor.h:287
plan_idx match_tab
Definition: sql_executor.h:378
SJ_TMP_TABLE * check_weed_out_table
Definition: sql_executor.h:357
enum_op_type
Definition: sql_executor.h:406
@ OT_MATERIALIZE
Definition: sql_executor.h:414
@ OT_BKA
Definition: sql_executor.h:423
@ OT_AGGREGATE_INTO_TMP_TABLE
Definition: sql_executor.h:416
@ OT_AGGREGATE
Definition: sql_executor.h:411
@ OT_BNL
Definition: sql_executor.h:420
@ OT_AGGREGATE_THEN_MATERIALIZE
Definition: sql_executor.h:415
@ OT_WINDOWING_FUNCTION
Definition: sql_executor.h:417
@ OT_NONE
Definition: sql_executor.h:408
Mem_root_array< const AccessPath * > * invalidators
Definition: sql_executor.h:469
QEP_TAB(const QEP_TAB &)
void set_keyread_optim()
Definition: sql_executor.h:289
Owner of a QEP_shared; parent of JOIN_TAB and QEP_TAB.
Definition: sql_opt_exec_shared.h:469
JOIN * join() const
Definition: sql_opt_exec_shared.h:482
TABLE * table() const
Definition: sql_opt_exec_shared.h:495
QEP_shared * m_qs
Definition: sql_opt_exec_shared.h:565
Item * condition() const
Definition: sql_opt_exec_shared.h:517
POSITION * position() const
Definition: sql_opt_exec_shared.h:496
void set_table(TABLE *t)
Definition: sql_opt_exec_shared.h:268
This class represents a query block, aka a query specification, which is a query consisting of a SELE...
Definition: sql_lex.h:1124
A context for reading through a single table using a chosen access method: index read,...
Definition: row_iterator.h:60
Definition: sql_executor.h:103
uint rowid_len
Definition: sql_executor.h:127
TABLE * tmp_table
Definition: sql_executor.h:130
SJ_TMP_TABLE_TAB * tabs
Definition: sql_executor.h:106
SJ_TMP_TABLE * next
Definition: sql_executor.h:133
uint null_bits
Definition: sql_executor.h:125
SJ_TMP_TABLE_TAB * tabs_end
Definition: sql_executor.h:107
bool have_confluent_row
Definition: sql_executor.h:122
SJ_TMP_TABLE()
Definition: sql_executor.h:105
uint null_bytes
Definition: sql_executor.h:126
bool is_confluent
Definition: sql_executor.h:116
Field_longlong * hash_field
Definition: sql_executor.h:135
Executor structure for the materialized semi-join info, which contains.
Definition: sql_executor.h:143
const bool is_scan
true if executing a scan, false if lookup
Definition: sql_executor.h:156
TABLE * table
Reference to temporary table.
Definition: sql_executor.h:161
const uint inner_table_index
Index in join_tab for first inner table.
Definition: sql_executor.h:159
const uint mat_table_index
Index in join_tab for materialized table.
Definition: sql_executor.h:158
Temp_table_param table_param
The temptable and its related info.
Definition: sql_executor.h:160
TABLE_LIST *const sj_nest
Semi-join nest for this materialization.
Definition: sql_executor.h:155
Semijoin_mat_exec(TABLE_LIST *sj_nest, bool is_scan, uint table_count, uint mat_table_index, uint inner_table_index)
Definition: sql_executor.h:145
~Semijoin_mat_exec()=default
const uint table_count
Number of tables in the sj-nest.
Definition: sql_executor.h:157
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:945
Object containing parameters used when creating and using temporary tables.
Definition: temp_table_param.h:98
Represents the (explicit) window of a SQL 2003 section 7.11 <window clause>, or the implicit (inlined...
Definition: window.h:104
A (partial) implementation of std::deque allocating its blocks on a MEM_ROOT.
Definition: mem_root_deque.h:109
char * pos
Definition: do_ctype.cc:76
Fido Client Authentication nullptr
Definition: fido_client_plugin.cc:221
Item * unwrap_rollup_group(Item *item)
Definition: sql_executor.cc:336
void init_tmptable_sum_functions(Item_sum **func_ptr)
Definition: sql_executor.cc:396
bool pfs_batch_update(const JOIN *join) const
Definition: sql_executor.cc:4446
bool is_rollup_group_wrapper(Item *item)
Definition: sql_executor.cc:330
bool setup_sum_funcs(THD *thd, Item_sum **func_ptr)
Call setup() for all sum functions.
Definition: sql_executor.cc:387
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:428
void ExtractConditions(Item *condition, Mem_root_array< Item * > *condition_parts)
Split AND conditions into their constituent parts, recursively.
Definition: sql_executor.cc:706
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:304
std::string RefToString(const TABLE_REF &ref, const KEY *key, bool include_nulls)
Definition: sql_executor.cc:129
int join_read_const_table(JOIN_TAB *tab, POSITION *pos)
Reads content of constant table.
Definition: sql_executor.cc:3329
ulonglong unique_hash(const Field *field, ulonglong *hash)
Generate hash for a field.
Definition: sql_executor.cc:3775
int do_sj_dups_weedout(THD *thd, SJ_TMP_TABLE *sjtbl)
SemiJoinDuplicateElimination: Weed out duplicate row combinations.
Definition: sql_executor.cc:3229
int report_handler_error(TABLE *table, int error)
Help function when we get some an error from the table handler.
Definition: sql_executor.cc:3302
void setup_tmptable_write_func(QEP_TAB *tab, Opt_trace_object *trace)
Setup write_func of QEP_tmp_table object.
Definition: sql_executor.cc:517
int update_item_cache_if_changed(List< Cached_item > &list)
Definition: sql_executor.cc:3974
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:3547
bool use_order() const
Use ordering provided by chosen index?
Definition: sql_executor.cc:3521
AccessPath * MoveCompositeIteratorsFromTablePath(AccessPath *path)
For a MATERIALIZE access path, move any non-basic iterators (e.g.
Definition: sql_executor.cc:1406
AccessPath * GetAccessPathForDerivedTable(THD *thd, QEP_TAB *qep_tab, AccessPath *table_path)
Definition: sql_executor.cc:1399
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:4221
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:4084
bool check_unique_constraint(TABLE *table)
Check unique_constraint.
Definition: sql_executor.cc:3865
int read_const(TABLE *table, TABLE_REF *ref)
Definition: sql_executor.cc:3460
bool make_group_fields(JOIN *main_join, JOIN *curr_join)
allocate group fields or take prepared (cached).
Definition: sql_executor.cc:3932
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:404
Item * CreateConjunction(List< Item > *items)
Create an AND conjuction of all given items.
Definition: sql_executor.cc:745
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:653
bool construct_lookup_ref(THD *thd, TABLE *table, TABLE_REF *ref)
Copy the lookup key into the table ref's key buffer.
Definition: sql_executor.cc:3892
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:4021
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:946
bool prepare_sum_aggregators(Item_sum **func_ptr, bool need_distinct)
Definition: sql_executor.cc:361
void init(JOIN_TAB *jt)
Initializes the object from a JOIN_TAB.
Definition: sql_optimizer.cc:1274
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:3036
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:2708
void cleanup()
Definition: sql_select.cc:3334
uint sjm_query_block_id() const
Definition: sql_select.cc:3390
uint effective_index() const
Return the index used for a table in a QEP.
Definition: sql_optimizer.cc:1301
uint get_sj_strategy() const
Definition: sql_optimizer.cc:1281
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:488
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:55
unsigned char uchar
Definition: my_inttypes.h:51
uint64_t qep_tab_map
Definition: my_table_map.h:31
Log error(cerr, "ERROR")
static char * path
Definition: mysqldump.cc:130
PT & ref(PT *tp)
Definition: tablespace_impl.cc:358
required string key
Definition: replication_asynchronous_connection_failover.proto:59
required string type
Definition: replication_group_member_actions.proto:33
AccessPath * create_table_access_path(THD *thd, TABLE *table, AccessPath *range_scan, TABLE_LIST *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:4499
bool MaterializeIsDoingDeduplication(TABLE *table)
(end of group Query_Executor)
Definition: sql_executor.cc:4464
unique_ptr_destroy_only< RowIterator > PossiblyAttachFilterIterator(unique_ptr_destroy_only< RowIterator > iterator, const std::vector< Item * > &conditions, THD *thd)
Copy_func_type
Definition: sql_executor.h:169
@ CFT_HAS_NO_WF
In first windowing step, copies non-window functions which do not rely on window functions,...
Definition: sql_executor.h:200
@ CFT_WF_NON_FRAMING
In windowing step, copies non framing window function, e.g.
Definition: sql_executor.h:184
@ 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:190
@ CFT_WF_FRAMING
In windowing step, copies framing window function, including all grouping aggregates,...
Definition: sql_executor.h:178
@ CFT_ALL
In non-windowing step, copies functions.
Definition: sql_executor.h:173
@ CFT_FIELDS
Copies Item_field only (typically because other functions might depend on those fields).
Definition: sql_executor.h:215
@ CFT_HAS_WF
In final windowing step, copies all non-wf functions.
Definition: sql_executor.h:206
@ CFT_WF_USES_ONLY_ONE_ROW
In windowing step, copies framing window functions that read only one row per frame.
Definition: sql_executor.h:195
@ CFT_WF
Copies all window functions.
Definition: sql_executor.h:210
unique_ptr_destroy_only< RowIterator > init_table_iterator(THD *thd, TABLE *table, AccessPath *range_scan, TABLE_LIST *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:4519
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)
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:53
@ REF_SLICE_SAVED_BASE
The slice with pointers to columns of table(s), ie., the actual Items.
Definition: sql_opt_exec_shared.h:629
#define NO_PLAN_IDX
undefined index
Definition: sql_opt_exec_shared.h:54
Access paths are a query planning structure that correspond 1:1 to iterators, in that an access path ...
Definition: access_path.h:188
Definition: table.h:279
A position of table within a join order.
Definition: sql_select.h:351
Definition: sql_executor.h:488
Item * cond
Definition: sql_executor.h:489
int table_index_to_attach_to
Definition: sql_executor.h:490
Definition: sql_executor.h:79
QEP_TAB * qep_tab
Definition: sql_executor.h:80
ushort null_byte
Definition: sql_executor.h:82
uchar null_bit
Definition: sql_executor.h:83
uint rowid_offset
Definition: sql_executor.h:81
Definition: table.h:2684
Definition: sql_opt_exec_shared.h:58
Definition: table.h:1394
class QEP_TAB * qep_tab
Definition: table.h:1736
struct TABLE::@174 reginfo
bool key_read
If set, the optimizer has found that row retrieval should access index tree only.
Definition: table.h:1661
unsigned int uint
Definition: uca-dump.cc:29
Window_retrieve_cached_row_reason
Position hints for the frame buffer are saved for these kind of row accesses, cf.
Definition: window.h:64