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