MySQL  8.0.27
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, 2021, 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 
33 #include <cstring>
34 #include <memory>
35 #include <string>
36 #include <vector>
37 
38 #include "my_alloc.h"
39 #include "my_inttypes.h"
40 #include "my_table_map.h"
41 #include "sql/row_iterator.h"
42 #include "sql/sql_lex.h"
43 #include "sql/sql_opt_exec_shared.h" // QEP_shared_owner
44 #include "sql/table.h"
45 #include "sql/temp_table_param.h" // Temp_table_param
46 
48 class Cached_item;
49 class Field;
50 class Field_longlong;
51 class Filesort;
52 class FollowTailIterator;
53 class Item;
54 class Item_sum;
55 class JOIN;
56 class JOIN_TAB;
57 class KEY;
59 class Opt_trace_object;
60 class QEP_TAB;
61 class QUICK_SELECT_I;
62 class THD;
63 class Window;
65 struct AccessPath;
66 struct CACHE_FIELD;
67 struct POSITION;
68 template <class T>
69 class List;
70 template <typename Element_type>
71 class Mem_root_array;
72 
73 /*
74  Array of pointers to tables whose rowids compose the temporary table
75  record.
76 */
80  ushort null_byte;
82 };
83 
84 /*
85  Temporary table used by semi-join DuplicateElimination strategy
86 
87  This consists of the temptable itself and data needed to put records
88  into it. The table's DDL is as follows:
89 
90  CREATE TABLE tmptable (col VARCHAR(n) BINARY, PRIMARY KEY(col));
91 
92  where the primary key can be replaced with unique constraint if n exceeds
93  the limit (as it is always done for query execution-time temptables).
94 
95  The record value is a concatenation of rowids of tables from the join we're
96  executing. If a join table is on the inner side of the outer join, we
97  assume that its rowid can be NULL and provide means to store this rowid in
98  the tuple.
99 */
100 
102  public:
106 
107  /*
108  is_confluent==true means this is a special case where the temptable record
109  has zero length (and presence of a unique key means that the temptable can
110  have either 0 or 1 records).
111  In this case we don't create the physical temptable but instead record
112  its state in SJ_TMP_TABLE::have_confluent_record.
113  */
115 
116  /*
117  When is_confluent==true: the contents of the table (whether it has the
118  record or not).
119  */
121 
122  /* table record parameters */
126 
127  /* The temporary table itself (NULL means not created yet) */
129 
130  /* Pointer to next table (next->start_idx > this->end_idx) */
132  /* Calc hash instead of too long key */
134 };
135 
136 /**
137  Executor structure for the materialized semi-join info, which contains
138  - Description of expressions selected from subquery
139  - The sj-materialization temporary table
140 */
142  public:
145  : sj_nest(sj_nest),
146  is_scan(is_scan),
150  table_param(),
151  table(nullptr) {}
152  ~Semijoin_mat_exec() = default;
153  TABLE_LIST *const sj_nest; ///< Semi-join nest for this materialization
154  const bool is_scan; ///< true if executing a scan, false if lookup
155  const uint table_count; ///< Number of tables in the sj-nest
156  const uint mat_table_index; ///< Index in join_tab for materialized table
157  const uint inner_table_index; ///< Index in join_tab for first inner table
158  Temp_table_param table_param; ///< The temptable and its related info
159  TABLE *table; ///< Reference to temporary table
160 };
161 
163 
164 [[nodiscard]] bool copy_fields(Temp_table_param *param, const THD *thd,
165  bool reverse_copy = false);
166 
167 enum Copy_func_type : int {
168  /**
169  In non-windowing step, copies functions
170  */
172  /**
173  In windowing step, copies framing window function, including
174  all grouping aggregates, e.g. SUM, AVG and FIRST_VALUE, LAST_VALUE.
175  */
177  /**
178  In windowing step, copies non framing window function, e.g.
179  ROW_NUMBER, RANK, DENSE_RANK, except those that are two_pass cf.
180  copy_two_pass_window_functions which are treated separately.
181  */
183  /**
184  In windowing step, copies window functions that need frame cardinality,
185  that is we need to read all rows of a partition before we can compute the
186  wf's value for the the first row in the partition.
187  */
189  /**
190  In windowing step, copies framing window functions that read only one row
191  per frame.
192  */
194  /**
195  In first windowing step, copies non-window functions which do not rely on
196  window functions, i.e. those that have Item::has_wf() == false.
197  */
199  /**
200  In final windowing step, copies all non-wf functions. Must be called after
201  all wfs have been evaluated, as non-wf functions may reference wf,
202  e.g. 1+RANK.
203  */
205  /**
206  Copies all window functions.
207  */
209  /**
210  Copies Item_field only (typically because other functions might depend
211  on those fields).
212  */
214 };
215 
216 bool copy_funcs(Temp_table_param *, const THD *thd,
218 
219 /**
220  Copy the lookup key into the table ref's key buffer.
221 
222  @param thd pointer to the THD object
223  @param table the table to read
224  @param ref information about the index lookup key
225 
226  @retval false ref key copied successfully
227  @retval true error dectected during copying of key
228 */
229 bool construct_lookup_ref(THD *thd, TABLE *table, TABLE_REF *ref);
230 
231 /** Help function when we get some an error from the table handler. */
232 int report_handler_error(TABLE *table, int error);
233 
235 
236 int do_sj_dups_weedout(THD *thd, SJ_TMP_TABLE *sjtbl);
238 
239 // Create list for using with tempory table
241  Ref_item_array ref_item_array,
242  mem_root_deque<Item *> *res_fields,
243  size_t added_non_hidden_fields);
244 // Create list for using with tempory table
246  THD *thd, Query_block *select,
247  Ref_item_array ref_item_array,
248  mem_root_deque<Item *> *res_fields,
249  size_t added_non_hidden_fields);
250 bool prepare_sum_aggregators(Item_sum **func_ptr, bool need_distinct);
251 bool setup_sum_funcs(THD *thd, Item_sum **func_ptr);
252 bool make_group_fields(JOIN *main_join, JOIN *curr_join);
253 bool check_unique_constraint(TABLE *table);
254 ulonglong unique_hash(const Field *field, ulonglong *hash);
255 
256 class QEP_TAB : public QEP_shared_owner {
257  public:
259  : QEP_shared_owner(),
266  rematerialize(false),
267  not_used_in_distinct(false),
268  having(nullptr),
270  filesort(nullptr),
272  m_keyread_optim(false),
273  m_reversed_access(false),
275 
276  /// Initializes the object from a JOIN_TAB
277  void init(JOIN_TAB *jt);
278  // Cleans up.
279  void cleanup();
280 
281  // Getters and setters
282 
285  bool keyread_optim() const { return m_keyread_optim; }
287  if (table()) m_keyread_optim = table()->key_read;
288  }
289  bool reversed_access() const { return m_reversed_access; }
290  void set_reversed_access(bool arg) { m_reversed_access = arg; }
291 
292  void set_table(TABLE *t) {
293  m_qs->set_table(t);
294  if (t) t->reginfo.qep_tab = this;
295  }
296 
297  /// @returns semijoin strategy for this table.
298  uint get_sj_strategy() const;
299 
300  /// Return true if join_tab should perform a FirstMatch action
301  bool do_firstmatch() const { return firstmatch_return != NO_PLAN_IDX; }
302 
303  /// Return true if join_tab should perform a LooseScan action
304  bool do_loosescan() const { return loosescan_key_len; }
305 
306  /// Return true if join_tab starts a Duplicate Weedout action
307  bool starts_weedout() const { return flush_weedout_table; }
308 
309  /// Return true if join_tab finishes a Duplicate Weedout action
310  bool finishes_weedout() const { return check_weed_out_table; }
311 
312  /**
313  A helper function that allocates appropriate join cache object and
314  sets next_query_block function of previous tab.
315  */
316  void init_join_cache(JOIN_TAB *join_tab);
317 
318  /**
319  @returns query block id for an inner table of materialized semi-join, and
320  0 for all other tables.
321  @note implementation is not efficient (loops over all tables) - use this
322  function only in EXPLAIN.
323  */
324  uint sjm_query_block_id() const;
325 
326  /// @returns whether this is doing QS_DYNAMIC_RANGE
327  bool dynamic_range() const {
328  if (!position()) return false; // tmp table
329  return using_dynamic_range;
330  }
331 
332  bool use_order() const; ///< Use ordering provided by chosen index?
333 
334  /**
335  Construct an access path for reading from this table in the query,
336  using the access method that has been determined previously
337  (e.g., table scan, ref access, optional sort afterwards, etc.).
338  */
340  void push_index_cond(const JOIN_TAB *join_tab, uint keyno,
341  Opt_trace_object *trace_obj);
342 
343  /// @return the index used for a table in a QEP
344  uint effective_index() const;
345 
346  bool pfs_batch_update(const JOIN *join) const;
347 
348  public:
349  /// Pointer to table reference
351 
352  /* Variables for semi-join duplicate elimination */
355 
356  /*
357  If set, means we should stop join enumeration after we've got the first
358  match and return to the specified join tab. May be PRE_FIRST_PLAN_IDX
359  which means stopping join execution after the first match.
360  */
362 
363  /*
364  Length of key tuple (depends on #keyparts used) to use for loose scan.
365  If zero, means that loosescan is not used.
366  */
368 
369  /*
370  If doing a LooseScan, this QEP is the first (i.e. "driving")
371  QEP_TAB, and match_tab points to the last QEP_TAB handled by the strategy.
372  match_tab->found_match should be checked to see if the current value group
373  had a match.
374  */
376 
377  /// Dependent table functions have to be materialized on each new scan
379 
380  enum Setup_func {
385  };
387  bool using_dynamic_range = false;
388 
389  /** true <=> remove duplicates on this table. */
391 
392  // If we have a query of the type SELECT DISTINCT t1.* FROM t1 JOIN t2
393  // ON ..., (ie., we join in one or more tables that we don't actually
394  // read any columns from), we can stop scanning t2 as soon as we see the
395  // first row. This pattern seems to be a workaround for lack of semijoins
396  // in older versions of MySQL.
398 
399  /** HAVING condition for checking prior saving a record into tmp table*/
401 
402  // Operation between the previous QEP_TAB and this one.
404  // Regular nested loop.
406 
407  // Aggregate (GROUP BY).
409 
410  // Various temporary table operations, used at the end of the join.
415 
416  // Block-nested loop (rewritten to hash join).
418 
419  // Batch key access.
420  OT_BKA
422 
423  /* Tmp table info */
425 
426  /* Sorting related info */
428 
429  /**
430  If we pushed a global ORDER BY down onto this first table, that ORDER BY
431  list will be preseved here.
432  */
434 
435  /**
436  Slice number of the ref items array to switch to before reading rows from
437  this table.
438  */
440 
441  /// Condition as it was set by the optimizer, used for EXPLAIN.
442  /// m_condition may be overwritten at a later stage.
444 
445  /**
446  True if only index is going to be read for this table. This is the
447  optimizer's decision.
448  */
450 
451  /**
452  True if reversed scan is used. This is the optimizer's decision.
453  */
455 
456  /**
457  Maps of all lateral derived tables which should be refreshed when
458  execution reads a new row from this table.
459  @note that if a LDT depends on t1 and t2, and t2 is after t1 in the plan,
460  then only t2::lateral_derived_tables_depend_on_me gets the map of the
461  LDT, for efficiency (less useless calls to QEP_TAB::refresh_lateral())
462  and clarity in EXPLAIN.
463  */
465 
467 
468  QEP_TAB(const QEP_TAB &); // not defined
469  QEP_TAB &operator=(const QEP_TAB &); // not defined
470 };
471 
472 bool set_record_buffer(TABLE *table, double expected_rows_to_fetch);
473 void init_tmptable_sum_functions(Item_sum **func_ptr);
474 void update_tmptable_sum_func(Item_sum **func_ptr, TABLE *tmp_table);
475 bool has_rollup_result(Item *item);
476 bool is_rollup_group_wrapper(Item *item);
477 bool is_rollup_sum_wrapper(Item *item);
479 
480 /*
481  If a condition cannot be applied right away, for instance because it is a
482  WHERE condition and we're on the right side of an outer join, we have to
483  return it up so that it can be applied on a higher recursion level.
484  This structure represents such a condition.
485  */
488  int table_index_to_attach_to; // -1 means “on the last possible outer join”.
489 };
490 
491 /**
492  Create an AND conjuction of all given items. If there are no items, returns
493  nullptr. If there's only one item, returns that item.
494  */
496 
499  const std::vector<Item *> &conditions, THD *thd);
500 
501 void SplitConditions(Item *condition, QEP_TAB *current_table,
502  std::vector<Item *> *predicates_below_join,
503  std::vector<PendingCondition> *predicates_above_join,
504  std::vector<PendingCondition> *join_conditions);
505 
506 /**
507  For a MATERIALIZE access path, move any non-basic iterators (e.g. sorts and
508  filters) from table_path to above the path, for easier EXPLAIN and generally
509  simpler structure. Note the assert in CreateIteratorFromAccessPath() that we
510  succeeded. (ALTERNATIVE counts as a basic iterator in this regard.)
511 
512  We do this by finding the second-bottommost access path, and inserting our
513  materialize node as it child. The bottommost one becomes the actual table
514  access path.
515  */
517 
519  AccessPath *table_path);
521  THD *thd, TABLE_LIST *table_ref, TABLE *table, bool rematerialize,
522  Mem_root_array<const AccessPath *> *invalidators, bool need_rowid,
523  AccessPath *table_path);
524 
525 void ConvertItemsToCopy(const mem_root_deque<Item *> &items, Field **fields,
526  Temp_table_param *param);
527 std::string RefToString(const TABLE_REF &ref, const KEY *key,
528  bool include_nulls);
529 
531 
532 /**
533  Split AND conditions into their constituent parts, recursively.
534  Conditions that are not AND conditions are appended unchanged onto
535  condition_parts. E.g. if you have ((a AND b) AND c), condition_parts
536  will contain [a, b, c], plus whatever it contained before the call.
537  */
538 void ExtractConditions(Item *condition,
539  Mem_root_array<Item *> *condition_parts);
540 
541 #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:6136
Definition: field.h:2365
Definition: field.h:590
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:465
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:597
Definition: sql_optimizer.h:125
Definition: key.h:112
Definition: sql_list.h:431
A typesafe replacement for DYNAMIC_ARRAY.
Definition: mem_root_array.h:418
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:256
uint loosescan_key_len
Definition: sql_executor.h:367
bool dynamic_range() const
Definition: sql_executor.h:327
Item * condition_optim() const
Definition: sql_executor.h:283
Setup_func materialize_table
Definition: sql_executor.h:386
void set_reversed_access(bool arg)
Definition: sql_executor.h:290
Item * m_condition_optim
Condition as it was set by the optimizer, used for EXPLAIN.
Definition: sql_executor.h:443
bool rematerialize
Dependent table functions have to be materialized on each new scan.
Definition: sql_executor.h:378
bool keyread_optim() const
Definition: sql_executor.h:285
TABLE_LIST * table_ref
Pointer to table reference.
Definition: sql_executor.h:350
Filesort * filesort
Definition: sql_executor.h:427
bool reversed_access() const
Definition: sql_executor.h:289
void set_table(TABLE *t)
Definition: sql_executor.h:292
uint ref_item_slice
Slice number of the ref items array to switch to before reading rows from this table.
Definition: sql_executor.h:439
bool m_reversed_access
True if reversed scan is used.
Definition: sql_executor.h:454
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:464
bool needs_duplicate_removal
true <=> remove duplicates on this table.
Definition: sql_executor.h:390
plan_idx firstmatch_return
Definition: sql_executor.h:361
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:301
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:433
Setup_func
Definition: sql_executor.h:380
@ NO_SETUP
Definition: sql_executor.h:381
@ MATERIALIZE_TABLE_FUNCTION
Definition: sql_executor.h:382
@ MATERIALIZE_SEMIJOIN
Definition: sql_executor.h:384
@ MATERIALIZE_DERIVED
Definition: sql_executor.h:383
QEP_TAB()
Definition: sql_executor.h:258
bool not_used_in_distinct
Definition: sql_executor.h:397
bool starts_weedout() const
Return true if join_tab starts a Duplicate Weedout action.
Definition: sql_executor.h:307
bool m_keyread_optim
True if only index is going to be read for this table.
Definition: sql_executor.h:449
bool using_dynamic_range
Definition: sql_executor.h:387
bool finishes_weedout() const
Return true if join_tab finishes a Duplicate Weedout action.
Definition: sql_executor.h:310
bool do_loosescan() const
Return true if join_tab should perform a LooseScan action.
Definition: sql_executor.h:304
Item * having
HAVING condition for checking prior saving a record into tmp table.
Definition: sql_executor.h:400
SJ_TMP_TABLE * flush_weedout_table
Definition: sql_executor.h:353
Temp_table_param * tmp_table_param
Definition: sql_executor.h:424
void set_condition_optim()
Definition: sql_executor.h:284
plan_idx match_tab
Definition: sql_executor.h:375
SJ_TMP_TABLE * check_weed_out_table
Definition: sql_executor.h:354
enum_op_type
Definition: sql_executor.h:403
@ OT_MATERIALIZE
Definition: sql_executor.h:411
@ OT_BKA
Definition: sql_executor.h:420
@ OT_AGGREGATE_INTO_TMP_TABLE
Definition: sql_executor.h:413
@ OT_AGGREGATE
Definition: sql_executor.h:408
@ OT_BNL
Definition: sql_executor.h:417
@ OT_AGGREGATE_THEN_MATERIALIZE
Definition: sql_executor.h:412
@ OT_WINDOWING_FUNCTION
Definition: sql_executor.h:414
@ OT_NONE
Definition: sql_executor.h:405
Mem_root_array< const AccessPath * > * invalidators
Definition: sql_executor.h:466
QEP_TAB & operator=(const QEP_TAB &)
QEP_TAB(const QEP_TAB &)
void set_keyread_optim()
Definition: sql_executor.h:286
Owner of a QEP_shared; parent of JOIN_TAB and QEP_TAB.
Definition: sql_opt_exec_shared.h:470
Item * condition() const
Definition: sql_opt_exec_shared.h:515
QEP_shared * m_qs
Definition: sql_opt_exec_shared.h:563
JOIN * join() const
Definition: sql_opt_exec_shared.h:483
POSITION * position() const
Definition: sql_opt_exec_shared.h:494
TABLE * table() const
Definition: sql_opt_exec_shared.h:493
void set_table(TABLE *t)
Definition: sql_opt_exec_shared.h:270
Definition: range_optimizer.h:221
This class represents a query block, aka a query specification, which is a query consisting of a SELE...
Definition: sql_lex.h:1123
Definition: sql_executor.h:101
uint rowid_len
Definition: sql_executor.h:125
TABLE * tmp_table
Definition: sql_executor.h:128
SJ_TMP_TABLE_TAB * tabs
Definition: sql_executor.h:104
SJ_TMP_TABLE * next
Definition: sql_executor.h:131
uint null_bits
Definition: sql_executor.h:123
SJ_TMP_TABLE_TAB * tabs_end
Definition: sql_executor.h:105
bool have_confluent_row
Definition: sql_executor.h:120
SJ_TMP_TABLE()
Definition: sql_executor.h:103
uint null_bytes
Definition: sql_executor.h:124
bool is_confluent
Definition: sql_executor.h:114
Field_longlong * hash_field
Definition: sql_executor.h:133
Executor structure for the materialized semi-join info, which contains.
Definition: sql_executor.h:141
const bool is_scan
true if executing a scan, false if lookup
Definition: sql_executor.h:154
TABLE * table
Reference to temporary table.
Definition: sql_executor.h:159
const uint inner_table_index
Index in join_tab for first inner table.
Definition: sql_executor.h:157
const uint mat_table_index
Index in join_tab for materialized table.
Definition: sql_executor.h:156
Temp_table_param table_param
The temptable and its related info.
Definition: sql_executor.h:158
TABLE_LIST *const sj_nest
Semi-join nest for this materialization.
Definition: sql_executor.h:153
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:143
~Semijoin_mat_exec()=default
const uint table_count
Number of tables in the sj-nest.
Definition: sql_executor.h:155
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:821
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:94
Dialog Client Authentication nullptr
Definition: dialog.cc:352
char * pos
Definition: do_ctype.cc:76
void init_tmptable_sum_functions(Item_sum **func_ptr)
Definition: sql_executor.cc:409
bool pfs_batch_update(const JOIN *join) const
Definition: sql_executor.cc:5225
bool is_rollup_group_wrapper(Item *item)
Definition: sql_executor.cc:337
bool setup_sum_funcs(THD *thd, Item_sum **func_ptr)
Call setup() for all sum functions.
Definition: sql_executor.cc:400
AccessPath * GetAccessPathForDerivedTable(THD *thd, QEP_TAB *qep_tab, AccessPath *table_path)
Definition: sql_executor.cc:1412
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:441
void ExtractConditions(Item *condition, Mem_root_array< Item * > *condition_parts)
Split AND conditions into their constituent parts, recursively.
Definition: sql_executor.cc:719
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:311
std::string RefToString(const TABLE_REF &ref, const KEY *key, bool include_nulls)
Definition: sql_executor.cc:138
int join_read_const_table(JOIN_TAB *tab, POSITION *pos)
Reads content of constant table.
Definition: sql_executor.cc:3374
ulonglong unique_hash(const Field *field, ulonglong *hash)
Generate hash for a field.
Definition: sql_executor.cc:4566
int do_sj_dups_weedout(THD *thd, SJ_TMP_TABLE *sjtbl)
SemiJoinDuplicateElimination: Weed out duplicate row combinations.
Definition: sql_executor.cc:3254
int report_handler_error(TABLE *table, int error)
Help function when we get some an error from the table handler.
Definition: sql_executor.cc:3327
void setup_tmptable_write_func(QEP_TAB *tab, Opt_trace_object *trace)
Setup write_func of QEP_tmp_table object.
Definition: sql_executor.cc:530
int update_item_cache_if_changed(List< Cached_item > &list)
Definition: sql_executor.cc:4765
Item * unwrap_rollup_group(Item *item)
Definition: sql_executor.cc:349
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:4276
bool use_order() const
Use ordering provided by chosen index?
Definition: sql_executor.cc:4058
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:5012
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:4875
bool check_unique_constraint(TABLE *table)
Check unique_constraint.
Definition: sql_executor.cc:4656
bool make_group_fields(JOIN *main_join, JOIN *curr_join)
allocate group fields or take prepared (cached).
Definition: sql_executor.cc:4723
AccessPath * MoveCompositeIteratorsFromTablePath(AccessPath *path)
For a MATERIALIZE access path, move any non-basic iterators (e.g.
Definition: sql_executor.cc:1419
Item * CreateConjunction(List< Item > *items)
Create an AND conjuction of all given items.
Definition: sql_executor.cc:758
bool is_rollup_sum_wrapper(Item *item)
Definition: sql_executor.cc:343
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:666
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:4683
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:4812
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:959
bool prepare_sum_aggregators(Item_sum **func_ptr, bool need_distinct)
Definition: sql_executor.cc:374
void init(JOIN_TAB *jt)
Initializes the object from a JOIN_TAB.
Definition: sql_optimizer.cc:1263
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:3024
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:2696
void cleanup()
Definition: sql_select.cc:3322
uint sjm_query_block_id() const
Definition: sql_select.cc:3378
uint effective_index() const
Return the index used for a table in a QEP.
Definition: sql_optimizer.cc:1290
uint get_sj_strategy() const
Definition: sql_optimizer.cc:1270
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:464
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
unique_ptr_destroy_only< RowIterator > PossiblyAttachFilterIterator(unique_ptr_destroy_only< RowIterator > iterator, const std::vector< Item * > &conditions, THD *thd)
bool MaterializeIsDoingDeduplication(TABLE *table)
Definition: sql_executor.cc:5352
Copy_func_type
Definition: sql_executor.h:167
@ CFT_HAS_NO_WF
In first windowing step, copies non-window functions which do not rely on window functions,...
Definition: sql_executor.h:198
@ CFT_WF_NON_FRAMING
In windowing step, copies non framing window function, e.g.
Definition: sql_executor.h:182
@ 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:188
@ CFT_WF_FRAMING
In windowing step, copies framing window function, including all grouping aggregates,...
Definition: sql_executor.h:176
@ CFT_ALL
In non-windowing step, copies functions.
Definition: sql_executor.h:171
@ CFT_FIELDS
Copies Item_field only (typically because other functions might depend on those fields).
Definition: sql_executor.h:213
@ CFT_HAS_WF
In final windowing step, copies all non-wf functions.
Definition: sql_executor.h:204
@ CFT_WF_USES_ONLY_ONE_ROW
In windowing step, copies framing window functions that read only one row per frame.
Definition: sql_executor.h:193
@ CFT_WF
Copies all window functions.
Definition: sql_executor.h:208
void update_tmptable_sum_func(Item_sum **func_ptr, TABLE *tmp_table)
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.
@ REF_SLICE_SAVED_BASE
The slice with pointers to columns of table(s), ie., the actual Items.
Definition: sql_opt_exec_shared.h:627
#define NO_PLAN_IDX
undefined index
Definition: sql_opt_exec_shared.h:55
int8 plan_idx
This represents the index of a JOIN_TAB/QEP_TAB in an array.
Definition: sql_opt_exec_shared.h:40
Access paths are a query planning structure that correspond 1:1 to iterators, in that an access path ...
Definition: access_path.h:176
Definition: table.h:279
A position of table within a join order.
Definition: sql_select.h:350
Definition: sql_executor.h:486
Item * cond
Definition: sql_executor.h:487
int table_index_to_attach_to
Definition: sql_executor.h:488
Definition: sql_executor.h:77
QEP_TAB * qep_tab
Definition: sql_executor.h:78
ushort null_byte
Definition: sql_executor.h:80
uchar null_bit
Definition: sql_executor.h:81
uint rowid_offset
Definition: sql_executor.h:79
Definition: table.h:2694
Definition: sql_opt_exec_shared.h:59
Definition: table.h:1394
class QEP_TAB * qep_tab
Definition: table.h:1737
bool key_read
If set, the optimizer has found that row retrieval should access index tree only.
Definition: table.h:1661
struct TABLE::@163 reginfo
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