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