MySQL  8.0.19
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, 2019, Oracle and/or its affiliates. All rights reserved.
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 <string.h>
32 #include <sys/types.h>
33 #include <memory>
34 #include <vector>
35 
36 #include "my_alloc.h"
37 #include "my_base.h"
38 #include "my_compiler.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 Opt_trace_object;
58 class QEP_TAB;
59 class QUICK_SELECT_I;
60 class THD;
61 class Window;
63 struct CACHE_FIELD;
64 struct POSITION;
65 template <class T>
66 class List;
67 template <typename Element_type>
68 class Mem_root_array;
69 
70 /**
71  Possible status of a "nested loop" operation (Next_select_func family of
72  functions).
73  All values except NESTED_LOOP_OK abort the nested loop.
74 */
76  /**
77  Thread shutdown was requested while processing the record
78  @todo could it be merged with NESTED_LOOP_ERROR? Why two distinct states?
79  */
81  /// A fatal error (like table corruption) was detected
83  /// Record has been successfully handled
85  /**
86  Record has been successfully handled; additionally, the nested loop
87  produced the number of rows specified in the LIMIT clause for the query.
88  */
90  /**
91  Record has been successfully handled; additionally, there is a cursor and
92  the nested loop algorithm produced the number of rows that is specified
93  for current cursor fetch operation.
94  */
96 };
97 
99  bool);
100 
101 /*
102  Array of pointers to tables whose rowids compose the temporary table
103  record.
104 */
108  ushort null_byte;
110 };
111 
112 /*
113  Temporary table used by semi-join DuplicateElimination strategy
114 
115  This consists of the temptable itself and data needed to put records
116  into it. The table's DDL is as follows:
117 
118  CREATE TABLE tmptable (col VARCHAR(n) BINARY, PRIMARY KEY(col));
119 
120  where the primary key can be replaced with unique constraint if n exceeds
121  the limit (as it is always done for query execution-time temptables).
122 
123  The record value is a concatenation of rowids of tables from the join we're
124  executing. If a join table is on the inner side of the outer join, we
125  assume that its rowid can be NULL and provide means to store this rowid in
126  the tuple.
127 */
128 
130  public:
131  SJ_TMP_TABLE() : hash_field(nullptr) {}
134 
135  /*
136  is_confluent==true means this is a special case where the temptable record
137  has zero length (and presence of a unique key means that the temptable can
138  have either 0 or 1 records).
139  In this case we don't create the physical temptable but instead record
140  its state in SJ_TMP_TABLE::have_confluent_record.
141  */
143 
144  /*
145  When is_confluent==true: the contents of the table (whether it has the
146  record or not).
147  */
149 
150  /* table record parameters */
154 
155  /* The temporary table itself (NULL means not created yet) */
157 
158  /* Pointer to next table (next->start_idx > this->end_idx) */
160  /* Calc hash instead of too long key */
162 };
163 
164 /**
165  Executor structure for the materialized semi-join info, which contains
166  - Description of expressions selected from subquery
167  - The sj-materialization temporary table
168 */
170  public:
173  : sj_nest(sj_nest),
174  is_scan(is_scan),
178  table_param(),
179  table(NULL) {}
181  TABLE_LIST *const sj_nest; ///< Semi-join nest for this materialization
182  const bool is_scan; ///< true if executing a scan, false if lookup
183  const uint table_count; ///< Number of tables in the sj-nest
184  const uint mat_table_index; ///< Index in join_tab for materialized table
185  const uint inner_table_index; ///< Index in join_tab for first inner table
186  Temp_table_param table_param; ///< The temptable and its related info
187  TABLE *table; ///< Reference to temporary table
188 };
189 
190 /**
191  QEP_operation is an interface class for operations in query execution plan.
192 
193  Currently following operations are implemented:
194  JOIN_CACHE - caches partial join result and joins with attached table
195  QEP_tmp_table - materializes join result in attached table
196 
197  An operation's life cycle is as follows:
198  .) it is initialized on the init() call
199  .) accumulates records one by one when put_record() is called.
200  .) finalize record sending when end_send() is called.
201  .) free all internal buffers on the free() call.
202 
203  Each operation is attached to a join_tab, to which exactly depends on the
204  operation type: JOIN_CACHE is attached to the table following the table
205  being cached, QEP_tmp_buffer is attached to a tmp table.
206 */
207 
209  public:
210  // Type of the operation
212  /**
213  For JOIN_CACHE : Table to be joined with the partial join records from
214  the cache
215  For JOIN_TMP_BUFFER : join_tab of tmp table
216  */
218 
220  QEP_operation(QEP_TAB *qep_tab_arg) : qep_tab(qep_tab_arg) {}
221  virtual ~QEP_operation() {}
222  virtual enum_op_type type() = 0;
223  /**
224  Initialize operation's internal state. Called once per query execution.
225  */
226  virtual int init() { return 0; }
227  /**
228  Put a new record into the operation's buffer
229  @return
230  return one of enum_nested_loop_state values.
231  */
232  virtual enum_nested_loop_state put_record() = 0;
233  /**
234  Finalize records sending.
235  */
236  virtual enum_nested_loop_state end_send() = 0;
237  /**
238  Internal state cleanup.
239  */
240  virtual void mem_free() {}
241 };
242 
243 /**
244  @brief
245  Class for accumulating join result in a tmp table, grouping them if
246  necessary, and sending further.
247 
248  @details
249  Join result records are accumulated on the put_record() call.
250  The accumulation process is determined by the write_func, it could be:
251  end_write Simply store all records in tmp table.
252  end_write_group Perform grouping using join->group_fields,
253  records are expected to be sorted.
254  end_update Perform grouping using the key generated on tmp
255  table. Input records aren't expected to be sorted.
256  Tmp table uses the heap engine
257  end_update_unique Same as above, but the engine is myisam.
258 
259  Lazy table initialization is used - the table will be instantiated and
260  rnd/index scan started on the first put_record() call.
261 
262 */
263 
264 class QEP_tmp_table : public QEP_operation {
265  public:
266  QEP_tmp_table(QEP_TAB *qep_tab_arg)
267  : QEP_operation(qep_tab_arg), write_func(NULL) {}
270  /*
271  Send the result of operation further (to a next operation/client)
272  This function is called after all records were put into the buffer
273  (determined by the caller).
274 
275  @return return one of enum_nested_loop_state values.
276  */
278  /** write_func setter */
279  void set_write_func(Next_select_func new_write_func) {
280  write_func = new_write_func;
281  }
283 
284  private:
285  /** Write function that would be used for saving records in tmp table. */
287  enum_nested_loop_state put_record(bool end_of_records);
288  MY_ATTRIBUTE((warn_unused_result))
289  bool prepare_tmp_table();
290 };
291 
294  bool end_of_records);
296  bool end_of_records);
298  bool end_of_records);
300  bool end_of_records);
302  int error);
304 
305 MY_ATTRIBUTE((warn_unused_result))
306 bool copy_fields(Temp_table_param *param, const THD *thd,
307  bool reverse_copy = false);
308 
310  /**
311  In non-windowing step, copies functions
312  */
314  /**
315  In windowing step, copies framing window function, including
316  all grouping aggregates, e.g. SUM, AVG and FIRST_VALUE, LAST_VALUE.
317  */
319  /**
320  In windowing step, copies non framing window function, e.g.
321  ROW_NUMBER, RANK, DENSE_RANK, except those that are two_pass cf.
322  copy_two_pass_window_functions which are treated separately.
323  */
325  /**
326  In windowing step, copies window functions that need frame cardinality,
327  that is we need to read all rows of a partition before we can compute the
328  wf's value for the the first row in the partition.
329  */
331  /**
332  In windowing step, copies framing window functions that read only one row
333  per frame.
334  */
336  /**
337  In first windowing step, copies non-window functions which do not rely on
338  window functions, i.e. those that have Item::has_wf() == false.
339  */
341  /**
342  In final windowing step, copies all non-wf functions. Must be called after
343  all wfs have been evaluated, as non-wf functions may reference wf,
344  e.g. 1+RANK.
345  */
347  /**
348  Copies all window functions.
349  */
351  /**
352  Copies all items that are expressions containing aggregates, but are not
353  themselves aggregates. Such expressions are typically split into their
354  constituent parts during setup_fields(), such that the parts that are
355  _not_ aggregates are replaced by Item_refs that point into a slice.
356  See AggregateIterator::Read() for more details.
357  */
359 };
360 
361 bool copy_funcs(Temp_table_param *, const THD *thd,
363 
364 // Combines copy_fields() and copy_funcs().
365 bool copy_fields_and_funcs(Temp_table_param *param, const THD *thd,
367 
368 /**
369  Copy the lookup key into the table ref's key buffer.
370 
371  @param thd pointer to the THD object
372  @param table the table to read
373  @param ref information about the index lookup key
374 
375  @retval false ref key copied successfully
376  @retval true error dectected during copying of key
377 */
378 bool construct_lookup_ref(THD *thd, TABLE *table, TABLE_REF *ref);
379 
380 /** Help function when we get some an error from the table handler. */
381 int report_handler_error(TABLE *table, int error);
382 
383 int safe_index_read(QEP_TAB *tab);
384 
386 void join_setup_iterator(QEP_TAB *tab);
390 
391 int do_sj_dups_weedout(THD *thd, SJ_TMP_TABLE *sjtbl);
393 
394 // Create list for using with tempory table
395 bool change_to_use_tmp_fields(List<Item> &all_fields,
396  size_t num_select_elements, THD *thd,
397  Ref_item_array ref_item_array,
398  List<Item> *res_selected_fields,
399  List<Item> *res_all_fields);
400 // Create list for using with tempory table
401 bool change_refs_to_tmp_fields(List<Item> &all_fields,
402  size_t num_select_elements, THD *thd,
403  Ref_item_array ref_item_array,
404  List<Item> *res_selected_fields,
405  List<Item> *res_all_fields);
406 bool prepare_sum_aggregators(Item_sum **func_ptr, bool need_distinct);
407 bool setup_sum_funcs(THD *thd, Item_sum **func_ptr);
408 bool make_group_fields(JOIN *main_join, JOIN *curr_join);
409 bool setup_copy_fields(List<Item> &all_fields, size_t num_select_elements,
410  THD *thd, Temp_table_param *param,
411  Ref_item_array ref_item_array,
412  List<Item> *res_selected_fields,
413  List<Item> *res_all_fields);
414 bool check_unique_constraint(TABLE *table);
415 ulonglong unique_hash(const Field *field, ulonglong *hash);
416 
417 class QEP_TAB : public QEP_shared_owner {
418  public:
420  : QEP_shared_owner(),
421  table_ref(NULL),
429  found(false),
434  next_select(NULL),
440  having(NULL),
441  op(NULL),
443  filesort(NULL),
445  send_records(0),
450  m_fetched_rows(0),
452 
453  /// Initializes the object from a JOIN_TAB
454  void init(JOIN_TAB *jt);
455  // Cleans up.
456  void cleanup();
457 
458  // Getters and setters
459 
464  bool keyread_optim() const { return m_keyread_optim; }
466  if (table()) m_keyread_optim = table()->key_read;
467  }
468  bool reversed_access() const { return m_reversed_access; }
469  void set_reversed_access(bool arg) { m_reversed_access = arg; }
470 
471  void set_table(TABLE *t) {
472  m_qs->set_table(t);
473  if (t) t->reginfo.qep_tab = this;
474  }
475 
478  }
481  }
482 
483  bool using_table_scan() const { return m_using_table_scan; }
484  void set_using_table_scan(bool arg) { m_using_table_scan = arg; }
485 
486  /// @returns semijoin strategy for this table.
487  uint get_sj_strategy() const;
488 
489  /// Return true if join_tab should perform a FirstMatch action
490  bool do_firstmatch() const { return firstmatch_return != NO_PLAN_IDX; }
491 
492  /// Return true if join_tab should perform a LooseScan action
493  bool do_loosescan() const { return loosescan_key_len; }
494 
495  /// Return true if join_tab starts a Duplicate Weedout action
496  bool starts_weedout() const { return flush_weedout_table; }
497 
498  /// Return true if join_tab finishes a Duplicate Weedout action
499  bool finishes_weedout() const { return check_weed_out_table; }
500 
501  bool prepare_scan();
502 
503  /**
504  Instructs each lateral derived table depending on this QEP_TAB, to
505  rematerialize itself before emitting rows.
506  */
507  void refresh_lateral();
508 
509  /**
510  A helper function that allocates appropriate join cache object and
511  sets next_select function of previous tab.
512  */
513  void init_join_cache(JOIN_TAB *join_tab);
514 
515  /**
516  @returns query block id for an inner table of materialized semi-join, and
517  0 for all other tables.
518  @note implementation is not efficient (loops over all tables) - use this
519  function only in EXPLAIN.
520  */
521  uint sjm_query_block_id() const;
522 
523  /// @returns whether this is doing QS_DYNAMIC_RANGE
524  bool dynamic_range() const {
525  if (!position()) return false; // tmp table
526  return using_dynamic_range;
527  }
528 
529  bool use_order() const; ///< Use ordering provided by chosen index?
530  bool remove_duplicates();
531 
532  /**
533  Used to begin a new execution of a subquery. Necessary if this subquery
534  has done a filesort which which has cleared condition/quick.
535  */
539  }
540 
542  void push_index_cond(const JOIN_TAB *join_tab, uint keyno,
543  Opt_trace_object *trace_obj);
544 
545  /// @return the index used for a table in a QEP
546  uint effective_index() const;
547 
548  bool pfs_batch_update(JOIN *join) const;
549 
550  public:
551  /// Pointer to table reference
553 
554  /* Variables for semi-join duplicate elimination */
557 
558  /*
559  If set, means we should stop join enumeration after we've got the first
560  match and return to the specified join tab. May be PRE_FIRST_PLAN_IDX
561  which means stopping join execution after the first match.
562  */
564 
565  /*
566  Length of key tuple (depends on #keyparts used) to store in loosescan_buf.
567  If zero, means that loosescan is not used.
568  */
570 
571  /* Buffer to save index tuple to be able to skip duplicates */
573 
574  /*
575  If doing a LooseScan, this QEP is the first (i.e. "driving")
576  QEP_TAB, and match_tab points to the last QEP_TAB handled by the strategy.
577  match_tab->found_match should be checked to see if the current value group
578  had a match.
579  */
581 
582  /*
583  Used by FirstMatch and LooseScan. true <=> there is a matching
584  record combination
585  */
587 
588  /**
589  Used to decide whether an inner table of an outer join should produce NULL
590  values. If it is true after a call to evaluate_join_record(), the join
591  condition has been satisfied for at least one row from the inner
592  table. This member is not really manipulated by this class, see sub_select
593  for details on its use.
594  */
595  bool found;
596 
597  /**
598  This member is true as long as we are evaluating rows from the inner
599  tables of an outer join. If none of these rows satisfy the join condition,
600  we generated NULL-complemented rows and set this member to false. In the
601  meantime, the value may be read by triggered conditions, see
602  Item_func_trig_cond::val_int().
603  */
605 
606  plan_idx first_unmatched; /**< used for optimization purposes only */
607 
608  /// Dependent table functions have to be materialized on each new scan
610 
611  typedef int (*Setup_func)(QEP_TAB *);
613  bool using_dynamic_range = false;
616 
617  // join-cache-related members
620 
621  // Whether the row ID is needed for this table, and where the row ID can be
622  // found.
623  //
624  // If rowid_status != NO_ROWID_NEEDED, it indicates that this table is part of
625  // weedout. In order for weedout to eliminate duplicate rows, it needs a
626  // unique ID for each row it reads. In general, any operator that needs the
627  // row ID should ask the storage engine directly for the ID of the last row
628  // read by calling handler::position(). However, it is not that simple...
629  //
630  // As mentioned, position() will ask the storage engine to provide the row ID
631  // of the last row read. But some iterators (i.e. HashJoinIterator) buffer
632  // rows, so that the last row returned by i.e. HashJoinIterator is not
633  // necessarily the same as the last row returned by the storage engine.
634  // This means that any iterator that buffers rows without using a temporary
635  // table must store and restore the row ID itself. If a temporary table is
636  // used, the temporary table engine will provide the row ID.
637  //
638  // When creating the iterator tree, any iterator that needs to interact with
639  // row IDs must adhere to the following rules:
640  //
641  // 1. Any iterator that buffers rows without using a temporary table must
642  // store and restore the row ID if rowid_status != NO_ROWID_NEEDED.
643  // In addition, they must mark that they do so by changing the value of
644  // rowid_status to ROWID_PROVIDED_BY_ITERATOR_READ_CALL in their
645  // constructor.
646  // 2. Any iterator that needs the row ID (currently only WeedoutIterator)
647  // must check rowid_status to see if they should call position() or trust
648  // that a row ID is provided by another iterator. Note that when filesort
649  // sorts by row ID, it handles everything regarding row ID itself.
650  // It manages this because sorting by row ID always goes through a
651  // temporary table, which in turn will provide the row ID to filesort.
652  // 3. As the value of rowid_status may change while building the iterator
653  // tree, all iterators interacting with row IDs must cache the
654  // value they see in their constructor.
655  //
656  // Consider the following example:
657  //
658  // Weedout (t1,t3)
659  // |
660  // Nested loop
661  // / |
662  // Hash join t3
663  // / |
664  // t1 t2
665  //
666  // During query planning, rowid_status will be set to
667  // NEED_TO_CALL_POSITION_FOR_ROWID on t1 and t3 due to the planned weedout.
668  // When the iterator tree is constructed, the hash join constructor will be
669  // called first. It caches the value of rowid_status for t1 per rule 3 above,
670  // and changes the value to ROWID_PROVIDED_BY_ITERATOR_READ_CALL per rule 1.
671  // This notifies any iterator above itself that they should not call
672  // position(). When the nested loop constructor is called, nothing happens, as
673  // the iterator does not interact with row IDs in any way. When the weedout
674  // constructor is called, it caches the value of rowid_status for t1 and t3
675  // per rule 3. During execution, the weedout will call position() on t3,
676  // since rowid_status was NEED_TO_CALL_POSITION_FOR_ROWID when the iterator
677  // was constructed. It will not call position() on t1, as rowid_status was set
678  // to ROWID_PROVIDED_BY_ITERATOR_READ_CALL by the hash join iterator.
679  //
680  // Note that if you have a NULL-complemented row, there is no guarantee that
681  // position() will provide a valid row ID, or not even a valid row ID pointer.
682  // So all operations must check for NULL-complemented rows before trying to
683  // use/copy a row ID.
685 
686  // Helper structure for copying the row ID. Only used by BNL and BKA in the
687  // non-iterator executor.
689 
690  /** true <=> remove duplicates on this table. */
692 
693  // If we have a query of the type SELECT DISTINCT t1.* FROM t1 JOIN t2
694  // ON ..., (ie., we join in one or more tables that we don't actually
695  // read any columns from), we can stop scanning t2 as soon as we see the
696  // first row. This pattern seems to be a workaround for lack of semijoins
697  // in older versions of MySQL.
699 
700  /// Index condition for BKA access join
702 
703  /** HAVING condition for checking prior saving a record into tmp table*/
705 
707 
708  /* Tmp table info */
710 
711  /* Sorting related info */
713 
714  /**
715  Slice number of the ref items array to switch to before reading rows from
716  this table.
717  */
719 
720  /** Number of records saved in tmp table */
722 
723  /// @see m_quick_optim
725 
726  /**
727  m_quick is the quick "to be used at this stage of execution".
728  It can happen that filesort uses the quick (produced by the optimizer) to
729  produce a sorted result, then the read of this result has to be done
730  without "quick", so we must reset m_quick to NULL, but we want to delay
731  freeing of m_quick or it would close the filesort's result and the table
732  prematurely.
733  In that case, we move m_quick to m_quick_optim (=> delay deletion), reset
734  m_quick to NULL (read of filesort's result will be without quick); if
735  this is a subquery which is later executed a second time,
736  QEP_TAB::reset() will restore the quick from m_quick_optim into m_quick.
737  quick_optim stands for "the quick decided by the optimizer".
738  EXPLAIN reads this member and m_condition_optim; so if you change them
739  after exposing the plan (setting plan_state), do it with the
740  LOCK_query_plan mutex.
741  */
743 
744  /**
745  True if only index is going to be read for this table. This is the
746  optimizer's decision.
747  */
749 
750  /**
751  True if reversed scan is used. This is the optimizer's decision.
752  */
754 
755  /**
756  Count of rows fetched from this table; maintained by sub_select() and
757  reset to 0 by JOIN::reset().
758 
759  Only used by the pre-iterator executor.
760  */
762 
763  /**
764  Maps of all lateral derived tables which should be refreshed when
765  execution reads a new row from this table.
766  @note that if a LDT depends on t1 and t2, and t2 is after t1 in the plan,
767  then only t2::lateral_derived_tables_depend_on_me gets the map of the
768  LDT, for efficiency (less useless calls to QEP_TAB::refresh_lateral())
769  and clarity in EXPLAIN.
770  */
772 
774 
775  /**
776  If this table is a temporary table used for whole-JOIN materialization
777  (e.g. before sorting): true iff the table deduplicates, typically by way
778  of an unique index.
779 
780  Otherwise, unused.
781  */
783 
784  /**
785  True if iterator is a TableScanIterator. Used so that we can know whether
786  to stream directly across derived tables and into sorts (we cannot if there
787  is a ref access).
788  */
789  bool m_using_table_scan = false;
790 
791  /**
792  If this table is a recursive reference(to a CTE), contains a pointer to the
793  iterator here. This is so that MaterializeIterator can get a list of all
794  such iterators, to coordinate rematerialization and other signals.
795  */
797 
798  QEP_TAB(const QEP_TAB &); // not defined
799  QEP_TAB &operator=(const QEP_TAB &); // not defined
800 };
801 
802 /**
803  @returns a pointer to the QEP_TAB whose index is qtab->member. For
804  example, QEP_AT(x,first_inner) is the first_inner table of x.
805 */
806 #define QEP_AT(qtab, member) (qtab->join()->qep_tab[qtab->member])
807 
808 /**
809  Use this class when you need a QEP_TAB not connected to any JOIN_TAB.
810 */
812  public:
815  /// @returns access to the QEP_TAB
816  QEP_TAB &as_QEP_TAB() { return m_qt; }
817 
818  private:
821 };
822 
823 void copy_sum_funcs(Item_sum **func_ptr, Item_sum **end_ptr);
824 bool set_record_buffer(const QEP_TAB *tab);
825 bool init_sum_functions(Item_sum **func_ptr, Item_sum **end_ptr);
826 void init_tmptable_sum_functions(Item_sum **func_ptr);
827 bool update_sum_func(Item_sum **func_ptr);
828 void update_tmptable_sum_func(Item_sum **func_ptr, TABLE *tmp_table);
829 bool has_rollup_result(Item *item);
830 
831 /*
832  If a condition cannot be applied right away, for instance because it is a
833  WHERE condition and we're on the right side of an outer join, we have to
834  return it up so that it can be applied on a higher recursion level.
835  This structure represents such a condition.
836  */
839  int table_index_to_attach_to; // -1 means “on the last possible outer join”.
840 };
841 
844  const std::vector<Item *> &conditions, THD *thd);
845 
846 void SplitConditions(Item *condition,
847  std::vector<Item *> *predicates_below_join,
848  std::vector<PendingCondition> *predicates_above_join);
849 
851  const bool new_partition_or_eof,
852  bool *output_row_ready);
854  bool *new_partition);
855 bool bring_back_frame_row(THD *thd, Window *w, Temp_table_param *out_param,
857  int fno = 0);
858 
859 void ConvertItemsToCopy(List<Item> *items, Field **fields,
860  Temp_table_param *param, JOIN *join);
861 std::string RefToString(const TABLE_REF &ref, const KEY *key,
862  bool include_nulls);
863 
864 #endif /* SQL_EXECUTOR_INCLUDED */
Next_select_func
enum_nested_loop_state(* Next_select_func)(JOIN *, class QEP_TAB *, bool)
Definition: sql_executor.h:98
Semijoin_mat_exec::table_param
Temp_table_param table_param
The temptable and its related info.
Definition: sql_executor.h:186
QEP_TAB_standalone::QEP_TAB_standalone
QEP_TAB_standalone()
Definition: sql_executor.h:813
QEP_tmp_table::set_write_func
void set_write_func(Next_select_func new_write_func)
write_func setter
Definition: sql_executor.h:279
Item
Definition: item.h:665
THD
Definition: sql_class.h:764
QEP_TAB::not_used_in_distinct
bool not_used_in_distinct
Definition: sql_executor.h:698
SJ_TMP_TABLE_TAB::qep_tab
QEP_TAB * qep_tab
Definition: sql_executor.h:106
QEP_TAB::cleanup
void cleanup()
Definition: sql_select.cc:3269
update_sum_func
bool update_sum_func(Item_sum **func_ptr)
Definition: sql_executor.cc:656
QEP_TAB::m_quick_optim
QUICK_SELECT_I * m_quick_optim
m_quick is the quick "to be used at this stage of execution".
Definition: sql_executor.h:742
QEP_TAB::m_fetched_rows
ha_rows m_fetched_rows
Count of rows fetched from this table; maintained by sub_select() and reset to 0 by JOIN::reset().
Definition: sql_executor.h:761
Mem_root_array
A typesafe replacement for DYNAMIC_ARRAY.
Definition: mem_root_array.h:398
CFT_ALL
@ CFT_ALL
In non-windowing step, copies functions.
Definition: sql_executor.h:313
QEP_shared::set_table
void set_table(TABLE *t)
Definition: sql_opt_exec_shared.h:263
QEP_TAB::filesort
Filesort * filesort
Definition: sql_executor.h:712
SJ_TMP_TABLE::null_bits
uint null_bits
Definition: sql_executor.h:151
QEP_TAB_standalone::as_QEP_TAB
QEP_TAB & as_QEP_TAB()
Definition: sql_executor.h:816
QEP_TAB::finishes_weedout
bool finishes_weedout() const
Return true if join_tab finishes a Duplicate Weedout action.
Definition: sql_executor.h:499
REF_SLICE_SAVED_BASE
@ REF_SLICE_SAVED_BASE
The slice with pointers to columns of table(s), ie., the actual Items.
Definition: sql_opt_exec_shared.h:665
QEP_operation::end_send
virtual enum_nested_loop_state end_send()=0
Finalize records sending.
my_base.h
copy_fields_and_funcs
bool copy_fields_and_funcs(Temp_table_param *param, const THD *thd, Copy_func_type type=CFT_ALL)
Definition: sql_executor.cc:8257
update_tmptable_sum_func
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:627
QEP_tmp_table
Class for accumulating join result in a tmp table, grouping them if necessary, and sending further.
Definition: sql_executor.h:264
QEP_TAB::invalidators
Mem_root_array< const CacheInvalidatorIterator * > * invalidators
Definition: sql_executor.h:773
temp_table_param.h
Copy_func_type
Copy_func_type
Definition: sql_executor.h:309
QEP_TAB::materialize_table
Setup_func materialize_table
Definition: sql_executor.h:612
NULL
#define NULL
Definition: types.h:55
NO_ROWID_NEEDED
@ NO_ROWID_NEEDED
Definition: table.h:179
sql_opt_exec_shared.h
SJ_TMP_TABLE_TAB::null_byte
ushort null_byte
Definition: sql_executor.h:108
QEP_operation
QEP_operation is an interface class for operations in query execution plan.
Definition: sql_executor.h:208
Temp_table_param
Object containing parameters used when creating and using temporary tables.
Definition: temp_table_param.h:74
sql_lex.h
SJ_TMP_TABLE::null_bytes
uint null_bytes
Definition: sql_executor.h:152
my_compiler.h
hash
uint32_t hash(const void *key, size_t length, const uint32_t initval)
Definition: hash.c:121
row_iterator.h
setup_copy_fields
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.
Definition: sql_executor.cc:8125
QEP_TAB::used_uneven_bit_fields
bool used_uneven_bit_fields
Definition: sql_executor.h:619
QEP_operation::init
virtual int init()
Initialize operation's internal state.
Definition: sql_executor.h:226
QEP_TAB::tmp_table_param
Temp_table_param * tmp_table_param
Definition: sql_executor.h:709
QEP_TAB::flush_weedout_table
SJ_TMP_TABLE * flush_weedout_table
Definition: sql_executor.h:555
string.h
SJ_TMP_TABLE::hash_field
Field_longlong * hash_field
Definition: sql_executor.h:161
CFT_WF_FRAMING
@ CFT_WF_FRAMING
In windowing step, copies framing window function, including all grouping aggregates,...
Definition: sql_executor.h:318
QEP_TAB::set_condition_optim
void set_condition_optim()
Definition: sql_executor.h:463
QEP_TAB::Setup_func
int(* Setup_func)(QEP_TAB *)
Definition: sql_executor.h:611
TABLE::key_read
bool key_read
If set, the optimizer has found that row retrieval should access index tree only.
Definition: table.h:1544
QEP_operation::OT_CACHE
@ OT_CACHE
Definition: sql_executor.h:211
SJ_TMP_TABLE_TAB::null_bit
uchar null_bit
Definition: sql_executor.h:109
pos
char * pos
Definition: do_ctype.cc:76
CFT_WF_NON_FRAMING
@ CFT_WF_NON_FRAMING
In windowing step, copies non framing window function, e.g.
Definition: sql_executor.h:324
Window
Represents the (explicit) window of a SQL 2003 section 7.11 <window clause>, or the implicit (inlined...
Definition: window.h:94
QEP_TAB::send_records
ha_rows send_records
Number of records saved in tmp table.
Definition: sql_executor.h:721
Semijoin_mat_exec::Semijoin_mat_exec
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:171
QEP_TAB::using_table_scan
bool using_table_scan() const
Definition: sql_executor.h:483
TABLE
Definition: table.h:1305
QEP_tmp_table::prepare_tmp_table
bool prepare_tmp_table()
Instantiate tmp table and start index scan if necessary.
Definition: sql_executor.cc:8522
join_materialize_table_function
int join_materialize_table_function(QEP_TAB *tab)
Definition: sql_executor.cc:4805
unique_hash
ulonglong unique_hash(const Field *field, ulonglong *hash)
Generate hash for a field.
Definition: sql_executor.cc:5645
QEP_TAB
Definition: sql_executor.h:417
QEP_TAB::temporary_table_deduplicates
bool temporary_table_deduplicates() const
Definition: sql_executor.h:476
QEP_TAB::m_condition_optim
Item * m_condition_optim
Definition: sql_executor.h:724
safe_index_read
int safe_index_read(QEP_TAB *tab)
Definition: sql_executor.cc:4072
SplitConditions
void SplitConditions(Item *condition, std::vector< Item * > *predicates_below_join, std::vector< PendingCondition > *predicates_above_join)
Definition: sql_executor.cc:1424
QEP_TAB::get_sj_strategy
uint get_sj_strategy() const
Definition: sql_optimizer.cc:1140
QEP_TAB::set_keyread_optim
void set_keyread_optim()
Definition: sql_executor.h:465
QEP_TAB::remove_duplicates
bool remove_duplicates()
Definition: sql_executor.cc:7802
QEP_TAB::firstmatch_return
plan_idx firstmatch_return
Definition: sql_executor.h:563
NESTED_LOOP_CURSOR_LIMIT
@ NESTED_LOOP_CURSOR_LIMIT
Record has been successfully handled; additionally, there is a cursor and the nested loop algorithm p...
Definition: sql_executor.h:95
has_rollup_result
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:499
mysql_harness::join
std::string join(Container cont, const std::string &delim)
join elements of an container into a string seperated by a delimiter.
Definition: string.h:144
QEP_TAB::ref_item_slice
uint ref_item_slice
Slice number of the ref items array to switch to before reading rows from this table.
Definition: sql_executor.h:718
SJ_TMP_TABLE::is_confluent
bool is_confluent
Definition: sql_executor.h:142
unique_ptr_destroy_only
std::unique_ptr< T, Destroy_only< T > > unique_ptr_destroy_only
std::unique_ptr, but only destroying.
Definition: my_alloc.h:408
QEP_TAB::starts_weedout
bool starts_weedout() const
Return true if join_tab starts a Duplicate Weedout action.
Definition: sql_executor.h:496
QEP_TAB::copy_current_rowid
CACHE_FIELD * copy_current_rowid
Definition: sql_executor.h:688
SJ_TMP_TABLE_TAB
Definition: sql_executor.h:105
QEP_TAB::condition_optim
Item * condition_optim() const
Definition: sql_executor.h:460
setup_tmptable_write_func
void setup_tmptable_write_func(QEP_TAB *tab, Opt_trace_object *trace)
Setup write_func of QEP_tmp_table object.
Definition: sql_executor.cc:925
SJ_TMP_TABLE
Definition: sql_executor.h:129
SJ_TMP_TABLE::tmp_table
TABLE * tmp_table
Definition: sql_executor.h:156
Window_retrieve_cached_row_reason
Window_retrieve_cached_row_reason
Position hints for the frame buffer are saved for these kind of row accesses, cf.
Definition: window.h:64
Filesort
Sorting related info.
Definition: filesort.h:49
join_materialize_semijoin
int join_materialize_semijoin(QEP_TAB *tab)
Definition: sql_executor.cc:4842
QEP_TAB::needs_duplicate_removal
bool needs_duplicate_removal
true <=> remove duplicates on this table.
Definition: sql_executor.h:691
ConvertItemsToCopy
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 spec...
Definition: sql_executor.cc:1296
init_sum_functions
bool init_sum_functions(Item_sum **func_ptr, Item_sum **end_ptr)
Definition: sql_executor.cc:645
key
static const char * key
Definition: suite_stubs.c:14
FollowTailIterator
FollowTailIterator is a special version of TableScanIterator that is used as part of WITH RECURSIVE q...
Definition: basic_row_iterators.h:477
QEP_TAB::operator=
QEP_TAB & operator=(const QEP_TAB &)
join_read_const_table
int join_read_const_table(JOIN_TAB *tab, POSITION *pos)
Reads content of constant table.
Definition: sql_executor.cc:4091
QEP_TAB::found_match
bool found_match
Definition: sql_executor.h:586
CFT_WF_NEEDS_CARD
@ CFT_WF_NEEDS_CARD
In windowing step, copies window functions that need frame cardinality, that is we need to read all r...
Definition: sql_executor.h:330
QEP_operation::QEP_operation
QEP_operation()
Definition: sql_executor.h:219
my_alloc.h
TABLE::qep_tab
class QEP_TAB * qep_tab
Definition: table.h:1598
QEP_TAB::check_weed_out_table
SJ_TMP_TABLE * check_weed_out_table
Definition: sql_executor.h:556
QEP_TAB::not_null_compl
bool not_null_compl
This member is true as long as we are evaluating rows from the inner tables of an outer join.
Definition: sql_executor.h:604
QEP_shared_owner::quick
QUICK_SELECT_I * quick() const
Definition: sql_opt_exec_shared.h:519
int64
int64_t int64
Definition: my_inttypes.h:67
RefToString
std::string RefToString(const TABLE_REF &ref, const KEY *key, bool include_nulls)
Definition: sql_executor.cc:189
QEP_shared_owner
Owner of a QEP_shared; parent of JOIN_TAB and QEP_TAB.
Definition: sql_opt_exec_shared.h:463
QEP_TAB::set_temporary_table_deduplicates
void set_temporary_table_deduplicates(bool arg)
Definition: sql_executor.h:479
Semijoin_mat_exec::sj_nest
TABLE_LIST *const sj_nest
Semi-join nest for this materialization.
Definition: sql_executor.h:181
QEP_shared
Holds members common to JOIN_TAB and QEP_TAB.
Definition: sql_opt_exec_shared.h:221
PendingCondition
Definition: sql_executor.h:837
QEP_TAB::iterator
unique_ptr_destroy_only< RowIterator > iterator
Definition: sql_executor.h:615
QEP_TAB::m_temporary_table_deduplicates
bool m_temporary_table_deduplicates
If this table is a temporary table used for whole-JOIN materialization (e.g.
Definition: sql_executor.h:782
JOIN
Definition: sql_optimizer.h:174
my_inttypes.h
QEP_operation::~QEP_operation
virtual ~QEP_operation()
Definition: sql_executor.h:221
QEP_shared_owner::condition
Item * condition() const
Definition: sql_opt_exec_shared.h:508
QEP_tmp_table::put_record
enum_nested_loop_state put_record()
Put a new record into the operation's buffer.
Definition: sql_executor.h:269
PendingCondition::cond
Item * cond
Definition: sql_executor.h:838
sub_select
enum_nested_loop_state sub_select(JOIN *join, QEP_TAB *qep_tab, bool end_of_records)
Retrieve records ends with a given beginning from the result of a join.
Definition: sql_executor.cc:3418
SJ_TMP_TABLE::rowid_len
uint rowid_len
Definition: sql_executor.h:153
QEP_TAB::loosescan_key_len
uint loosescan_key_len
Definition: sql_executor.h:569
QEP_tmp_table::get_write_func
Next_select_func get_write_func() const
Definition: sql_executor.h:282
QEP_TAB::prepare_scan
bool prepare_scan()
Prepare table to be scanned.
Definition: sql_executor.cc:3598
process_buffered_windowing_record
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,...
Definition: sql_executor.cc:6360
uint
unsigned int uint
Definition: uca-dump.cc:29
QEP_TAB::rowid_status
rowid_statuses rowid_status
Definition: sql_executor.h:684
QEP_operation::type
virtual enum_op_type type()=0
QEP_TAB::found
bool found
Used to decide whether an inner table of an outer join should produce NULL values.
Definition: sql_executor.h:595
join_materialize_derived
int join_materialize_derived(QEP_TAB *tab)
Definition: sql_executor.cc:4819
QEP_TAB::next_select
Next_select_func next_select
Definition: sql_executor.h:614
do_sj_dups_weedout
int do_sj_dups_weedout(THD *thd, SJ_TMP_TABLE *sjtbl)
SemiJoinDuplicateElimination: Weed out duplicate row combinations.
Definition: sql_executor.cc:3644
QEP_TAB_standalone
Use this class when you need a QEP_TAB not connected to any JOIN_TAB.
Definition: sql_executor.h:811
QEP_TAB_standalone::m_qt
QEP_TAB m_qt
Definition: sql_executor.h:820
QEP_shared_owner::table
TABLE * table() const
Definition: sql_opt_exec_shared.h:486
list
class udf_list * list
set_record_buffer
bool set_record_buffer(const QEP_TAB *tab)
Allocate a data buffer that the storage engine can use for fetching batches of records.
Definition: sql_executor.cc:1057
TABLE_LIST
Definition: table.h:2467
Semijoin_mat_exec
Executor structure for the materialized semi-join info, which contains.
Definition: sql_executor.h:169
Semijoin_mat_exec::inner_table_index
const uint inner_table_index
Index in join_tab for first inner table.
Definition: sql_executor.h:185
CFT_HAS_NO_WF
@ CFT_HAS_NO_WF
In first windowing step, copies non-window functions which do not rely on window functions,...
Definition: sql_executor.h:340
uchar
unsigned char uchar
Definition: my_inttypes.h:51
SJ_TMP_TABLE::SJ_TMP_TABLE
SJ_TMP_TABLE()
Definition: sql_executor.h:131
CFT_HAS_WF
@ CFT_HAS_WF
In final windowing step, copies all non-wf functions.
Definition: sql_executor.h:346
QEP_tmp_table::type
enum_op_type type()
Definition: sql_executor.h:268
QEP_TAB::set_table
void set_table(TABLE *t)
Definition: sql_executor.h:471
QEP_shared_owner::set_qs
void set_qs(QEP_shared *q)
Definition: sql_opt_exec_shared.h:469
table_map
uint64_t table_map
Definition: my_table_map.h:30
QEP_TAB::used_null_fields
bool used_null_fields
Definition: sql_executor.h:618
SJ_TMP_TABLE_TAB::rowid_offset
uint rowid_offset
Definition: sql_executor.h:107
NESTED_LOOP_OK
@ NESTED_LOOP_OK
Record has been successfully handled.
Definition: sql_executor.h:84
NO_PLAN_IDX
#define NO_PLAN_IDX
undefined index
Definition: sql_opt_exec_shared.h:54
QEP_TAB::set_using_table_scan
void set_using_table_scan(bool arg)
Definition: sql_executor.h:484
QEP_TAB::QEP_TAB
QEP_TAB()
Definition: sql_executor.h:419
SJ_TMP_TABLE::have_confluent_row
bool have_confluent_row
Definition: sql_executor.h:148
my_table_map.h
QEP_TAB::set_quick_optim
void set_quick_optim()
Definition: sql_executor.h:462
QEP_TAB::pfs_batch_update
bool pfs_batch_update(JOIN *join) const
Definition: sql_executor.cc:8659
check_unique_constraint
bool check_unique_constraint(TABLE *table)
Check unique_constraint.
Definition: sql_executor.cc:5732
construct_lookup_ref
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:7998
enum_nested_loop_state
enum_nested_loop_state
Possible status of a "nested loop" operation (Next_select_func family of functions).
Definition: sql_executor.h:75
QEP_operation::qep_tab
QEP_TAB * qep_tab
For JOIN_CACHE : Table to be joined with the partial join records from the cache For JOIN_TMP_BUFFER ...
Definition: sql_executor.h:217
Semijoin_mat_exec::table
TABLE * table
Reference to temporary table.
Definition: sql_executor.h:187
QEP_TAB::match_tab
plan_idx match_tab
Definition: sql_executor.h:580
QEP_TAB::cache_idx_cond
Item * cache_idx_cond
Index condition for BKA access join.
Definition: sql_executor.h:701
QEP_TAB::sjm_query_block_id
uint sjm_query_block_id() const
Definition: sql_select.cc:3312
QEP_TAB::set_reversed_access
void set_reversed_access(bool arg)
Definition: sql_executor.h:469
Cached_item
This is used for segregating rows in groups (e.g.
Definition: item.h:5393
QEP_TAB::quick_optim
QUICK_SELECT_I * quick_optim() const
Definition: sql_executor.h:461
bool
#define bool
Definition: config_static.h:42
plan_idx
int8 plan_idx
This represents the index of a JOIN_TAB/QEP_TAB in an array.
Definition: sql_opt_exec_shared.h:39
QEP_operation::put_record
virtual enum_nested_loop_state put_record()=0
Put a new record into the operation's buffer.
change_refs_to_tmp_fields
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.
Definition: sql_executor.cc:8383
QUICK_SELECT_I
Definition: opt_range.h:229
QEP_TAB::table_ref
TABLE_LIST * table_ref
Pointer to table reference.
Definition: sql_executor.h:552
QEP_TAB::do_firstmatch
bool do_firstmatch() const
Return true if join_tab should perform a FirstMatch action.
Definition: sql_executor.h:490
make_group_fields
bool make_group_fields(JOIN *main_join, JOIN *curr_join)
allocate group fields or take prepared (cached).
Definition: sql_executor.cc:8038
NESTED_LOOP_KILLED
@ NESTED_LOOP_KILLED
Thread shutdown was requested while processing the record.
Definition: sql_executor.h:80
QEP_shared_owner::set_condition
void set_condition(Item *to)
Definition: sql_opt_exec_shared.h:509
QEP_TAB::op
QEP_operation * op
Definition: sql_executor.h:706
NESTED_LOOP_ERROR
@ NESTED_LOOP_ERROR
A fatal error (like table corruption) was detected.
Definition: sql_executor.h:82
QEP_TAB::do_loosescan
bool do_loosescan() const
Return true if join_tab should perform a LooseScan action.
Definition: sql_executor.h:493
QEP_TAB::pick_table_access_method
void pick_table_access_method()
Pick the appropriate access method functions.
Definition: sql_executor.cc:5100
QEP_operation::enum_op_type
enum_op_type
Definition: sql_executor.h:211
end_send_group
enum_nested_loop_state end_send_group(JOIN *join, QEP_TAB *qep_tab, bool end_of_records)
Definition: sql_executor.cc:5410
NESTED_LOOP_QUERY_LIMIT
@ NESTED_LOOP_QUERY_LIMIT
Record has been successfully handled; additionally, the nested loop produced the number of rows speci...
Definition: sql_executor.h:89
KEY
Definition: key.h:111
QEP_TAB::reversed_access
bool reversed_access() const
Definition: sql_executor.h:468
prepare_sum_aggregators
bool prepare_sum_aggregators(Item_sum **func_ptr, bool need_distinct)
Definition: sql_executor.cc:582
PossiblyAttachFilterIterator
unique_ptr_destroy_only< RowIterator > PossiblyAttachFilterIterator(unique_ptr_destroy_only< RowIterator > iterator, const std::vector< Item * > &conditions, THD *thd)
Return a new iterator that wraps "iterator" and that tests all of the given conditions (if any),...
Definition: sql_executor.cc:1178
Item_sum
Class Item_sum is the base class used for special expressions that SQL calls 'set functions'.
Definition: item_sum.h:390
rowid_statuses
rowid_statuses
Definition: table.h:178
QEP_TAB::init_join_cache
void init_join_cache(JOIN_TAB *join_tab)
A helper function that allocates appropriate join cache object and sets next_select function of previ...
Definition: sql_select.cc:2914
SJ_TMP_TABLE::tabs
SJ_TMP_TABLE_TAB * tabs
Definition: sql_executor.h:132
QEP_shared_owner::set_quick
void set_quick(QUICK_SELECT_I *q)
Definition: sql_opt_exec_shared.h:520
copy_fields
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:8243
QEP_TAB::restore_quick_optim_and_condition
void restore_quick_optim_and_condition()
Used to begin a new execution of a subquery.
Definition: sql_executor.h:536
QEP_operation::QEP_operation
QEP_operation(QEP_TAB *qep_tab_arg)
Definition: sql_executor.h:220
setup_sum_funcs
bool setup_sum_funcs(THD *thd, Item_sum **func_ptr)
Call setup() for all sum functions.
Definition: sql_executor.cc:610
error
Log error(cerr, "ERROR")
HttpMethod::type
int type
Definition: http_common.h:411
buffer_windowing_record
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 ...
Definition: sql_executor.cc:5938
QEP_TAB::recursive_iterator
FollowTailIterator * recursive_iterator
If this table is a recursive reference(to a CTE), contains a pointer to the iterator here.
Definition: sql_executor.h:796
Semijoin_mat_exec::is_scan
const bool is_scan
true if executing a scan, false if lookup
Definition: sql_executor.h:182
QEP_TAB::keyread_optim
bool keyread_optim() const
Definition: sql_executor.h:464
Semijoin_mat_exec::table_count
const uint table_count
Number of tables in the sj-nest.
Definition: sql_executor.h:183
evaluate_join_record
enum_nested_loop_state evaluate_join_record(JOIN *join, QEP_TAB *qep_tab, int error)
items
Definition: items.h:34
copy_funcs
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:681
QEP_shared_owner::position
POSITION * position() const
Definition: sql_opt_exec_shared.h:487
QEP_TAB::refresh_lateral
void refresh_lateral()
Instructs each lateral derived table depending on this QEP_TAB, to rematerialize itself before emitti...
Definition: sql_executor.cc:3568
CacheInvalidatorIterator
An iterator that helps invalidating caches.
Definition: composite_iterators.h:498
change_to_use_tmp_fields
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.
Definition: sql_executor.cc:8283
table.h
QEP_TAB_standalone::~QEP_TAB_standalone
~QEP_TAB_standalone()
Definition: sql_executor.h:814
QEP_operation::mem_free
virtual void mem_free()
Internal state cleanup.
Definition: sql_executor.h:240
Field_longlong
Definition: field.h:2439
Opt_trace_object
A JSON object (unordered set of key/value pairs).
Definition: opt_trace.h:813
QEP_tmp_table::end_send
enum_nested_loop_state end_send()
Finish rnd/index scan after accumulating records, switch ref_array, and send accumulated records furt...
Definition: sql_executor.cc:8580
Bounds_checked_array< Item * >
QEP_TAB::use_order
bool use_order() const
Use ordering provided by chosen index?
Definition: sql_executor.cc:4885
ulonglong
unsigned long long int ulonglong
Definition: my_inttypes.h:55
init_tmptable_sum_functions
void init_tmptable_sum_functions(Item_sum **func_ptr)
Definition: sql_executor.cc:619
update_item_cache_if_changed
int update_item_cache_if_changed(List< Cached_item > &list)
Definition: sql_executor.cc:8080
JOIN_TAB
Query optimization plan node.
Definition: sql_select.h:579
TABLE_REF
Definition: sql_opt_exec_shared.h:58
QEP_operation::OT_TMP_TABLE
@ OT_TMP_TABLE
Definition: sql_executor.h:211
CACHE_FIELD
Definition: sql_join_buffer.h:59
QEP_TAB::effective_index
uint effective_index() const
Return the index used for a table in a QEP.
Definition: sql_optimizer.cc:1160
Semijoin_mat_exec::~Semijoin_mat_exec
~Semijoin_mat_exec()
Definition: sql_executor.h:180
List
Definition: aggregate_check.h:523
ha_rows
my_off_t ha_rows
Definition: my_base.h:1132
POSITION
A position of table within a join order.
Definition: sql_select.h:343
QEP_TAB_standalone::m_qs
QEP_shared m_qs
Definition: sql_executor.h:819
QEP_TAB::m_using_table_scan
bool m_using_table_scan
True if iterator is a TableScanIterator.
Definition: sql_executor.h:789
TABLE::reginfo
struct TABLE::@120 reginfo
PendingCondition::table_index_to_attach_to
int table_index_to_attach_to
Definition: sql_executor.h:839
SJ_TMP_TABLE::next
SJ_TMP_TABLE * next
Definition: sql_executor.h:159
Field
Definition: field.h:695
QEP_TAB::lateral_derived_tables_depend_on_me
table_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:771
QEP_TAB::using_dynamic_range
bool using_dynamic_range
Definition: sql_executor.h:613
CFT_WF
@ CFT_WF
Copies all window functions.
Definition: sql_executor.h:350
QEP_TAB::loosescan_buf
uchar * loosescan_buf
Definition: sql_executor.h:572
QEP_shared_owner::join
JOIN * join() const
Definition: sql_opt_exec_shared.h:476
sub_select_op
enum_nested_loop_state sub_select_op(JOIN *join, QEP_TAB *qep_tab, bool end_of_records)
Accumulate full or partial join result in operation and send operation's result further.
Definition: sql_executor.cc:3246
QEP_tmp_table::write_func
Next_select_func write_func
Write function that would be used for saving records in tmp table.
Definition: sql_executor.h:286
report_handler_error
int report_handler_error(TABLE *table, int error)
Help function when we get some an error from the table handler.
Definition: sql_executor.cc:4032
join_setup_iterator
void join_setup_iterator(QEP_TAB *tab)
Prepare table for reading rows and read first record.
Definition: sql_executor.cc:4774
CFT_DEPENDING_ON_AGGREGATE
@ CFT_DEPENDING_ON_AGGREGATE
Copies all items that are expressions containing aggregates, but are not themselves aggregates.
Definition: sql_executor.h:358
QEP_tmp_table::QEP_tmp_table
QEP_tmp_table(QEP_TAB *qep_tab_arg)
Definition: sql_executor.h:266
QEP_TAB::init
void init(JOIN_TAB *jt)
Initializes the object from a JOIN_TAB.
Definition: sql_optimizer.cc:1133
Semijoin_mat_exec::mat_table_index
const uint mat_table_index
Index in join_tab for materialized table.
Definition: sql_executor.h:184
end_write_group
enum_nested_loop_state end_write_group(JOIN *join, QEP_TAB *qep_tab, bool end_of_records)
Definition: sql_executor.cc:7636
end_send_count
enum_nested_loop_state end_send_count(JOIN *join, QEP_TAB *qep_tab)
Definition: sql_executor.cc:5375
QEP_TAB::m_keyread_optim
bool m_keyread_optim
True if only index is going to be read for this table.
Definition: sql_executor.h:748
QEP_shared_owner::m_qs
QEP_shared * m_qs
Definition: sql_opt_exec_shared.h:556
QEP_TAB::rematerialize
bool rematerialize
Dependent table functions have to be materialized on each new scan.
Definition: sql_executor.h:609
QEP_TAB::first_unmatched
plan_idx first_unmatched
used for optimization purposes only
Definition: sql_executor.h:606
copy_sum_funcs
void copy_sum_funcs(Item_sum **func_ptr, Item_sum **end_ptr)
Copy result of sum functions to record in tmp_table.
Definition: sql_executor.cc:636
SJ_TMP_TABLE::tabs_end
SJ_TMP_TABLE_TAB * tabs_end
Definition: sql_executor.h:133
CFT_WF_USES_ONLY_ONE_ROW
@ CFT_WF_USES_ONLY_ONE_ROW
In windowing step, copies framing window functions that read only one row per frame.
Definition: sql_executor.h:335
bring_back_frame_row
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 ...
Definition: sql_executor.cc:6104
QEP_TAB::m_reversed_access
bool m_reversed_access
True if reversed scan is used.
Definition: sql_executor.h:753
QEP_TAB::having
Item * having
HAVING condition for checking prior saving a record into tmp table.
Definition: sql_executor.h:704
QEP_TAB::push_index_cond
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:2583
QEP_TAB::dynamic_range
bool dynamic_range() const
Definition: sql_executor.h:524
false
#define false
Definition: config_static.h:43