MySQL  8.0.19
Source Code Documentation
sql_opt_exec_shared.h
Go to the documentation of this file.
1 /* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
2 
3  This program is free software; you can redistribute it and/or modify
4  it under the terms of the GNU General Public License, version 2.0,
5  as published by the Free Software Foundation.
6 
7  This program is also distributed with certain software (including
8  but not limited to OpenSSL) that is licensed under separate terms,
9  as designated in a particular file or component or in included license
10  documentation. The authors of MySQL hereby grant you an additional
11  permission to link the program and your derivative works with the
12  separately licensed software that they have included with MySQL.
13 
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License, version 2.0, for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program; if not, write to the Free Software
21  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22 
23 /**
24  @file sql/sql_opt_exec_shared.h
25  Common types of the Optimizer, used by optimization and execution.
26 */
27 
28 #ifndef SQL_OPT_EXEC_SHARED_INCLUDED
29 #define SQL_OPT_EXEC_SHARED_INCLUDED
30 
31 #include "my_base.h"
32 #include "my_dbug.h"
33 #include "sql/item.h"
34 
35 class JOIN;
36 class Item_func_match;
37 class store_key;
38 struct POSITION;
40 
41 /**
42  This represents the index of a JOIN_TAB/QEP_TAB in an array. "plan_idx":
43  "Plan Table Index". It is signed, because:
44  - firstmatch_return may be PRE_FIRST_PLAN_IDX (it can happen that the first
45  table of the plan uses FirstMatch: SELECT ... WHERE literal IN (SELECT
46  ...)).
47  - it must hold the invalid value NO_PLAN_IDX (which means "no
48  JOIN_TAB/QEP_TAB", equivalent of NULL pointer); this invalid value must
49  itself be different from PRE_FIRST_PLAN_IDX, to distinguish "FirstMatch to
50  before-first-table" (firstmatch_return==PRE_FIRST_PLAN_IDX) from "No
51  FirstMatch" (firstmatch_return==NO_PLAN_IDX).
52 */
53 typedef int8 plan_idx;
54 #define NO_PLAN_IDX (-2) ///< undefined index
55 #define PRE_FIRST_PLAN_IDX \
56  (-1) ///< right before the first (first's index is 0)
57 
58 struct TABLE_REF {
59  bool key_err;
60  uint key_parts; ///< num of ...
61  uint key_length; ///< length of key_buff
62  int key; ///< key no
63  uchar *key_buff; ///< value to look for with key
64  uchar *key_buff2; ///< key_buff+key_length
65  /**
66  Used to store the value from each keypart field. These values are
67  used for ref access. If key_copy[key_part] == NULL it means that
68  the value is constant and does not need to be reevaluated
69  */
71  Item **items; ///< val()'s for each keypart
72  /*
73  Array of pointers to trigger variables. Some/all of the pointers may be
74  NULL. The ref access can be used iff
75 
76  for each used key part i, (!cond_guards[i] || *cond_guards[i])
77 
78  This array is used by subquery code. The subquery code may inject
79  triggered conditions, i.e. conditions that can be 'switched off'. A ref
80  access created from such condition is not valid when at least one of the
81  underlying conditions is switched off (see subquery code for more details).
82  If a table in a subquery has this it means that the table access
83  will switch from ref access to table scan when the outer query
84  produces a NULL value to be checked for in the subquery. This will
85  be used by NOT IN subqueries and IN subqueries which need to distinguish
86  NULL and FALSE, where ignore_unknown() is false.
87  */
88  bool **cond_guards;
89  /**
90  @code (null_rejecting & (1<<i)) @endcode means the condition is '=' and no
91  matching rows will be produced if items[i] IS NULL (see
92  add_not_null_conds())
93  */
95  table_map depend_map; ///< Table depends on these tables.
96  /*
97  NULL byte position in the key_buf (if set, the key is taken to be NULL);
98  normally points to the first byte in the buffer. Used for REF_OR_NULL
99  lookups.
100  */
102  /*
103  The number of times the record associated with this key was used
104  in the join.
105  */
107 
108  /*
109  true <=> disable the "cache" as doing lookup with the same key value may
110  produce different results (because of Index Condition Pushdown)
111  */
113 
115  : key_err(true),
116  key_parts(0),
117  key_length(0),
118  key(-1),
119  key_buff(NULL),
120  key_buff2(NULL),
121  key_copy(NULL),
122  items(NULL),
123  cond_guards(NULL),
124  null_rejecting(0),
125  depend_map(0),
127  use_count(0),
128  disable_cache(false) {}
129 
130  /**
131  @returns whether the reference contains NULL values which could never give
132  a match.
133  */
134  bool impossible_null_ref() const {
135  if (null_rejecting != 0) {
136  for (uint i = 0; i < key_parts; i++) {
137  if ((null_rejecting & 1 << i) && items[i]->is_null()) return true;
138  }
139  }
140  return false;
141  }
142 
143  /**
144  Check if there are triggered/guarded conditions that might be
145  'switched off' by the subquery code when executing 'Full scan on
146  NULL key' subqueries.
147 
148  @return true if there are guarded conditions, false otherwise
149  */
150 
151  bool has_guarded_conds() const {
153 
154  for (uint i = 0; i < key_parts; i++) {
155  if (cond_guards[i]) return true;
156  }
157  return false;
158  }
159 };
160 
161 struct CACHE_FIELD;
162 class QEP_operation;
163 class Filesort;
164 class Semijoin_mat_exec;
165 
166 /*
167  The structs which holds the join connections and join states
168 */
169 enum join_type { /*
170  Initial state. Access type has not yet been decided
171  for the table
172  */
174  /* Table has exactly one row */
176  /*
177  Table has at most one matching row. Values read
178  from this row can be treated as constants. Example:
179  "WHERE table.pk = 3"
180  */
182  /*
183  '=' operator is used on unique index. At most one
184  row is read for each combination of rows from
185  preceding tables
186  */
188  /*
189  '=' operator is used on non-unique index
190  */
192  /*
193  Full table scan.
194  */
196  /*
197  Range scan.
198  */
200  /*
201  Like table scan, but scans index leaves instead of
202  the table
203  */
205  /* Fulltext index is used */
207  /*
208  Like ref, but with extra search for NULL values.
209  E.g. used for "WHERE col = ... OR col IS NULL"
210  */
212  /*
213  Do multiple range scans over one table and combine
214  the results into one. The merge can be used to
215  produce unions and intersections
216  */
218 };
219 
220 /// Holds members common to JOIN_TAB and QEP_TAB.
221 class QEP_shared {
222  public:
224  : m_join(NULL),
226  m_table(NULL),
227  m_position(NULL),
234  m_ref(),
235  m_index(0),
237  m_condition(NULL),
238  m_keys(),
239  m_records(0),
240  m_quick(NULL),
242  added_tables_map(0),
243  m_ft_func(NULL),
245 
246  /*
247  Simple getters and setters. They are public. However, this object is
248  protected in QEP_shared_owner, so only that class and its children
249  (JOIN_TAB, QEP_TAB) can access the getters and setters.
250  */
251 
252  JOIN *join() const { return m_join; }
253  void set_join(JOIN *j) { m_join = j; }
254  plan_idx idx() const {
255  DBUG_ASSERT(m_idx >= 0); // Index must be valid
256  return m_idx;
257  }
258  void set_idx(plan_idx i) {
259  DBUG_ASSERT(m_idx == NO_PLAN_IDX); // Index should not change in lifetime
260  m_idx = i;
261  }
262  TABLE *table() const { return m_table; }
263  void set_table(TABLE *t) { m_table = t; }
264  POSITION *position() const { return m_position; }
278  TABLE_REF &ref() { return m_ref; }
279  uint index() const { return m_index; }
280  void set_index(uint i) { m_index = i; }
281  enum join_type type() const { return m_type; }
282  void set_type(enum join_type t) { m_type = t; }
283  Item *condition() const { return m_condition; }
284  void set_condition(Item *c) { m_condition = c; }
287  }
290  }
291  Key_map &keys() { return m_keys; }
292  ha_rows records() const { return m_records; }
294  QUICK_SELECT_I *quick() const { return m_quick; }
298  Item_func_match *ft_func() const { return m_ft_func; }
300 
301  // More elaborate functions:
302 
303  /**
304  Set available tables for a table in a join plan.
305 
306  @param prefix_tables_arg Set of tables available for this plan
307  @param prev_tables_arg Set of tables available for previous table, used to
308  calculate set of tables added for this table.
309  */
310  void set_prefix_tables(table_map prefix_tables_arg,
311  table_map prev_tables_arg) {
312  prefix_tables_map = prefix_tables_arg;
313  added_tables_map = prefix_tables_arg & ~prev_tables_arg;
314  }
315 
316  /**
317  Add an available set of tables for a table in a join plan.
318 
319  @param tables Set of tables added for this table in plan.
320  */
322  prefix_tables_map |= tables;
323  added_tables_map |= tables;
324  }
325 
327 
329  return m_first_inner != NO_PLAN_IDX;
330  }
333  }
335  return m_first_inner == m_idx && m_last_inner == m_idx;
336  }
337 
340  }
341 
343 
344  private:
346 
347  /**
348  Index of structure in array:
349  - NO_PLAN_IDX if before get_best_combination()
350  - index of pointer to this JOIN_TAB, in JOIN::best_ref array
351  - index of this QEP_TAB, in JOIN::qep array.
352  */
354 
355  /// Corresponding table. Might be an internal temporary one.
357 
358  /// Points into best_positions array. Includes cost info.
360 
361  /*
362  semijoin-related members.
363  */
364 
365  /**
366  Struct needed for materialization of semi-join. Set for a materialized
367  temporary table, and NULL for all other join_tabs (except when
368  materialization is in progress, @see join_materialize_semijoin()).
369  */
371 
372  /**
373  Boundaries of semijoin inner tables around this table. Valid only once
374  final QEP has been chosen. Depending on the strategy, they may define an
375  interval (all tables inside are inner of a semijoin) or
376  not. last_sj_inner is not set for Duplicates Weedout.
377  */
379 
380  /*
381  outer-join-related members.
382  */
383  plan_idx m_first_inner; ///< first inner table for including outer join
384  plan_idx m_last_inner; ///< last table table for embedding outer join
385  plan_idx m_first_upper; ///< first inner table for embedding outer join
386 
387  /**
388  Used to do index-based look up based on a key value.
389  Used when we read constant tables, in misc optimization (like
390  remove_const()), and in execution.
391  */
393 
394  /// ID of index used for index scan or semijoin LooseScan
396 
397  /// Type of chosen access method (scan, etc).
399 
400  /**
401  Table condition, ie condition to be evaluated for a row from this table.
402  Notice that the condition may refer to rows from previous tables in the
403  join prefix, as well as outer tables.
404  */
406 
407  /**
408  Whether the condition in m_condition is evaluated in front of a sort,
409  so that it does not need to be evaluated again (unless it is outer to
410  an inner join; see the relevant comments in SortingIterator::Init().
411 
412  Note that m_condition remains non-nullptr in this case, for purposes
413  of the (non-tree) EXPLAIN and for filesort to build up its read maps.
414  */
416 
417  /**
418  All keys with can be used.
419  Used by add_key_field() (optimization time) and execution of dynamic
420  range (DynamicRangeIterator), and EXPLAIN.
421  */
423 
424  /**
425  Either number of rows in the table or 1 for const table.
426  Used in optimization, and also in execution for FOUND_ROWS().
427  */
429 
430  /**
431  Non-NULL if quick-select used.
432  Filled in optimization, used in execution to find rows, and in EXPLAIN.
433  */
435 
436  /*
437  Maps below are shared because of dynamic range: in execution, it needs to
438  know the prefix tables, to find the possible QUICK methods.
439  */
440 
441  /**
442  The set of all tables available in the join prefix for this table,
443  including the table handled by this JOIN_TAB.
444  */
446  /**
447  The set of tables added for this table, compared to the previous table
448  in the join prefix.
449  */
451 
452  /** FT function */
454 
455  /**
456  Set if index dive can be skipped for this query.
457  See comments for check_skip_records_in_range_qualification.
458  */
460 };
461 
462 /// Owner of a QEP_shared; parent of JOIN_TAB and QEP_TAB.
464  public:
466 
467  /// Instructs to share the QEP_shared with another owner
468  void share_qs(QEP_shared_owner *other) { other->set_qs(m_qs); }
469  void set_qs(QEP_shared *q) {
470  DBUG_ASSERT(!m_qs);
471  m_qs = q;
472  }
473 
474  // Getters/setters forwarding to QEP_shared:
475 
476  JOIN *join() const { return m_qs ? m_qs->join() : nullptr; }
477  void set_join(JOIN *j) { return m_qs->set_join(j); }
478 
479  // NOTE: This index (and the associated map) is not the same as
480  // table_ref's index, which is the index in the original FROM list
481  // (before optimization).
482  plan_idx idx() const { return m_qs->idx(); }
483  void set_idx(plan_idx i) { return m_qs->set_idx(i); }
484  qep_tab_map idx_map() const { return qep_tab_map{1} << m_qs->idx(); }
485 
486  TABLE *table() const { return m_qs->table(); }
487  POSITION *position() const { return m_qs->position(); }
488  void set_position(POSITION *p) { return m_qs->set_position(p); }
491  return m_qs->set_sj_mat_exec(s);
492  }
494  plan_idx last_sj_inner() const { return m_qs->last_sj_inner(); }
495  plan_idx first_inner() const { return m_qs->first_inner(); }
496  plan_idx last_inner() const { return m_qs->last_inner(); }
497  plan_idx first_upper() const { return m_qs->first_upper(); }
499  void set_last_inner(plan_idx i) { return m_qs->set_last_inner(i); }
503  TABLE_REF &ref() const { return m_qs->ref(); }
504  uint index() const { return m_qs->index(); }
505  void set_index(uint i) { return m_qs->set_index(i); }
506  enum join_type type() const { return m_qs->type(); }
507  void set_type(enum join_type t) { return m_qs->set_type(t); }
508  Item *condition() const { return m_qs->condition(); }
509  void set_condition(Item *to) { return m_qs->set_condition(to); }
512  }
515  }
516  Key_map &keys() const { return m_qs->keys(); }
517  ha_rows records() const { return m_qs->records(); }
518  void set_records(ha_rows r) { return m_qs->set_records(r); }
519  QUICK_SELECT_I *quick() const { return m_qs->quick(); }
520  void set_quick(QUICK_SELECT_I *q) { return m_qs->set_quick(q); }
521  table_map prefix_tables() const { return m_qs->prefix_tables(); }
522  table_map added_tables() const { return m_qs->added_tables(); }
523  Item_func_match *ft_func() const { return m_qs->ft_func(); }
524  void set_ft_func(Item_func_match *f) { return m_qs->set_ft_func(f); }
526  return m_qs->set_prefix_tables(prefix_tables, prev_tables);
527  }
529  return m_qs->add_prefix_tables(tables);
530  }
533  }
536  }
539  }
542  }
543 
544  bool has_guarded_conds() const { return ref().has_guarded_conds(); }
545  bool and_with_condition(Item *tmp_cond);
546 
549  }
550 
552 
553  void qs_cleanup();
554 
555  protected:
556  QEP_shared *m_qs; // qs stands for Qep_Shared
557 };
558 
559 /**
560  Symbolic slice numbers into JOIN's arrays ref_items, tmp_fields and
561  tmp_all_fields
562 
563  See also the comments on JOIN::ref_items.
564 */
565 enum {
566  /**
567  The slice which is used during evaluation of expressions; Item_ref::ref
568  points there. This is the only slice that is not allocated on the heap;
569  it always points to select_lex->base_ref_items.
570 
571  If we have a simple query (no temporary tables or GROUP BY needed),
572  this slice always contains the base slice, i.e., the actual Items used
573  in the original query.
574 
575  However, if we have temporary tables, there are cases where we need to
576  swap out those Items, because they refer to Fields that are no longer in
577  use. As a simple case, consider
578 
579  SELECT REVERSE(t1), COUNT(*) FROM t1 GROUP BY REVERSE(t1);
580 
581  Assuming no index on t1, this will require creating a temporary table
582  consisting only of REVERSE(t1), and then sorting it before grouping.
583  During execution of the query creating the temporary table, we will
584  have an Item_func_reverse pointing to a Field for t1, and the result of
585  this will be stored in the temporary table "tmp". However, when reading
586  from "tmp", it would be wrong to use that Item_func_reverse, as the Field
587  no longer exists. Thus, we create a slice (in REF_SLICE_TMP1) with new Item
588  pointers, where Item_func_reverse is replaced by an Item_field that reads
589  from the right field in the temporary table. Similar logic applies for
590  windowing functions etc.; see below.
591 
592  In such cases, the pointers in this slice are _overwritten_ (using memcpy)
593  by e.g. REF_SLICE_TMP1 for as long as we read from the temporary table.
594  Switch_ref_item_slice provides an encapsulation of the overwriting,
595  and the optimizer stores a copy of the original Item pointers in the
596  REF_SLICE_SAVED_BASE slice so that it is possible to copy them back
597  when we are done.
598 
599  @todo It would probably be better to store the active slice index in
600  current_thd and do the indirection in Item_ref_* instead of copying the
601  slices around.
602  */
604  /**
605  The slice with pointers to columns of 1st group-order-distinct tmp
606  table
607  */
609  /**
610  The slice with pointers to columns of 2nd group-order-distinct tmp
611  table
612  */
614  /**
615  Stores the unfinished aggregated row when doing GROUP BY on an
616  ordered table.
617 
618  For certain queries with GROUP BY (e.g., when using an index),
619  rows arrive already sorted in the right order for grouping.
620  In that case, we do not need nor use a temporary table, but can
621  just group values as we go. However, we do not necessarily know when
622  a group ends -- a group implicitly ends when we see that the
623  group index values have changed, and by that time, it's too late to
624  output them in the aggregated row (the Fields already point to the
625  new row, so the data is lost).
626 
627  Thus, we need to store the values for the current group somewhere.
628  We use a set of Items, which together represent a one-row
629  pseudo-tmp-table holding the current group. These items are created
630  by setup_copy_fields().
631 
632  When we have finished reading a row from the last pre-grouping table, we
633  process it either with end_send_group() or end_send():
634 
635  * end_send_group(): Compare the new row with the current group.
636  If it belongs to the current group, we update the aggregation functions
637  and move on. If not, we output the aggregated row and overwrite the
638  contents of this slice with the new group.
639 
640  * end_send(): Used when we know there's exactly one row for each group
641  (e.g., during a loose index scan). In this case, we can skip the
642  comparison and just output the group directly; however, we still need
643  the temporary table to avoid evaluating Items more than once (see the
644  next paragraph).
645 
646  Both functions build the group by copying values of items from the previous
647  stages into a pseudo-table, e.g.
648 
649  SELECT a, RAND() AS r FROM t GROUP BY a HAVING r=1;
650 
651  copies "a" from "t" and stores it into the pseudo-table (this slice),
652  evaluates rand() and stores it, then finally evaluates "r=1" based on the
653  stored value (so that "r" in the SELECT list and "r" in "r=1" match).
654 
655  Groups from this slice are always directly sent to the query's result,
656  and never buffered to any further temporary table.
657  */
659  /**
660  The slice with pointers to columns of table(s), ie., the actual Items.
661  Only used for queries involving temporary tables or the likes; for simple
662  queries, they always live in REF_SLICE_ACTIVE, so we don't need a copy
663  here. See REF_SLICE_ACTIVE for more discussion.
664  */
666  /**
667  The slice with pointers to columns of 1st tmp table of windowing
668  */
670 };
671 
672 #endif // SQL_OPT_EXEC_SHARED_INCLUDED
QEP_shared::condition
Item * condition() const
Definition: sql_opt_exec_shared.h:283
QEP_shared::mark_condition_as_pushed_to_sort
void mark_condition_as_pushed_to_sort()
Definition: sql_opt_exec_shared.h:288
QEP_shared::QEP_shared
QEP_shared()
Definition: sql_opt_exec_shared.h:223
QEP_shared_owner::set_prefix_tables
void set_prefix_tables(table_map prefix_tables, table_map prev_tables)
Definition: sql_opt_exec_shared.h:525
QEP_shared::added_tables_map
table_map added_tables_map
The set of tables added for this table, compared to the previous table in the join prefix.
Definition: sql_opt_exec_shared.h:450
Bitmap< 64 >
Definition: sql_bitmap.h:136
QEP_shared_owner::idx_map
qep_tab_map idx_map() const
Definition: sql_opt_exec_shared.h:484
QEP_shared::last_sj_inner
plan_idx last_sj_inner()
Definition: sql_opt_exec_shared.h:269
TABLE_REF::cond_guards
bool ** cond_guards
Definition: sql_opt_exec_shared.h:88
Item
Definition: item.h:665
QEP_shared_owner::has_guarded_conds
bool has_guarded_conds() const
Definition: sql_opt_exec_shared.h:544
JT_EQ_REF
@ JT_EQ_REF
Definition: sql_opt_exec_shared.h:187
TABLE_REF::impossible_null_ref
bool impossible_null_ref() const
Definition: sql_opt_exec_shared.h:134
QEP_shared_owner::keys
Key_map & keys() const
Definition: sql_opt_exec_shared.h:516
QEP_shared_owner::share_qs
void share_qs(QEP_shared_owner *other)
Instructs to share the QEP_shared with another owner.
Definition: sql_opt_exec_shared.h:468
QEP_shared::set_table
void set_table(TABLE *t)
Definition: sql_opt_exec_shared.h:263
QEP_shared_owner::QEP_shared_owner
QEP_shared_owner()
Definition: sql_opt_exec_shared.h:465
QEP_shared::set_ft_func
void set_ft_func(Item_func_match *f)
Definition: sql_opt_exec_shared.h:299
QEP_shared::set_position
void set_position(POSITION *p)
Definition: sql_opt_exec_shared.h:265
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_shared_owner::set_sj_mat_exec
void set_sj_mat_exec(Semijoin_mat_exec *s)
Definition: sql_opt_exec_shared.h:490
my_base.h
QEP_shared::m_condition_is_pushed_to_sort
bool m_condition_is_pushed_to_sort
Whether the condition in m_condition is evaluated in front of a sort, so that it does not need to be ...
Definition: sql_opt_exec_shared.h:415
TABLE_REF::TABLE_REF
TABLE_REF()
Definition: sql_opt_exec_shared.h:114
TABLE_REF::null_rejecting
key_part_map null_rejecting
Definition: sql_opt_exec_shared.h:94
qep_tab_map
uint64_t qep_tab_map
Definition: my_table_map.h:32
QEP_shared::first_sj_inner
plan_idx first_sj_inner()
Definition: sql_opt_exec_shared.h:268
NULL
#define NULL
Definition: types.h:55
QEP_shared::set_prefix_tables
void set_prefix_tables(table_map prefix_tables_arg, table_map prev_tables_arg)
Set available tables for a table in a join plan.
Definition: sql_opt_exec_shared.h:310
QEP_shared_owner::last_sj_inner
plan_idx last_sj_inner() const
Definition: sql_opt_exec_shared.h:494
QEP_shared::position
POSITION * position() const
Definition: sql_opt_exec_shared.h:264
QEP_shared::set_records
void set_records(ha_rows r)
Definition: sql_opt_exec_shared.h:293
QEP_operation
QEP_operation is an interface class for operations in query execution plan.
Definition: sql_executor.h:208
QEP_shared::set_index
void set_index(uint i)
Definition: sql_opt_exec_shared.h:280
QEP_shared::m_quick
QUICK_SELECT_I * m_quick
Non-NULL if quick-select used.
Definition: sql_opt_exec_shared.h:434
QEP_shared::skip_records_in_range
bool skip_records_in_range() const
Definition: sql_opt_exec_shared.h:342
my_dbug.h
TABLE
Definition: table.h:1305
TABLE_REF::key_buff2
uchar * key_buff2
key_buff+key_length
Definition: sql_opt_exec_shared.h:64
QEP_shared::table
TABLE * table() const
Definition: sql_opt_exec_shared.h:262
JT_REF_OR_NULL
@ JT_REF_OR_NULL
Definition: sql_opt_exec_shared.h:211
TABLE_REF::key_length
uint key_length
length of key_buff
Definition: sql_opt_exec_shared.h:61
QEP_shared::is_inner_table_of_outer_join
bool is_inner_table_of_outer_join() const
Definition: sql_opt_exec_shared.h:328
TABLE_REF::key_buff
uchar * key_buff
value to look for with key
Definition: sql_opt_exec_shared.h:63
QEP_shared_owner::first_sj_inner
plan_idx first_sj_inner() const
Definition: sql_opt_exec_shared.h:493
key_part_map
ulong key_part_map
Definition: my_base.h:1000
QEP_shared::idx
plan_idx idx() const
Definition: sql_opt_exec_shared.h:254
QEP_shared::type
enum join_type type() const
Definition: sql_opt_exec_shared.h:281
QEP_shared::last_inner
plan_idx last_inner()
Definition: sql_opt_exec_shared.h:276
QEP_shared::first_upper
plan_idx first_upper()
Definition: sql_opt_exec_shared.h:277
QEP_shared_owner::skip_records_in_range
bool skip_records_in_range() const
Definition: sql_opt_exec_shared.h:551
QEP_shared_owner::set_join
void set_join(JOIN *j)
Definition: sql_opt_exec_shared.h:477
QEP_shared_owner::is_first_inner_for_outer_join
bool is_first_inner_for_outer_join() const
Definition: sql_opt_exec_shared.h:537
QEP_shared::set_idx
void set_idx(plan_idx i)
Definition: sql_opt_exec_shared.h:258
QEP_shared::set_last_inner
void set_last_inner(plan_idx i)
Definition: sql_opt_exec_shared.h:272
Filesort
Sorting related info.
Definition: filesort.h:49
QEP_shared_owner::first_upper
plan_idx first_upper() const
Definition: sql_opt_exec_shared.h:497
QEP_shared::m_type
enum join_type m_type
Type of chosen access method (scan, etc).
Definition: sql_opt_exec_shared.h:398
QEP_shared_owner::ref
TABLE_REF & ref() const
Definition: sql_opt_exec_shared.h:503
QEP_shared_owner::last_inner
plan_idx last_inner() const
Definition: sql_opt_exec_shared.h:496
true
#define true
Definition: config_static.h:44
TABLE_REF::use_count
ha_rows use_count
Definition: sql_opt_exec_shared.h:106
QEP_shared::set_condition
void set_condition(Item *c)
Definition: sql_opt_exec_shared.h:284
TABLE_REF::null_ref_key
uchar * null_ref_key
Definition: sql_opt_exec_shared.h:101
QEP_shared::added_tables
table_map added_tables() const
Definition: sql_opt_exec_shared.h:297
TABLE_REF::items
Item ** items
val()'s for each keypart
Definition: sql_opt_exec_shared.h:71
QEP_shared_owner::mark_condition_as_pushed_to_sort
void mark_condition_as_pushed_to_sort()
Definition: sql_opt_exec_shared.h:513
QEP_shared_owner::is_inner_table_of_outer_join
bool is_inner_table_of_outer_join() const
Definition: sql_opt_exec_shared.h:534
QEP_shared_owner::is_single_inner_of_semi_join
bool is_single_inner_of_semi_join() const
Definition: sql_opt_exec_shared.h:531
QEP_shared::first_inner
plan_idx first_inner()
Definition: sql_opt_exec_shared.h:270
TABLE_REF::key_err
bool key_err
Definition: sql_opt_exec_shared.h:59
JT_FT
@ JT_FT
Definition: sql_opt_exec_shared.h:206
REF_SLICE_ACTIVE
@ REF_SLICE_ACTIVE
The slice which is used during evaluation of expressions; Item_ref::ref points there.
Definition: sql_opt_exec_shared.h:603
JT_INDEX_MERGE
@ JT_INDEX_MERGE
Definition: sql_opt_exec_shared.h:217
QEP_shared_owner::set_first_sj_inner
void set_first_sj_inner(plan_idx i)
Definition: sql_opt_exec_shared.h:500
QEP_shared_owner::is_single_inner_for_outer_join
bool is_single_inner_for_outer_join() const
Definition: sql_opt_exec_shared.h:540
QEP_shared_owner::quick
QUICK_SELECT_I * quick() const
Definition: sql_opt_exec_shared.h:519
QEP_shared_owner
Owner of a QEP_shared; parent of JOIN_TAB and QEP_TAB.
Definition: sql_opt_exec_shared.h:463
JT_UNKNOWN
@ JT_UNKNOWN
Definition: sql_opt_exec_shared.h:173
QEP_shared
Holds members common to JOIN_TAB and QEP_TAB.
Definition: sql_opt_exec_shared.h:221
QEP_shared::m_first_sj_inner
plan_idx m_first_sj_inner
Boundaries of semijoin inner tables around this table.
Definition: sql_opt_exec_shared.h:378
QEP_shared_owner::records
ha_rows records() const
Definition: sql_opt_exec_shared.h:517
JOIN
Definition: sql_optimizer.h:174
QEP_shared_owner::set_position
void set_position(POSITION *p)
Definition: sql_opt_exec_shared.h:488
QEP_shared::m_position
POSITION * m_position
Points into best_positions array. Includes cost info.
Definition: sql_opt_exec_shared.h:359
QEP_shared_owner::condition
Item * condition() const
Definition: sql_opt_exec_shared.h:508
QEP_shared_owner::set_idx
void set_idx(plan_idx i)
Definition: sql_opt_exec_shared.h:483
QEP_shared_owner::condition_is_pushed_to_sort
bool condition_is_pushed_to_sort() const
Definition: sql_opt_exec_shared.h:510
TABLE_REF::has_guarded_conds
bool has_guarded_conds() const
Check if there are triggered/guarded conditions that might be 'switched off' by the subquery code whe...
Definition: sql_opt_exec_shared.h:151
QEP_shared::m_idx
plan_idx m_idx
Index of structure in array:
Definition: sql_opt_exec_shared.h:353
QEP_shared_owner::set_first_upper
void set_first_upper(plan_idx i)
Definition: sql_opt_exec_shared.h:502
r
const mysql_service_registry_t * r
Definition: pfs_example_plugin_employee.cc:85
QEP_shared_owner::set_last_inner
void set_last_inner(plan_idx i)
Definition: sql_opt_exec_shared.h:499
int8
int8_t int8
Definition: my_inttypes.h:61
join_type
join_type
Definition: sql_opt_exec_shared.h:169
QEP_shared_owner::set_type
void set_type(enum join_type t)
Definition: sql_opt_exec_shared.h:507
QEP_shared::set_first_inner
void set_first_inner(plan_idx i)
Definition: sql_opt_exec_shared.h:271
QEP_shared::set_skip_records_in_range
void set_skip_records_in_range(bool skip_records_in_range)
Definition: sql_opt_exec_shared.h:338
uint
unsigned int uint
Definition: uca-dump.cc:29
JT_ALL
@ JT_ALL
Definition: sql_opt_exec_shared.h:195
QEP_shared::m_first_upper
plan_idx m_first_upper
first inner table for embedding outer join
Definition: sql_opt_exec_shared.h:385
QEP_shared::m_table
TABLE * m_table
Corresponding table. Might be an internal temporary one.
Definition: sql_opt_exec_shared.h:356
QEP_shared::m_join
JOIN * m_join
Definition: sql_opt_exec_shared.h:345
QEP_shared::prefix_tables_map
table_map prefix_tables_map
The set of all tables available in the join prefix for this table, including the table handled by thi...
Definition: sql_opt_exec_shared.h:445
QEP_shared_owner::table
TABLE * table() const
Definition: sql_opt_exec_shared.h:486
QEP_shared_owner::added_tables
table_map added_tables() const
Definition: sql_opt_exec_shared.h:522
QEP_shared::prefix_tables
table_map prefix_tables() const
Definition: sql_opt_exec_shared.h:296
Semijoin_mat_exec
Executor structure for the materialized semi-join info, which contains.
Definition: sql_executor.h:169
QEP_shared::condition_is_pushed_to_sort
bool condition_is_pushed_to_sort() const
Definition: sql_opt_exec_shared.h:285
QEP_shared_owner::set_first_inner
void set_first_inner(plan_idx i)
Definition: sql_opt_exec_shared.h:498
QEP_shared_owner::set_index
void set_index(uint i)
Definition: sql_opt_exec_shared.h:505
uchar
unsigned char uchar
Definition: my_inttypes.h:51
TABLE_REF::key
int key
key no
Definition: sql_opt_exec_shared.h:62
QEP_shared_owner::prefix_tables
table_map prefix_tables() const
Definition: sql_opt_exec_shared.h:521
QEP_shared_owner::sj_mat_exec
Semijoin_mat_exec * sj_mat_exec() const
Definition: sql_opt_exec_shared.h:489
JT_RANGE
@ JT_RANGE
Definition: sql_opt_exec_shared.h:199
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_shared::keys
Key_map & keys()
Definition: sql_opt_exec_shared.h:291
TABLE_REF::depend_map
table_map depend_map
Table depends on these tables.
Definition: sql_opt_exec_shared.h:95
NO_PLAN_IDX
#define NO_PLAN_IDX
undefined index
Definition: sql_opt_exec_shared.h:54
QEP_shared_owner::idx
plan_idx idx() const
Definition: sql_opt_exec_shared.h:482
QEP_shared::m_skip_records_in_range
bool m_skip_records_in_range
Set if index dive can be skipped for this query.
Definition: sql_opt_exec_shared.h:459
QEP_shared_owner::and_with_condition
bool and_with_condition(Item *tmp_cond)
Extend join_tab->cond by AND'ing add_cond to it.
Definition: sql_select.cc:3334
QEP_shared::set_quick
void set_quick(QUICK_SELECT_I *q)
Definition: sql_opt_exec_shared.h:295
REF_SLICE_ORDERED_GROUP_BY
@ REF_SLICE_ORDERED_GROUP_BY
Stores the unfinished aggregated row when doing GROUP BY on an ordered table.
Definition: sql_opt_exec_shared.h:658
QEP_shared::is_single_inner_of_outer_join
bool is_single_inner_of_outer_join() const
Definition: sql_opt_exec_shared.h:334
QEP_shared::set_join
void set_join(JOIN *j)
Definition: sql_opt_exec_shared.h:253
QEP_shared::set_first_sj_inner
void set_first_sj_inner(plan_idx i)
Definition: sql_opt_exec_shared.h:273
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_shared_owner::set_records
void set_records(ha_rows r)
Definition: sql_opt_exec_shared.h:518
JT_INDEX_SCAN
@ JT_INDEX_SCAN
Definition: sql_opt_exec_shared.h:204
q
synode_no q[FIFO_SIZE]
Definition: xcom_base.c:2940
QEP_shared_owner::add_prefix_tables
void add_prefix_tables(table_map tables)
Definition: sql_opt_exec_shared.h:528
TABLE_REF::disable_cache
bool disable_cache
Definition: sql_opt_exec_shared.h:112
QUICK_SELECT_I
Definition: opt_range.h:229
QEP_shared::index
uint index() const
Definition: sql_opt_exec_shared.h:279
JT_CONST
@ JT_CONST
Definition: sql_opt_exec_shared.h:181
QEP_shared_owner::set_condition
void set_condition(Item *to)
Definition: sql_opt_exec_shared.h:509
QEP_shared::ft_func
Item_func_match * ft_func() const
Definition: sql_opt_exec_shared.h:298
DBUG_ASSERT
#define DBUG_ASSERT(A)
Definition: my_dbug.h:197
TABLE_REF::key_parts
uint key_parts
num of ...
Definition: sql_opt_exec_shared.h:60
QEP_shared::records
ha_rows records() const
Definition: sql_opt_exec_shared.h:292
QEP_shared_owner::set_quick
void set_quick(QUICK_SELECT_I *q)
Definition: sql_opt_exec_shared.h:520
QEP_shared::m_ref
TABLE_REF m_ref
Used to do index-based look up based on a key value.
Definition: sql_opt_exec_shared.h:392
QEP_shared::m_sj_mat_exec
Semijoin_mat_exec * m_sj_mat_exec
Struct needed for materialization of semi-join.
Definition: sql_opt_exec_shared.h:370
JT_REF
@ JT_REF
Definition: sql_opt_exec_shared.h:191
REF_SLICE_TMP1
@ REF_SLICE_TMP1
The slice with pointers to columns of 1st group-order-distinct tmp table.
Definition: sql_opt_exec_shared.h:608
QEP_shared::m_condition
Item * m_condition
Table condition, ie condition to be evaluated for a row from this table.
Definition: sql_opt_exec_shared.h:405
QEP_shared_owner::index
uint index() const
Definition: sql_opt_exec_shared.h:504
QEP_shared::m_ft_func
Item_func_match * m_ft_func
FT function.
Definition: sql_opt_exec_shared.h:453
QEP_shared::m_records
ha_rows m_records
Either number of rows in the table or 1 for const table.
Definition: sql_opt_exec_shared.h:428
items
Definition: items.h:34
QEP_shared_owner::position
POSITION * position() const
Definition: sql_opt_exec_shared.h:487
QEP_shared_owner::set_ft_func
void set_ft_func(Item_func_match *f)
Definition: sql_opt_exec_shared.h:524
QEP_shared::is_single_inner_of_semi_join
bool is_single_inner_of_semi_join() const
Definition: sql_opt_exec_shared.h:331
QEP_shared::add_prefix_tables
void add_prefix_tables(table_map tables)
Add an available set of tables for a table in a join plan.
Definition: sql_opt_exec_shared.h:321
JT_SYSTEM
@ JT_SYSTEM
Definition: sql_opt_exec_shared.h:175
REF_SLICE_TMP2
@ REF_SLICE_TMP2
The slice with pointers to columns of 2nd group-order-distinct tmp table.
Definition: sql_opt_exec_shared.h:613
QEP_shared_owner::first_inner
plan_idx first_inner() const
Definition: sql_opt_exec_shared.h:495
QEP_shared::quick
QUICK_SELECT_I * quick() const
Definition: sql_opt_exec_shared.h:294
Item_func_match
Definition: item_func.h:3311
QEP_shared::set_sj_mat_exec
void set_sj_mat_exec(Semijoin_mat_exec *s)
Definition: sql_opt_exec_shared.h:267
TABLE_REF
Definition: sql_opt_exec_shared.h:58
CACHE_FIELD
Definition: sql_join_buffer.h:59
QEP_shared::m_keys
Key_map m_keys
All keys with can be used.
Definition: sql_opt_exec_shared.h:422
QEP_shared::m_last_sj_inner
plan_idx m_last_sj_inner
Definition: sql_opt_exec_shared.h:378
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_shared::ref
TABLE_REF & ref()
Definition: sql_opt_exec_shared.h:278
QEP_shared::m_last_inner
plan_idx m_last_inner
last table table for embedding outer join
Definition: sql_opt_exec_shared.h:384
QEP_shared::m_index
uint m_index
ID of index used for index scan or semijoin LooseScan.
Definition: sql_opt_exec_shared.h:395
QEP_shared_owner::type
enum join_type type() const
Definition: sql_opt_exec_shared.h:506
QEP_shared_owner::join
JOIN * join() const
Definition: sql_opt_exec_shared.h:476
QEP_shared::is_first_inner_for_outer_join
bool is_first_inner_for_outer_join() const
Definition: sql_opt_exec_shared.h:326
QEP_shared::sj_mat_exec
Semijoin_mat_exec * sj_mat_exec() const
Definition: sql_opt_exec_shared.h:266
store_key
class to copying an field/item to a key struct
Definition: sql_select.h:783
p
const char * p
Definition: ctype-mb.cc:1233
QEP_shared::m_first_inner
plan_idx m_first_inner
first inner table for including outer join
Definition: sql_opt_exec_shared.h:383
QEP_shared::set_first_upper
void set_first_upper(plan_idx i)
Definition: sql_opt_exec_shared.h:275
QEP_shared_owner::set_skip_records_in_range
void set_skip_records_in_range(bool skip_records_in_range)
Definition: sql_opt_exec_shared.h:547
QEP_shared::set_type
void set_type(enum join_type t)
Definition: sql_opt_exec_shared.h:282
QEP_shared_owner::m_qs
QEP_shared * m_qs
Definition: sql_opt_exec_shared.h:556
QEP_shared_owner::qs_cleanup
void qs_cleanup()
Definition: sql_select.cc:3295
QEP_shared_owner::set_last_sj_inner
void set_last_sj_inner(plan_idx i)
Definition: sql_opt_exec_shared.h:501
QEP_shared_owner::ft_func
Item_func_match * ft_func() const
Definition: sql_opt_exec_shared.h:523
QEP_shared::set_last_sj_inner
void set_last_sj_inner(plan_idx i)
Definition: sql_opt_exec_shared.h:274
REF_SLICE_WIN_1
@ REF_SLICE_WIN_1
The slice with pointers to columns of 1st tmp table of windowing.
Definition: sql_opt_exec_shared.h:669
TABLE_REF::key_copy
store_key ** key_copy
Used to store the value from each keypart field.
Definition: sql_opt_exec_shared.h:70
QEP_shared::join
JOIN * join() const
Definition: sql_opt_exec_shared.h:252
false
#define false
Definition: config_static.h:43
item.h