MySQL 8.0.37
Source Code Documentation
sql_executor.h
Go to the documentation of this file.
1#ifndef SQL_EXECUTOR_INCLUDED
2#define SQL_EXECUTOR_INCLUDED
3
4/* Copyright (c) 2000, 2024, Oracle and/or its affiliates.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License, version 2.0,
8 as published by the Free Software Foundation.
9
10 This program is designed to work with certain software (including
11 but not limited to OpenSSL) that is licensed under separate terms,
12 as designated in a particular file or component or in included license
13 documentation. The authors of MySQL hereby grant you an additional
14 permission to link the program and your derivative works with the
15 separately licensed software that they have either included with
16 the program or referenced in the documentation.
17
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License, version 2.0, for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software
25 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
26
27/**
28 @file sql/sql_executor.h
29 Classes for query execution.
30*/
31
32#include <sys/types.h>
33#include <cstring>
34#include <memory>
35#include <string>
36#include <vector>
37
38#include "my_alloc.h"
39#include "my_inttypes.h"
40#include "my_table_map.h"
42#include "sql/sql_lex.h"
43#include "sql/sql_opt_exec_shared.h" // QEP_shared_owner
44#include "sql/table.h"
45#include "sql/temp_table_param.h" // Temp_table_param
46
48class Cached_item;
49class Field;
50class Field_longlong;
51class Filesort;
53class Item;
54class Item_sum;
55class JOIN;
56class JOIN_TAB;
57class KEY;
60class QEP_TAB;
61class RowIterator;
62class THD;
63class Window;
64template <class T>
65class mem_root_deque;
66
68struct AccessPath;
69struct CACHE_FIELD;
70struct POSITION;
71template <class T>
72class List;
73template <typename Element_type>
74class Mem_root_array;
75
76/*
77 Array of pointers to tables whose rowids compose the temporary table
78 record.
79*/
83 ushort null_byte;
85};
86
87/*
88 Temporary table used by semi-join DuplicateElimination strategy
89
90 This consists of the temptable itself and data needed to put records
91 into it. The table's DDL is as follows:
92
93 CREATE TABLE tmptable (col VARCHAR(n) BINARY, PRIMARY KEY(col));
94
95 where the primary key can be replaced with unique constraint if n exceeds
96 the limit (as it is always done for query execution-time temptables).
97
98 The record value is a concatenation of rowids of tables from the join we're
99 executing. If a join table is on the inner side of the outer join, we
100 assume that its rowid can be NULL and provide means to store this rowid in
101 the tuple.
102*/
103
105 public:
109
110 /*
111 is_confluent==true means this is a special case where the temptable record
112 has zero length (and presence of a unique key means that the temptable can
113 have either 0 or 1 records).
114 In this case we don't create the physical temptable but instead record
115 its state in SJ_TMP_TABLE::have_confluent_record.
116 */
118
119 /*
120 When is_confluent==true: the contents of the table (whether it has the
121 record or not).
122 */
124
125 /* table record parameters */
129
130 /* The temporary table itself (NULL means not created yet) */
132
133 /* Pointer to next table (next->start_idx > this->end_idx) */
135 /* Calc hash instead of too long key */
137};
138
139/**
140 Executor structure for the materialized semi-join info, which contains
141 - Description of expressions selected from subquery
142 - The sj-materialization temporary table
143*/
145 public:
148 : sj_nest(sj_nest),
153 table_param(),
154 table(nullptr) {}
156 Table_ref *const sj_nest; ///< Semi-join nest for this materialization
157 const bool is_scan; ///< true if executing a scan, false if lookup
158 const uint table_count; ///< Number of tables in the sj-nest
159 const uint mat_table_index; ///< Index in join_tab for materialized table
160 const uint inner_table_index; ///< Index in join_tab for first inner table
161 Temp_table_param table_param; ///< The temptable and its related info
162 TABLE *table; ///< Reference to temporary table
163};
164
166
167[[nodiscard]] bool copy_fields(Temp_table_param *param, const THD *thd,
168 bool reverse_copy = false);
169
170enum Copy_func_type : int {
171 /**
172 In non-windowing step, copies functions
173 */
175 /**
176 In windowing step, copies framing window function, including
177 all grouping aggregates, e.g. SUM, AVG and FIRST_VALUE, LAST_VALUE.
178 */
180 /**
181 In windowing step, copies non framing window function, e.g.
182 ROW_NUMBER, RANK, DENSE_RANK, except those that are two_pass cf.
183 copy_two_pass_window_functions which are treated separately.
184 */
186 /**
187 In windowing step, copies window functions that need frame cardinality,
188 that is we need to read all rows of a partition before we can compute the
189 wf's value for the the first row in the partition.
190 */
192 /**
193 In windowing step, copies framing window functions that read only one row
194 per frame.
195 */
197 /**
198 In first windowing step, copies non-window functions which do not rely on
199 window functions, i.e. those that have Item::has_wf() == false.
200 */
202 /**
203 In final windowing step, copies all non-wf functions. Must be called after
204 all wfs have been evaluated, as non-wf functions may reference wf,
205 e.g. 1+RANK.
206 */
208 /**
209 Copies all window functions.
210 */
212 /**
213 Copies Item_field only (typically because other functions might depend
214 on those fields).
215 */
217};
218
219bool copy_funcs(Temp_table_param *, const THD *thd,
221
222/**
223 Copy the lookup key into the table ref's key buffer.
224
225 @param thd pointer to the THD object
226 @param table the table to read
227 @param ref information about the index lookup key
228
229 @retval false ref key copied successfully
230 @retval true error detected during copying of key
231*/
232bool construct_lookup(THD *thd, TABLE *table, Index_lookup *ref);
233
234/** Help function when we get some an error from the table handler. */
235int report_handler_error(TABLE *table, int error);
236
238
239int do_sj_dups_weedout(THD *thd, SJ_TMP_TABLE *sjtbl);
241
242// Create list for using with temporary table
244 Ref_item_array ref_item_array,
245 mem_root_deque<Item *> *res_fields,
246 size_t added_non_hidden_fields);
247// Create list for using with temporary table
249 THD *thd, Query_block *select,
250 Ref_item_array ref_item_array,
251 mem_root_deque<Item *> *res_fields,
252 size_t added_non_hidden_fields);
253bool prepare_sum_aggregators(Item_sum **func_ptr, bool need_distinct);
254bool setup_sum_funcs(THD *thd, Item_sum **func_ptr);
255bool make_group_fields(JOIN *main_join, JOIN *curr_join);
256bool check_unique_constraint(TABLE *table);
257ulonglong unique_hash(const Field *field, ulonglong *hash);
258int read_const(TABLE *table, Index_lookup *ref);
259
260class QEP_TAB : public QEP_shared_owner {
261 public:
270 rematerialize(false),
276 m_keyread_optim(false),
277 m_reversed_access(false),
279
280 /// Initializes the object from a JOIN_TAB
281 void init(JOIN_TAB *jt);
282 // Cleans up.
283 void cleanup();
284
285 // Getters and setters
286
289 bool keyread_optim() const { return m_keyread_optim; }
292 }
293 bool reversed_access() const { return m_reversed_access; }
294 void set_reversed_access(bool arg) { m_reversed_access = arg; }
295
296 void set_table(TABLE *t) {
297 m_qs->set_table(t);
298 if (t) t->reginfo.qep_tab = this;
299 }
300
301 /// @returns semijoin strategy for this table.
302 uint get_sj_strategy() const;
303
304 /// Return true if join_tab should perform a FirstMatch action
305 bool do_firstmatch() const { return firstmatch_return != NO_PLAN_IDX; }
306
307 /// Return true if join_tab should perform a LooseScan action
308 bool do_loosescan() const { return loosescan_key_len; }
309
310 /// Return true if join_tab starts a Duplicate Weedout action
311 bool starts_weedout() const { return flush_weedout_table; }
312
313 /// Return true if join_tab finishes a Duplicate Weedout action
314 bool finishes_weedout() const { return check_weed_out_table; }
315
316 /**
317 A helper function that allocates appropriate join cache object and
318 sets next_query_block function of previous tab.
319 */
320 void init_join_cache(JOIN_TAB *join_tab);
321
322 /**
323 @returns query block id for an inner table of materialized semi-join, and
324 0 for all other tables.
325 @note implementation is not efficient (loops over all tables) - use this
326 function only in EXPLAIN.
327 */
328 uint sjm_query_block_id() const;
329
330 /// @returns whether this is doing QS_DYNAMIC_RANGE
331 bool dynamic_range() const {
332 if (!position()) return false; // tmp table
333 return using_dynamic_range;
334 }
335
336 bool use_order() const; ///< Use ordering provided by chosen index?
337
338 /**
339 Construct an access path for reading from this table in the query,
340 using the access method that has been determined previously
341 (e.g., table scan, ref access, optional sort afterwards, etc.).
342 */
344 void push_index_cond(const JOIN_TAB *join_tab, uint keyno,
345 Opt_trace_object *trace_obj);
346
347 /// @return the index used for a table in a QEP
348 uint effective_index() const;
349
350 bool pfs_batch_update(const JOIN *join) const;
351
352 public:
353 /// Pointer to table reference
355
356 /* Variables for semi-join duplicate elimination */
359
360 /*
361 If set, means we should stop join enumeration after we've got the first
362 match and return to the specified join tab. May be PRE_FIRST_PLAN_IDX
363 which means stopping join execution after the first match.
364 */
366
367 /*
368 Length of key tuple (depends on #keyparts used) to use for loose scan.
369 If zero, means that loosescan is not used.
370 */
372
373 /*
374 If doing a LooseScan, this QEP is the first (i.e. "driving")
375 QEP_TAB, and match_tab points to the last QEP_TAB handled by the strategy.
376 match_tab->found_match should be checked to see if the current value group
377 had a match.
378 */
380
381 /// Dependent table functions have to be materialized on each new scan
383
389 };
392
393 /** true <=> remove duplicates on this table. */
395
396 // If we have a query of the type SELECT DISTINCT t1.* FROM t1 JOIN t2
397 // ON ..., (ie., we join in one or more tables that we don't actually
398 // read any columns from), we can stop scanning t2 as soon as we see the
399 // first row. This pattern seems to be a workaround for lack of semijoins
400 // in older versions of MySQL.
402
403 /** HAVING condition for checking prior saving a record into tmp table*/
405
406 // Operation between the previous QEP_TAB and this one.
408 // Regular nested loop.
410
411 // Aggregate (GROUP BY).
413
414 // Various temporary table operations, used at the end of the join.
419
420 // Block-nested loop (rewritten to hash join).
422
423 // Batch key access.
424 OT_BKA
426
427 /* Tmp table info */
429
430 /* Sorting related info */
432
433 /**
434 If we pushed a global ORDER BY down onto this first table, that ORDER BY
435 list will be preserved here.
436 */
438
439 /**
440 Slice number of the ref items array to switch to before reading rows from
441 this table.
442 */
444
445 /// Condition as it was set by the optimizer, used for EXPLAIN.
446 /// m_condition may be overwritten at a later stage.
448
449 /**
450 True if only index is going to be read for this table. This is the
451 optimizer's decision.
452 */
454
455 /**
456 True if reversed scan is used. This is the optimizer's decision.
457 */
459
460 /**
461 Maps of all lateral derived tables which should be refreshed when
462 execution reads a new row from this table.
463 @note that if a LDT depends on t1 and t2, and t2 is after t1 in the plan,
464 then only t2::lateral_derived_tables_depend_on_me gets the map of the
465 LDT, for efficiency (less useless calls to QEP_TAB::refresh_lateral())
466 and clarity in EXPLAIN.
467 */
469
471
472 QEP_TAB(const QEP_TAB &); // not defined
473 QEP_TAB &operator=(const QEP_TAB &); // not defined
474};
475
476bool set_record_buffer(TABLE *table, double expected_rows_to_fetch);
478void update_tmptable_sum_func(Item_sum **func_ptr, TABLE *tmp_table);
479bool has_rollup_result(Item *item);
480bool is_rollup_group_wrapper(const Item *item);
482
483/*
484 If a condition cannot be applied right away, for instance because it is a
485 WHERE condition and we're on the right side of an outer join, we have to
486 return it up so that it can be applied on a higher recursion level.
487 This structure represents such a condition.
488 */
491 int table_index_to_attach_to; // -1 means “on the last possible outer join”.
492};
493
494/**
495 Cache invalidator iterators we need to apply, but cannot yet due to outer
496 joins. As soon as “table_index_to_invalidate” is visible in our current join
497 nest (which means there could no longer be NULL-complemented rows we could
498 forget), we can and must output this invalidator and remove it from the array.
499 */
501 /**
502 The table whose every (post-join) row invalidates one or more derived
503 lateral tables.
504 */
507};
508
515
516/**
517 Create an AND conjunction of all given items. If there are no items, returns
518 nullptr. If there's only one item, returns that item.
519 */
521
524 const std::vector<Item *> &conditions, THD *thd);
525
526void SplitConditions(Item *condition, QEP_TAB *current_table,
527 std::vector<Item *> *predicates_below_join,
528 std::vector<PendingCondition> *predicates_above_join,
529 std::vector<PendingCondition> *join_conditions,
530 plan_idx semi_join_table_idx, qep_tab_map left_tables);
531
532/**
533 For a MATERIALIZE access path, move any non-basic iterators (e.g. sorts and
534 filters) from table_path to above the path, for easier EXPLAIN and generally
535 simpler structure. Note the assert in CreateIteratorFromAccessPath() that we
536 succeeded. (ALTERNATIVE counts as a basic iterator in this regard.)
537
538 We do this by finding the second-bottommost access path, and inserting our
539 materialize node as its child. The bottommost one becomes the actual table
540 access path.
541
542 If a ZERO_ROWS access path is materialized, we simply replace the MATERIALIZE
543 path with the ZERO_ROWS path, since there is nothing to materialize.
544 @param path the MATERIALIZE path.
545 @param query_block The query block in which 'path' belongs.
546 @returns The new root of the set of AccessPaths formed by 'path' and its
547 descendants.
548 */
550 const Query_block &query_block);
551
553 AccessPath *table_path);
555 THD *thd, Table_ref *table_ref, TABLE *table, bool rematerialize,
556 Mem_root_array<const AccessPath *> *invalidators, bool need_rowid,
557 AccessPath *table_path);
558
559void ConvertItemsToCopy(const mem_root_deque<Item *> &items, Field **fields,
560 Temp_table_param *param);
561std::string RefToString(const Index_lookup &ref, const KEY *key,
562 bool include_nulls);
563
565
566/**
567 Split AND conditions into their constituent parts, recursively.
568 Conditions that are not AND conditions are appended unchanged onto
569 condition_parts. E.g. if you have ((a AND b) AND c), condition_parts
570 will contain [a, b, c], plus whatever it contained before the call.
571 */
572bool ExtractConditions(Item *condition,
573 Mem_root_array<Item *> *condition_parts);
574
576 AccessPath *range_scan,
577 Table_ref *table_ref, POSITION *position,
578 bool count_examined_rows);
579
580/**
581 Creates an iterator for the given table, then calls Init() on the resulting
582 iterator. Unlike create_table_iterator(), this can create iterators for sort
583 buffer results (which are set in the TABLE object during query execution).
584 Returns nullptr on failure.
585 */
587 THD *thd, TABLE *table, AccessPath *range_scan, Table_ref *table_ref,
588 POSITION *position, bool ignore_not_found_rows, bool count_examined_rows);
589
590/**
591 A short form for when there's no range scan, recursive CTEs or cost
592 information; just a unique_result or a simple table scan. Normally, you should
593 prefer just instantiating an iterator yourself -- this is for legacy use only.
594 */
596 THD *thd, TABLE *table, bool ignore_not_found_rows,
597 bool count_examined_rows) {
598 return init_table_iterator(thd, table, nullptr, nullptr, nullptr,
599 ignore_not_found_rows, count_examined_rows);
600}
601
602AccessPath *ConnectJoins(plan_idx upper_first_idx, plan_idx first_idx,
603 plan_idx last_idx, QEP_TAB *qep_tabs, THD *thd,
604 CallingContext calling_context,
605 std::vector<PendingCondition> *pending_conditions,
606 std::vector<PendingInvalidator> *pending_invalidators,
607 std::vector<PendingCondition> *pending_join_conditions,
608 qep_tab_map *unhandled_duplicates,
609 table_map *conditions_depend_on_outer_tables);
610
611#endif /* SQL_EXECUTOR_INCLUDED */
An iterator that helps invalidating caches.
Definition: composite_iterators.h:392
This is used for segregating rows in groups (e.g.
Definition: item.h:6340
Definition: field.h:2386
Definition: field.h:575
Sorting related info.
Definition: filesort.h:52
FollowTailIterator is a special version of TableScanIterator that is used as part of WITH RECURSIVE q...
Definition: basic_row_iterators.h:439
Class Item_sum is the base class used for special expressions that SQL calls 'set functions'.
Definition: item_sum.h:399
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:851
Query optimization plan node.
Definition: sql_select.h:599
Definition: sql_optimizer.h:133
Definition: key.h:113
Definition: sql_list.h:434
A typesafe replacement for DYNAMIC_ARRAY.
Definition: mem_root_array.h:426
The iterator actually doing the reads from the inner table during BKA.
Definition: bka_iterator.h:264
A JSON object (unordered set of key/value pairs).
Definition: opt_trace.h:799
Definition: sql_executor.h:260
uint loosescan_key_len
Definition: sql_executor.h:371
bool dynamic_range() const
Definition: sql_executor.h:331
Setup_func materialize_table
Definition: sql_executor.h:390
void set_reversed_access(bool arg)
Definition: sql_executor.h:294
Item * m_condition_optim
Condition as it was set by the optimizer, used for EXPLAIN.
Definition: sql_executor.h:447
bool rematerialize
Dependent table functions have to be materialized on each new scan.
Definition: sql_executor.h:382
bool keyread_optim() const
Definition: sql_executor.h:289
Filesort * filesort
Definition: sql_executor.h:431
bool reversed_access() const
Definition: sql_executor.h:293
void set_table(TABLE *t)
Definition: sql_executor.h:296
uint ref_item_slice
Slice number of the ref items array to switch to before reading rows from this table.
Definition: sql_executor.h:443
bool m_reversed_access
True if reversed scan is used.
Definition: sql_executor.h:458
qep_tab_map lateral_derived_tables_depend_on_me
Maps of all lateral derived tables which should be refreshed when execution reads a new row from this...
Definition: sql_executor.h:468
bool needs_duplicate_removal
true <=> remove duplicates on this table.
Definition: sql_executor.h:394
plan_idx firstmatch_return
Definition: sql_executor.h:365
enum QEP_TAB::enum_op_type op_type
bool do_firstmatch() const
Return true if join_tab should perform a FirstMatch action.
Definition: sql_executor.h:305
ORDER * filesort_pushed_order
If we pushed a global ORDER BY down onto this first table, that ORDER BY list will be preserved here.
Definition: sql_executor.h:437
Setup_func
Definition: sql_executor.h:384
@ NO_SETUP
Definition: sql_executor.h:385
@ MATERIALIZE_TABLE_FUNCTION
Definition: sql_executor.h:386
@ MATERIALIZE_SEMIJOIN
Definition: sql_executor.h:388
@ MATERIALIZE_DERIVED
Definition: sql_executor.h:387
QEP_TAB()
Definition: sql_executor.h:262
Item * condition_optim() const
Definition: sql_executor.h:287
QEP_TAB & operator=(const QEP_TAB &)
bool not_used_in_distinct
Definition: sql_executor.h:401
bool starts_weedout() const
Return true if join_tab starts a Duplicate Weedout action.
Definition: sql_executor.h:311
bool m_keyread_optim
True if only index is going to be read for this table.
Definition: sql_executor.h:453
bool using_dynamic_range
Definition: sql_executor.h:391
bool finishes_weedout() const
Return true if join_tab finishes a Duplicate Weedout action.
Definition: sql_executor.h:314
bool do_loosescan() const
Return true if join_tab should perform a LooseScan action.
Definition: sql_executor.h:308
Item * having
HAVING condition for checking prior saving a record into tmp table.
Definition: sql_executor.h:404
SJ_TMP_TABLE * flush_weedout_table
Definition: sql_executor.h:357
Temp_table_param * tmp_table_param
Definition: sql_executor.h:428
void set_condition_optim()
Definition: sql_executor.h:288
plan_idx match_tab
Definition: sql_executor.h:379
Table_ref * table_ref
Pointer to table reference.
Definition: sql_executor.h:354
SJ_TMP_TABLE * check_weed_out_table
Definition: sql_executor.h:358
enum_op_type
Definition: sql_executor.h:407
@ OT_MATERIALIZE
Definition: sql_executor.h:415
@ OT_BKA
Definition: sql_executor.h:424
@ OT_AGGREGATE_INTO_TMP_TABLE
Definition: sql_executor.h:417
@ OT_AGGREGATE
Definition: sql_executor.h:412
@ OT_BNL
Definition: sql_executor.h:421
@ OT_AGGREGATE_THEN_MATERIALIZE
Definition: sql_executor.h:416
@ OT_WINDOWING_FUNCTION
Definition: sql_executor.h:418
@ OT_NONE
Definition: sql_executor.h:409
Mem_root_array< const AccessPath * > * invalidators
Definition: sql_executor.h:470
QEP_TAB(const QEP_TAB &)
void set_keyread_optim()
Definition: sql_executor.h:290
Owner of a QEP_shared; parent of JOIN_TAB and QEP_TAB.
Definition: sql_opt_exec_shared.h:478
JOIN * join() const
Definition: sql_opt_exec_shared.h:491
TABLE * table() const
Definition: sql_opt_exec_shared.h:504
QEP_shared * m_qs
Definition: sql_opt_exec_shared.h:574
Item * condition() const
Definition: sql_opt_exec_shared.h:526
POSITION * position() const
Definition: sql_opt_exec_shared.h:505
void set_table(TABLE *t)
Definition: sql_opt_exec_shared.h:277
This class represents a query block, aka a query specification, which is a query consisting of a SELE...
Definition: sql_lex.h:1156
A context for reading through a single table using a chosen access method: index read,...
Definition: row_iterator.h:82
Definition: sql_executor.h:104
uint rowid_len
Definition: sql_executor.h:128
TABLE * tmp_table
Definition: sql_executor.h:131
SJ_TMP_TABLE_TAB * tabs
Definition: sql_executor.h:107
SJ_TMP_TABLE * next
Definition: sql_executor.h:134
uint null_bits
Definition: sql_executor.h:126
SJ_TMP_TABLE_TAB * tabs_end
Definition: sql_executor.h:108
bool have_confluent_row
Definition: sql_executor.h:123
SJ_TMP_TABLE()
Definition: sql_executor.h:106
uint null_bytes
Definition: sql_executor.h:127
bool is_confluent
Definition: sql_executor.h:117
Field_longlong * hash_field
Definition: sql_executor.h:136
Executor structure for the materialized semi-join info, which contains.
Definition: sql_executor.h:144
const bool is_scan
true if executing a scan, false if lookup
Definition: sql_executor.h:157
TABLE * table
Reference to temporary table.
Definition: sql_executor.h:162
Table_ref *const sj_nest
Semi-join nest for this materialization.
Definition: sql_executor.h:156
const uint inner_table_index
Index in join_tab for first inner table.
Definition: sql_executor.h:160
const uint mat_table_index
Index in join_tab for materialized table.
Definition: sql_executor.h:159
Temp_table_param table_param
The temptable and its related info.
Definition: sql_executor.h:161
~Semijoin_mat_exec()=default
const uint table_count
Number of tables in the sj-nest.
Definition: sql_executor.h:158
Semijoin_mat_exec(Table_ref *sj_nest, bool is_scan, uint table_count, uint mat_table_index, uint inner_table_index)
Definition: sql_executor.h:146
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:34
Definition: table.h:2790
Object containing parameters used when creating and using temporary tables.
Definition: temp_table_param.h:95
Represents the (explicit) window of a SQL 2003 section 7.11 <window clause>, or the implicit (inlined...
Definition: window.h:105
A (partial) implementation of std::deque allocating its blocks on a MEM_ROOT.
Definition: mem_root_deque.h:110
Fido Client Authentication nullptr
Definition: fido_client_plugin.cc:222
Item * unwrap_rollup_group(Item *item)
Definition: sql_executor.cc:338
void init_tmptable_sum_functions(Item_sum **func_ptr)
Definition: sql_executor.cc:398
bool pfs_batch_update(const JOIN *join) const
Definition: sql_executor.cc:4635
bool setup_sum_funcs(THD *thd, Item_sum **func_ptr)
Call setup() for all sum functions.
Definition: sql_executor.cc:389
bool copy_funcs(Temp_table_param *, const THD *thd, Copy_func_type type=CFT_ALL)
Copy result of functions to record in tmp_table.
Definition: sql_executor.cc:430
bool has_rollup_result(Item *item)
Checks if an item has a ROLLUP NULL which needs to be written to temp table.
Definition: sql_executor.cc:308
int join_read_const_table(JOIN_TAB *tab, POSITION *pos)
Reads content of constant table.
Definition: sql_executor.cc:3482
bool construct_lookup(THD *thd, TABLE *table, Index_lookup *ref)
Copy the lookup key into the table ref's key buffer.
Definition: sql_executor.cc:4063
ulonglong unique_hash(const Field *field, ulonglong *hash)
Generate hash for a field.
Definition: sql_executor.cc:3942
int do_sj_dups_weedout(THD *thd, SJ_TMP_TABLE *sjtbl)
SemiJoinDuplicateElimination: Weed out duplicate row combinations.
Definition: sql_executor.cc:3385
AccessPath * MoveCompositeIteratorsFromTablePath(AccessPath *path, const Query_block &query_block)
For a MATERIALIZE access path, move any non-basic iterators (e.g.
Definition: sql_executor.cc:1535
int report_handler_error(TABLE *table, int error)
Help function when we get some an error from the table handler.
Definition: sql_executor.cc:3455
void setup_tmptable_write_func(QEP_TAB *tab, Opt_trace_object *trace)
Setup write_func of QEP_tmp_table object.
Definition: sql_executor.cc:519
int update_item_cache_if_changed(List< Cached_item > &list)
Definition: sql_executor.cc:4145
AccessPath * access_path()
Construct an access path for reading from this table in the query, using the access method that has b...
Definition: sql_executor.cc:3699
int read_const(TABLE *table, Index_lookup *ref)
Definition: sql_executor.cc:3613
bool use_order() const
Use ordering provided by chosen index?
Definition: sql_executor.cc:3673
bool is_rollup_group_wrapper(const Item *item)
Definition: sql_executor.cc:332
AccessPath * GetAccessPathForDerivedTable(THD *thd, QEP_TAB *qep_tab, AccessPath *table_path)
Definition: sql_executor.cc:1473
bool change_to_use_tmp_fields_except_sums(mem_root_deque< Item * > *fields, THD *thd, Query_block *select, Ref_item_array ref_item_array, mem_root_deque< Item * > *res_fields, size_t added_non_hidden_fields)
Change all sum_func refs to fields to point at fields in tmp table.
Definition: sql_executor.cc:4407
bool change_to_use_tmp_fields(mem_root_deque< Item * > *fields, THD *thd, Ref_item_array ref_item_array, mem_root_deque< Item * > *res_fields, size_t added_non_hidden_fields)
Change all funcs and sum_funcs to fields in tmp table, and create new list of all items.
Definition: sql_executor.cc:4255
bool check_unique_constraint(TABLE *table)
Check unique_constraint.
Definition: sql_executor.cc:4035
std::string RefToString(const Index_lookup &ref, const KEY *key, bool include_nulls)
Definition: sql_executor.cc:131
bool make_group_fields(JOIN *main_join, JOIN *curr_join)
allocate group fields or take prepared (cached).
Definition: sql_executor.cc:4103
void update_tmptable_sum_func(Item_sum **func_ptr, TABLE *tmp_table)
Update record 0 in tmp_table from record 1.
Definition: sql_executor.cc:406
Item * CreateConjunction(List< Item > *items)
Create an AND conjunction of all given items.
Definition: sql_executor.cc:736
bool set_record_buffer(TABLE *table, double expected_rows_to_fetch)
Allocate a data buffer that the storage engine can use for fetching batches of records.
Definition: sql_executor.cc:655
bool copy_fields(Temp_table_param *param, const THD *thd, bool reverse_copy=false)
Make a copy of all simple SELECT'ed fields.
Definition: sql_executor.cc:4192
void ConvertItemsToCopy(const mem_root_deque< Item * > &items, Field **fields, Temp_table_param *param)
For historical reasons, derived table materialization and temporary table materialization didn't spec...
Definition: sql_executor.cc:927
bool ExtractConditions(Item *condition, Mem_root_array< Item * > *condition_parts)
Split AND conditions into their constituent parts, recursively.
Definition: sql_executor.cc:708
bool prepare_sum_aggregators(Item_sum **func_ptr, bool need_distinct)
Definition: sql_executor.cc:363
void init(JOIN_TAB *jt)
Initializes the object from a JOIN_TAB.
Definition: sql_optimizer.cc:1319
void init_join_cache(JOIN_TAB *join_tab)
A helper function that allocates appropriate join cache object and sets next_query_block function of ...
Definition: sql_select.cc:3240
void push_index_cond(const JOIN_TAB *join_tab, uint keyno, Opt_trace_object *trace_obj)
Try to extract and push the index condition down to table handler.
Definition: sql_select.cc:2911
void cleanup()
Definition: sql_select.cc:3497
uint sjm_query_block_id() const
Definition: sql_select.cc:3553
uint effective_index() const
Return the index used for a table in a QEP.
Definition: sql_optimizer.cc:1346
uint get_sj_strategy() const
Definition: sql_optimizer.cc:1326
This file follows Google coding style, except for the name MEM_ROOT (which is kept for historical rea...
std::unique_ptr< T, Destroy_only< T > > unique_ptr_destroy_only
std::unique_ptr, but only destroying.
Definition: my_alloc.h:489
Some integer typedefs for easier portability.
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
Log error(cerr, "ERROR")
static char * path
Definition: mysqldump.cc:137
PT & ref(PT *tp)
Definition: tablespace_impl.cc:359
std::list< T, ut::allocator< T > > list
Specialization of list which uses ut_allocator.
Definition: ut0new.h:2878
required string key
Definition: replication_asynchronous_connection_failover.proto:60
required string type
Definition: replication_group_member_actions.proto:34
AccessPath * ConnectJoins(plan_idx upper_first_idx, plan_idx first_idx, plan_idx last_idx, QEP_TAB *qep_tabs, THD *thd, CallingContext calling_context, std::vector< PendingCondition > *pending_conditions, std::vector< PendingInvalidator > *pending_invalidators, std::vector< PendingCondition > *pending_join_conditions, qep_tab_map *unhandled_duplicates, table_map *conditions_depend_on_outer_tables)
bool MaterializeIsDoingDeduplication(TABLE *table)
(end of group Query_Executor)
Definition: sql_executor.cc:4653
AccessPath * create_table_access_path(THD *thd, TABLE *table, AccessPath *range_scan, Table_ref *table_ref, POSITION *position, bool count_examined_rows)
create_table_access_path is used to scan by using a number of different methods.
Definition: sql_executor.cc:4688
unique_ptr_destroy_only< RowIterator > PossiblyAttachFilterIterator(unique_ptr_destroy_only< RowIterator > iterator, const std::vector< Item * > &conditions, THD *thd)
void SplitConditions(Item *condition, QEP_TAB *current_table, std::vector< Item * > *predicates_below_join, std::vector< PendingCondition > *predicates_above_join, std::vector< PendingCondition > *join_conditions, plan_idx semi_join_table_idx, qep_tab_map left_tables)
CallingContext
Definition: sql_executor.h:509
@ DIRECTLY_UNDER_OUTER_JOIN
Definition: sql_executor.h:512
@ TOP_LEVEL
Definition: sql_executor.h:510
@ DIRECTLY_UNDER_WEEDOUT
Definition: sql_executor.h:513
@ DIRECTLY_UNDER_SEMIJOIN
Definition: sql_executor.h:511
unique_ptr_destroy_only< RowIterator > init_table_iterator(THD *thd, TABLE *table, AccessPath *range_scan, Table_ref *table_ref, POSITION *position, bool ignore_not_found_rows, bool count_examined_rows)
Creates an iterator for the given table, then calls Init() on the resulting iterator.
Definition: sql_executor.cc:4708
Copy_func_type
Definition: sql_executor.h:170
@ CFT_HAS_NO_WF
In first windowing step, copies non-window functions which do not rely on window functions,...
Definition: sql_executor.h:201
@ CFT_WF_NON_FRAMING
In windowing step, copies non framing window function, e.g.
Definition: sql_executor.h:185
@ CFT_WF_NEEDS_PARTITION_CARDINALITY
In windowing step, copies window functions that need frame cardinality, that is we need to read all r...
Definition: sql_executor.h:191
@ CFT_WF_FRAMING
In windowing step, copies framing window function, including all grouping aggregates,...
Definition: sql_executor.h:179
@ CFT_ALL
In non-windowing step, copies functions.
Definition: sql_executor.h:174
@ CFT_FIELDS
Copies Item_field only (typically because other functions might depend on those fields).
Definition: sql_executor.h:216
@ CFT_HAS_WF
In final windowing step, copies all non-wf functions.
Definition: sql_executor.h:207
@ CFT_WF_USES_ONLY_ONE_ROW
In windowing step, copies framing window functions that read only one row per frame.
Definition: sql_executor.h:196
@ CFT_WF
Copies all window functions.
Definition: sql_executor.h:211
Common types of the Optimizer, used by optimization and execution.
int plan_idx
This represents the index of a JOIN_TAB/QEP_TAB in an array.
Definition: sql_opt_exec_shared.h:54
@ REF_SLICE_SAVED_BASE
The slice with pointers to columns of table(s), ie., the actual Items.
Definition: sql_opt_exec_shared.h:638
#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:193
Structure used for index-based lookups.
Definition: sql_opt_exec_shared.h:67
Definition: table.h:281
A position of table within a join order.
Definition: sql_select.h:352
Definition: sql_executor.h:489
Item * cond
Definition: sql_executor.h:490
int table_index_to_attach_to
Definition: sql_executor.h:491
Cache invalidator iterators we need to apply, but cannot yet due to outer joins.
Definition: sql_executor.h:500
QEP_TAB * qep_tab
The table whose every (post-join) row invalidates one or more derived lateral tables.
Definition: sql_executor.h:505
plan_idx table_index_to_invalidate
Definition: sql_executor.h:506
Definition: sql_executor.h:80
QEP_TAB * qep_tab
Definition: sql_executor.h:81
ushort null_byte
Definition: sql_executor.h:83
uchar null_bit
Definition: sql_executor.h:84
uint rowid_offset
Definition: sql_executor.h:82
Definition: table.h:1398
class QEP_TAB * qep_tab
Definition: table.h:1832
bool key_read
If set, the optimizer has found that row retrieval should access index tree only.
Definition: table.h:1757
struct TABLE::@179 reginfo
unsigned int uint
Definition: uca9-dump.cc:75
Window_retrieve_cached_row_reason
Position hints for the frame buffer are saved for these kind of row accesses, cf.
Definition: window.h:65