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