MySQL  8.0.18
Source Code Documentation
composite_iterators.h
Go to the documentation of this file.
1 #ifndef SQL_COMPOSITE_ITERATORS_INCLUDED
2 #define SQL_COMPOSITE_ITERATORS_INCLUDED
3 
4 /* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
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 also distributed 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 included with MySQL.
16 
17  This program is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  GNU General Public License, version 2.0, for more details.
21 
22  You should have received a copy of the GNU General Public License
23  along with this program; if not, write to the Free Software
24  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
25 
26 /**
27  @file composite_iterators.h
28 
29  A composite row iterator is one that takes in one or more existing iterators
30  and processes their rows in some interesting way. They are usually not bound
31  to a single table or similar, but are the inner (non-leaf) nodes of the
32  iterator execution tree. They consistently own their source iterator, although
33  not its memory (since we never allocate row iterators on the heap--usually on
34  a MEM_ROOT>). This means that in the end, you'll end up with a single root
35  iterator which then owns everything else recursively.
36 
37  SortingIterator is also a composite iterator, but is defined in its own file.
38  */
39 
40 #include <stdio.h>
41 #include <algorithm>
42 #include <memory>
43 #include <string>
44 #include <vector>
45 
46 #include "my_alloc.h"
47 #include "my_base.h"
48 #include "my_dbug.h"
49 #include "my_table_map.h"
50 #include "prealloced_array.h"
51 #include "sql/item.h"
52 #include "sql/row_iterator.h"
53 #include "sql/table.h"
54 
55 class FollowTailIterator;
56 template <class T>
57 class List;
58 class JOIN;
59 class SELECT_LEX;
60 class SJ_TMP_TABLE;
61 class THD;
62 class Temp_table_param;
63 class Window;
64 
65 /**
66  An iterator that takes in a stream of rows and passes through only those that
67  meet some criteria (i.e., a condition evaluates to true). This is typically
68  used for WHERE/HAVING.
69  */
71  public:
73  Item *condition)
74  : RowIterator(thd), m_source(move(source)), m_condition(condition) {}
75 
76  bool Init() override { return m_source->Init(); }
77 
78  int Read() override;
79 
80  void SetNullRowFlag(bool is_null_row) override {
81  m_source->SetNullRowFlag(is_null_row);
82  }
83 
84  void StartPSIBatchMode() override { m_source->StartPSIBatchMode(); }
85  void EndPSIBatchModeIfStarted() override {
86  m_source->EndPSIBatchModeIfStarted();
87  }
88  void UnlockRow() override { m_source->UnlockRow(); }
89 
90  std::vector<Child> children() const override;
91 
92  std::vector<std::string> DebugString() const override {
93  return {"Filter: " + ItemToString(m_condition)};
94  }
95 
96  private:
99 };
100 
101 /**
102  Handles LIMIT and/or OFFSET; Init() eats the first "offset" rows, and Read()
103  stops as soon as it's seen "limit" rows (including any skipped by offset).
104  */
106  public:
107  /**
108  @param thd Thread context
109  @param source Row source
110  @param limit Maximum number of rows to read, including the ones skipped by
111  offset. Can be HA_POS_ERROR for no limit.
112  @param offset Number of initial rows to skip. Can be 0 for no offset.
113  @param count_all_rows If true, the query will run to completion to get
114  more accurate numbers for skipped_rows, so you will not get any
115  performance benefits of early end.
116  @param skipped_rows If not nullptr, is incremented for each row skipped by
117  offset or limit.
118  */
120  ha_rows limit, ha_rows offset, bool count_all_rows,
121  ha_rows *skipped_rows)
122  : RowIterator(thd),
123  m_source(move(source)),
124  m_limit(limit),
125  m_offset(offset),
126  m_count_all_rows(count_all_rows),
127  m_skipped_rows(skipped_rows) {
128  if (count_all_rows) {
129  DBUG_ASSERT(m_skipped_rows != nullptr);
130  }
131  }
132 
133  bool Init() override;
134 
135  int Read() override;
136 
137  void SetNullRowFlag(bool is_null_row) override {
138  m_source->SetNullRowFlag(is_null_row);
139  }
140 
141  void StartPSIBatchMode() override { m_source->StartPSIBatchMode(); }
142  void EndPSIBatchModeIfStarted() override {
143  m_source->EndPSIBatchModeIfStarted();
144  }
145  void UnlockRow() override { m_source->UnlockRow(); }
146 
147  std::vector<Child> children() const override {
148  return std::vector<Child>{{m_source.get(), ""}};
149  }
150 
151  std::vector<std::string> DebugString() const override {
152  char buf[256];
153  if (m_offset == 0) {
154  snprintf(buf, sizeof(buf), "Limit: %llu row(s)", m_limit);
155  } else if (m_limit == HA_POS_ERROR) {
156  snprintf(buf, sizeof(buf), "Offset: %llu row(s)", m_offset);
157  } else {
158  snprintf(buf, sizeof(buf), "Limit/Offset: %llu/%llu row(s)",
160  }
161  if (m_count_all_rows) {
162  return {std::string(buf) + " (no early end due to SQL_CALC_FOUND_ROWS)"};
163  } else {
164  return {std::string(buf)};
165  }
166  }
167 
168  private:
170 
171  // Note: The number of seen rows starts off at m_limit if we have OFFSET,
172  // which means we don't need separate LIMIT and OFFSET tests on the
173  // fast path of Read().
175 
176  /**
177  Whether we have OFFSET rows that we still need to skip.
178  */
180 
182  const bool m_count_all_rows;
184 };
185 
186 /**
187  Handles aggregation (typically used for GROUP BY) for the case where the rows
188  are already properly grouped coming in, ie., all rows that are supposed to be
189  part of the same group are adjacent in the input stream. (This could be
190  because they were sorted earlier, because we are scanning an index that
191  already gives us the rows in a group-compatible order, or because there is no
192  grouping.)
193 
194  AggregateIterator is special in that it's one of the very few row iterators
195  that actually change the shape of the rows; some columns are dropped as part
196  of aggregation, others (the aggregates) are added. For this reason (and also
197  because we need to make copies of the group expressions -- see Read()), it
198  conceptually always outputs to a temporary table. If we _are_ outputting to a
199  temporary table, that's not a problem -- we take over responsibility for
200  copying the group expressions from MaterializeIterator, which would otherwise
201  do it.
202 
203  However, if we are outputting directly to the user, we need somewhere to store
204  the output. This is solved by abusing the slice system; since we only need to
205  buffer a single row, we can set up just enough items in the
206  REF_SLICE_ORDERED_GROUP_BY slice, so that it can hold a single row. This row
207  is then used for our output, and we then switch to it just before the end of
208  Read() so that anyone reading from the buffers will get that output.
209  The caller knows the context about where our output goes, and thus also picks
210  the appropriate output slice for us.
211 
212  This isn't very pretty. What should be done is probably a more abstract
213  concept of sending a row around and taking copies of it if needed, as opposed
214  to it implicitly staying in the table's buffer. (This would also solve some
215  issues in EQRefIterator and when synthesizing NULL rows for outer joins.)
216  However, that's a large refactoring.
217  */
219  public:
221  JOIN *join, Temp_table_param *temp_table_param,
222  int output_slice, bool rollup);
223 
224  bool Init() override;
225  int Read() override;
226  void SetNullRowFlag(bool is_null_row) override {
227  m_source->SetNullRowFlag(is_null_row);
228  }
229 
230  void StartPSIBatchMode() override { m_source->StartPSIBatchMode(); }
231  void EndPSIBatchModeIfStarted() override {
232  m_source->EndPSIBatchModeIfStarted();
233  }
234  void UnlockRow() override {
235  // Most likely, HAVING failed. Ideally, we'd like to backtrack and
236  // unlock all rows that went into this aggregate, but we can't do that,
237  // and we also can't unlock the _current_ row, since that belongs to a
238  // different group. Thus, do nothing.
239  }
240 
241  std::vector<Child> children() const override {
242  return std::vector<Child>{{m_source.get(), ""}};
243  }
244 
245  std::vector<std::string> DebugString() const override;
246 
247  private:
248  enum {
254  } m_state;
255 
257 
258  /**
259  The join we are part of. It would be nicer not to rely on this,
260  but we need a large number of members from there, like which
261  aggregate functions we have, the THD, temporary table parameters
262  and so on.
263  */
264  JOIN *m_join = nullptr;
265 
266  /// The slice of the fields we are reading from (see the class comment).
268 
269  /// The slice of the fields we are outputting to. See the class comment.
271 
272  /// Whether we have seen the last input row.
274 
275  /**
276  Used to save NULL information in the specific case where we have
277  zero input rows.
278  */
280 
281  /// The parameters for the temporary table we are materializing into, if any.
283 
284  /// Whether this is a rollup query.
285  const bool m_rollup;
286 
287  /**
288  Whether we have a rollup query where we needed to replace m_join->fields
289  with a set of Item_refs. See the constructor for more information.
290  */
292 
293  /// If we have replaced the field list, contains the original field list.
295 
296  /**
297  If we have replaced the field list, this is the list of Item pointers
298  that each Item_ref points into.
299  */
301 
302  /**
303  The list that the current values in m_current_fields come from.
304  This is used purely as an optimization so that SwitchFieldList()
305  does not have to do copying work if m_current_fields is already set up
306  correctly. Only used if m_replace_field_list is true.
307  */
309 
310  /**
311  For rollup: The index of the first group item that did _not_ change when we
312  last switched groups. E.g., if we have group fields A,B,C,D and then switch
313  to group A,B,D,D, this value will become 1 (which means that we need
314  to output rollup rows for 2 -- A,B,D,NULL -- and then 1 -- A,B,NULL,NULL).
315  m_current_rollup_position will count down from the end until it becomes
316  less than this value.
317 
318  In addition, it is important to know this value so that we known
319  which aggregates to reset once we start reading rows again; e.g.,
320  in the given example, the two first aggregates should keep counting,
321  while the two last ones should be reset. join->sum_funcs_end contains
322  the right end pointers for this purpose.
323 
324  If we do not have rollup, this value is perennially zero, because there
325  is only one element in join->sum_funcs_end (representing all aggregates
326  in the query).
327  */
329 
330  /**
331  If we are in state OUTPUTTING_ROLLUP_ROWS, where we are in the iteration.
332  This value will start at the index of the last group expression and then
333  count backwards down to and including m_last_unchanged_group_item_idx.
334  It is used to know which field list we should send.
335  */
337 
338  void SwitchFieldList(List<Item> *fields) {
339  if (!m_replace_field_list || m_current_fields_source == fields) {
340  return;
341  }
342 
343  size_t item_index = 0;
344  for (Item &item : *fields) {
345  (*m_current_fields)[item_index++] = &item;
346  }
347  m_current_fields_source = fields;
348  }
349 };
350 
351 /**
352  Similar to AggregateIterator, but asusmes that the actual aggregates are
353  already have been filled out (typically by QUICK_RANGE_MIN_MAX), and all the
354  iterator needs to do is copy over the non-aggregated fields.
355  */
357  public:
360  JOIN *join, Temp_table_param *temp_table_param,
361  int output_slice)
362  : RowIterator(thd),
363  m_source(move(source)),
364  m_join(join),
365  m_temp_table_param(temp_table_param),
366  m_output_slice(output_slice) {}
367 
368  bool Init() override;
369  int Read() override;
370  void SetNullRowFlag(bool is_null_row) override {
371  m_source->SetNullRowFlag(is_null_row);
372  }
373 
374  void StartPSIBatchMode() override { m_source->StartPSIBatchMode(); }
375  void EndPSIBatchModeIfStarted() override {
376  m_source->EndPSIBatchModeIfStarted();
377  }
378  void UnlockRow() override {
379  // See AggregateIterator::UnlockRow().
380  }
381 
382  std::vector<Child> children() const override {
383  return std::vector<Child>{{m_source.get(), ""}};
384  }
385 
386  std::vector<std::string> DebugString() const override;
387 
388  private:
390 
391  /**
392  The join we are part of. It would be nicer not to rely on this,
393  but we need a large number of members from there, like which
394  aggregate functions we have, the THD, temporary table parameters
395  and so on.
396  */
397  JOIN *m_join = nullptr;
398 
399  /// The parameters for the temporary table we are materializing into, if any.
401 
402  /// The slice of the fields we are outputting to.
404 };
405 
406 enum class JoinType { INNER, OUTER, ANTI, SEMI };
407 
408 /**
409  A simple nested loop join, taking in two iterators (left/outer and
410  right/inner) and joining them together. This may, of course, scan the inner
411  iterator many times. It is currently the only form of join we have.
412 
413  The iterator works as a state machine, where the state records whether we need
414  to read a new outer row or not, and whether we've seen any rows from the inner
415  iterator at all (if not, an outer join need to synthesize a new NULL row).
416 
417  The iterator takes care of activating performance schema batch mode on the
418  right iterator if needed; this is typically only used if it is the innermost
419  table in the entire join (where the gains from turning on batch mode is the
420  largest, and the accuracy loss from turning it off are the least critical).
421  */
423  public:
427  JoinType join_type, bool pfs_batch_mode)
428  : RowIterator(thd),
429  m_source_outer(move(source_outer)),
430  m_source_inner(move(source_inner)),
432  m_pfs_batch_mode(pfs_batch_mode) {
433  DBUG_ASSERT(m_source_outer != nullptr);
434  DBUG_ASSERT(m_source_inner != nullptr);
435 
436  // Batch mode makes no sense for anti- or semijoins, since they should only
437  // be reading one row.
439  DBUG_ASSERT(!pfs_batch_mode);
440  }
441  }
442 
443  bool Init() override;
444 
445  int Read() override;
446 
447  void SetNullRowFlag(bool is_null_row) override {
448  // TODO: write something here about why we can't do this lazily.
449  m_source_outer->SetNullRowFlag(is_null_row);
450  m_source_inner->SetNullRowFlag(is_null_row);
451  }
452 
453  void EndPSIBatchModeIfStarted() override {
454  m_source_outer->EndPSIBatchModeIfStarted();
455  m_source_inner->EndPSIBatchModeIfStarted();
456  }
457 
458  void UnlockRow() override {
459  // Since we don't know which condition that caused the row to be rejected,
460  // we can't know whether we could also unlock the outer row
461  // (it may still be used as parts of other joined rows).
463  m_source_inner->UnlockRow();
464  }
465  }
466 
467  std::vector<std::string> DebugString() const override;
468 
469  std::vector<Child> children() const override {
470  return std::vector<Child>{{m_source_outer.get(), ""},
471  {m_source_inner.get(), ""}};
472  }
473 
474  private:
475  enum {
480  } m_state;
481 
485 
486  /** Whether to use batch mode when scanning the inner iterator. */
487  const bool m_pfs_batch_mode;
488 };
489 
490 /**
491  An iterator that helps invalidating caches. Every time a row passes through it
492  or it changes state in any other way, it increments its “generation” counter.
493  This allows MaterializeIterator to see whether any of its dependencies has
494  changed, and then force a rematerialization -- this is typically used for
495  LATERAL tables, where we're joining in a derived table that depends on
496  something earlier in the join.
497  */
499  public:
501  unique_ptr_destroy_only<RowIterator> source_iterator,
502  const std::string &name)
503  : RowIterator(thd),
504  m_source_iterator(move(source_iterator)),
505  m_name(name) {}
506 
507  bool Init() override {
508  ++m_generation;
509  return m_source_iterator->Init();
510  }
511 
512  int Read() override {
513  ++m_generation;
514  return m_source_iterator->Read();
515  }
516 
517  void SetNullRowFlag(bool is_null_row) override {
518  ++m_generation;
519  m_source_iterator->SetNullRowFlag(is_null_row);
520  }
521 
522  void UnlockRow() override { m_source_iterator->UnlockRow(); }
523  std::vector<std::string> DebugString() const override;
524  std::vector<Child> children() const override {
525  return {Child{m_source_iterator.get(), ""}};
526  }
527 
528  int64_t generation() const { return m_generation; }
529  std::string name() const { return m_name; }
530 
531  private:
533  int64_t m_generation = 0;
534  std::string m_name;
535 };
536 
537 /**
538  Handles materialization; the first call to Init() will scan the given iterator
539  to the end, store the results in a temporary table (optionally with
540  deduplication), and then Read() will allow you to read that table repeatedly
541  without the cost of executing the given subquery many times (unless you ask
542  for rematerialization).
543 
544  When materializing, MaterializeIterator takes care of evaluating any items
545  that need so, and storing the results in the fields of the outgoing table --
546  which items is governed by the temporary table parameters.
547 
548  Conceptually (although not performance-wise!), the MaterializeIterator is a
549  no-op if you don't ask for deduplication, and in some cases (e.g. when
550  scanning a table only once), we elide it. However, it's not necessarily
551  straightforward to do so by just not inserting the iterator, as the optimizer
552  will have set up everything (e.g., read sets, or what table upstream items
553  will read from) assuming the materialization will happen, so the realistic
554  option is setting up everything as if materialization would happen but not
555  actually write to the table; see StreamingIterator for details.
556 
557  MaterializeIterator conceptually materializes iterators, not JOINs or
558  SELECT_LEX_UNITs. However, there are many details that leak out
559  (e.g., setting performance schema batch mode, slices, reusing CTEs,
560  etc.), so we need to send them in anyway.
561  */
563  public:
564  struct QueryBlock {
565  /// The iterator to read the actual rows from.
567 
568  /// Used only for optimizer trace.
570 
571  /// The JOIN that this query block represents. Used for performance
572  /// schema batch mode: When materializing a query block that consists of
573  /// a single table, MaterializeIterator needs to set up schema batch mode,
574  /// since there is no nested loop iterator to do it. (This is similar to
575  /// what ExecuteIteratorQuery() needs to do at the top level.)
577 
578  /// If true, unique constraint checking via hash key is disabled
579  /// when materializing this query block (ie., we simply avoid calling
580  /// check_unique_constraint() for each row). Used when materializing
581  /// UNION DISTINCT and UNION ALL parts into the same table.
582  /// We'd like to just use a unique constraint via unique index instead,
583  /// but there might be other indexes on the destination table
584  /// that we'd like to keep, and the implementation doesn't allow
585  /// disabling only one index.
586  ///
587  /// If you use this on a query block, doing_hash_deduplication()
588  /// must be true.
590 
591  /// If set to false, the Field objects in the output row are
592  /// presumed already to be filled out. This is the case iff
593  /// there's an AggregateIterator earlier in the chain.
595 
596  /// If copy_fields_and_items is true, used for copying the Field objects
597  /// into the temporary table row. Otherwise unused.
599 
600  // Whether this query block is a recursive reference back to the
601  // output of the materialization.
603 
604  // If is_recursive_reference is true, contains the FollowTailIterator
605  // in the query block (there can be at most one recursive reference
606  // in a join list, as per the SQL standard, so there should be exactly one).
607  // Used for informing the iterators about various shared state in the
608  // materialization (including coordinating rematerializations).
610  };
611 
612  /**
613  @param thd Thread handler.
614  @param query_blocks_to_materialize List of query blocks to materialize.
615  @param table Handle to table to materialize into.
616  @param table_iterator Iterator used for scanning the temporary table
617  after materialization.
618  @param cte If materializing a CTE, points to it (see m_cte), otherwise
619  nullptr.
620  @param unit The query expression we are materializing (see m_unit).
621  @param join
622  When materializing within the same JOIN (e.g., into a temporary table
623  before sorting), as opposed to a derived table or a CTE, we may need
624  to change the slice on the join before returning rows from the result
625  table. If so, join and ref_slice would need to be set, and
626  query_blocks_to_materialize should contain only one member, with the same
627  join.
628  @param ref_slice See join. If we are materializing across JOINs,
629  e.g. derived tables, ref_slice should be left at -1.
630  @param rematerialize true if rematerializing on every Init() call
631  (e.g., because we have a dependency on a value from outside the query
632  block).
633  @param limit_rows
634  Does the same job as a LimitOffsetIterator right before the
635  MaterializeIterator would have done, except that it works _after_
636  deduplication (if that is active). It is used for when pushing LIMIT down
637  to MaterializeIterator, so that we can stop materializing when there are
638  enough rows. The deduplication is the reason why this specific limit has
639  to be handled in MaterializeIterator and not using a regular
640  LimitOffsetIterator. Set to HA_POS_ERROR for no limit.
641  */
643  Mem_root_array<QueryBlock> query_blocks_to_materialize,
644  TABLE *table,
646  const Common_table_expr *cte, SELECT_LEX_UNIT *unit,
647  JOIN *join, int ref_slice, bool rematerialize,
648  ha_rows limit_rows);
649 
650  /**
651  A convenience form for materializing a single table only.
652 
653  @param thd Thread handler.
654  @param subquery_iterator The iterator to read the actual rows from.
655  @param temp_table_param If copy_fields_and_items is true, used for copying
656  the Field objects into the temporary table row. Otherwise unused.
657  @param table Handle to table to materialize into.
658  @param table_iterator Iterator used for scanning the temporary table
659  after materialization.
660  @param cte If materializing a CTE, points to it (see m_cte), otherwise
661  nullptr.
662  @param select_number Used only for optimizer trace.
663  @param unit The query expression we are materializing (see m_unit).
664  @param join
665  When materializing within the same JOIN (e.g., into a temporary table
666  before sorting), as opposed to a derived table or a CTE, we may need
667  to change the slice on the join before returning rows from the result
668  table. If so, join and ref_slice would need to be set, and
669  query_blocks_to_materialize should contain only one member, with the same
670  join.
671  @param ref_slice See join. If we are materializing across JOINs,
672  e.g. derived tables, ref_slice should be left at -1.
673  @param copy_fields_and_items If set to false, the Field objects in the
674  output row are presumed already to be filled out. This is the case iff
675  there's an AggregateIterator earlier in the chain.
676  @param rematerialize true if rematerializing on every Init() call
677  (e.g., because we have a dependency on a value from outside the query
678  block).
679  @param limit_rows See limit_rows on the other constructor.
680  */
682  unique_ptr_destroy_only<RowIterator> subquery_iterator,
683  Temp_table_param *temp_table_param, TABLE *table,
685  const Common_table_expr *cte, int select_number,
686  SELECT_LEX_UNIT *unit, JOIN *join, int ref_slice,
687  bool copy_fields_and_items, bool rematerialize,
688  ha_rows limit_rows);
689 
690  bool Init() override;
691  int Read() override;
692  std::vector<std::string> DebugString() const override;
693 
694  std::vector<Child> children() const override;
695 
696  void SetNullRowFlag(bool is_null_row) override {
697  m_table_iterator->SetNullRowFlag(is_null_row);
698  }
699 
700  void StartPSIBatchMode() override { m_table_iterator->StartPSIBatchMode(); }
701  void EndPSIBatchModeIfStarted() override;
702 
703  // The temporary table is private to us, so there's no need to worry about
704  // locks to other transactions.
705  void UnlockRow() override {}
706 
707  /**
708  Add a cache invalidator that must be checked on every Init().
709  If its generation has increased since last materialize, we need to
710  rematerialize even if m_rematerialize is false.
711  */
712  void AddInvalidator(const CacheInvalidatorIterator *invalidator);
713 
714  private:
717 
718  /// If we are materializing a CTE, points to it (otherwise nullptr).
719  /// Used so that we see if some other iterator already materialized the table,
720  /// avoiding duplicate work.
722 
723  /// The query expression we are materializing. For derived tables,
724  /// we materialize the entire query expression; for materialization within
725  /// a query expression (e.g. for sorting or for windowing functions),
726  /// we materialize only parts of it. Used to clear correlated CTEs within
727  /// the unit when we rematerialize, since they depend on values from
728  /// outside the query expression, and those values may have changed
729  /// since last materialization.
731 
732  /// See constructor.
733  JOIN *const m_join;
734 
735  /// The slice to set when accessing temporary table; used if anything upstream
736  /// (e.g. WHERE, HAVING) wants to evaluate values based on its contents.
737  /// See constructor.
738  const int m_ref_slice;
739 
740  /// If true, we need to materialize anew for each Init() (because the contents
741  /// of the table will depend on some outer non-constant value).
742  const bool m_rematerialize;
743 
744  /// See constructor.
746 
747  struct Invalidator {
750  };
752 
753  /// Whether we are deduplicating using a hash field on the temporary
754  /// table. (This condition mirrors check_unique_constraint().)
755  /// If so, we compute a hash value for every row, look up all rows with
756  /// the same hash and manually compare them to the row we are trying to
757  /// insert.
758  ///
759  /// Note that this is _not_ the common way of deduplicating as we go.
760  /// The common method is to have a regular index on the table
761  /// over the right columns, and in that case, ha_write_row() will fail
762  /// with an ignorable error, so that the row is ignored even though
763  /// check_unique_constraint() is not called. However, B-tree indexes
764  /// have limitations, in particular on length, that sometimes require us
765  /// to do this instead. See create_tmp_table() for details.
766  bool doing_hash_deduplication() const { return table()->hash_field; }
767 
768  /// Whether we are deduplicating, whether through a hash field
769  /// or a regular unique index.
770  bool doing_deduplication() const;
771 
772  bool MaterializeRecursive();
773  bool MaterializeQueryBlock(const QueryBlock &query_block,
774  ha_rows *stored_rows);
775 };
776 
777 /**
778  StreamingIterator is a minimal version of MaterializeIterator that does not
779  actually materialize; instead, every Read() just forwards the call to the
780  subquery iterator and does the required copying from one set of fields to
781  another.
782 
783  It is used for when the optimizer would normally set up a materialization,
784  but you don't actually need one, ie. you don't want to read the rows multiple
785  times after writing them, and you don't want to access them by index (only
786  a single table scan). If you don't need the copy functionality (ie., you
787  have an AggregateIterator, which does this job already), you still need a
788  StreamingIterator, to set the NULL row flag on the temporary table.
789  */
791  public:
793  unique_ptr_destroy_only<RowIterator> subquery_iterator,
794  Temp_table_param *temp_table_param, TABLE *table,
795  bool copy_fields_and_items);
796 
797  bool Init() override;
798 
799  int Read() override;
800 
801  std::vector<std::string> DebugString() const override {
802  return {"Stream results"};
803  }
804 
805  std::vector<Child> children() const override {
806  return std::vector<Child>{{m_subquery_iterator.get(), ""}};
807  }
808 
809  void StartPSIBatchMode() override {
810  m_subquery_iterator->StartPSIBatchMode();
811  }
812  void EndPSIBatchModeIfStarted() override {
813  m_subquery_iterator->EndPSIBatchModeIfStarted();
814  }
815  void UnlockRow() override { m_subquery_iterator->UnlockRow(); }
816 
817  private:
822 
823  // Whether the iterator should generate and provide a row ID. Only true if the
824  // iterator is part of weedout, where the iterator will create a fake row ID
825  // to uniquely identify the rows it produces.
826  bool m_provide_rowid{false};
827 };
828 
829 /**
830  Aggregates unsorted data into a temporary table, using update operations
831  to keep running aggregates. After that, works as a MaterializeIterator
832  in that it allows the temporary table to be scanned.
833  */
835  public:
837  THD *thd, unique_ptr_destroy_only<RowIterator> subquery_iterator,
838  Temp_table_param *temp_table_param, TABLE *table,
840  SELECT_LEX *select_lex, JOIN *join, int ref_slice);
841 
842  bool Init() override;
843  int Read() override;
844  void SetNullRowFlag(bool is_null_row) override {
845  m_table_iterator->SetNullRowFlag(is_null_row);
846  }
847  void EndPSIBatchModeIfStarted() override {
848  m_table_iterator->EndPSIBatchModeIfStarted();
849  m_subquery_iterator->EndPSIBatchModeIfStarted();
850  }
851  void UnlockRow() override {}
852  std::vector<std::string> DebugString() const override;
853 
854  std::vector<Child> children() const override;
855 
856  private:
857  /// The iterator we are reading rows from.
859 
860  /// The iterator used to scan the resulting temporary table.
862 
865  JOIN *const m_join;
866  const int m_ref_slice;
867 
868  // See MaterializeIterator::doing_hash_deduplication().
869  bool using_hash_key() const { return table()->hash_field; }
870 };
871 
872 /**
873  An iterator that wraps a Table_function (e.g. JSON_TABLE) and allows you to
874  iterate over the materialized temporary table. The table is materialized anew
875  for every Init().
876 
877  TODO: Just wrapping it is probably not the optimal thing to do;
878  Table_function is highly oriented around materialization, but never caches.
879  Thus, perhaps we should rewrite Table_function to return a RowIterator
880  instead of going through a temporary table.
881  */
883  public:
885  THD *thd, Table_function *table_function, TABLE *table,
886  unique_ptr_destroy_only<RowIterator> table_iterator);
887 
888  bool Init() override;
889  int Read() override { return m_table_iterator->Read(); }
890  std::vector<std::string> DebugString() const override {
891  return {{"Materialize table function"}};
892  }
893  void SetNullRowFlag(bool is_null_row) override {
894  m_table_iterator->SetNullRowFlag(is_null_row);
895  }
896 
897  void StartPSIBatchMode() override { m_table_iterator->StartPSIBatchMode(); }
898  void EndPSIBatchModeIfStarted() override {
899  m_table_iterator->EndPSIBatchModeIfStarted();
900  }
901 
902  // The temporary table is private to us, so there's no need to worry about
903  // locks to other transactions.
904  void UnlockRow() override {}
905 
906  private:
908 
910 };
911 
912 /**
913  Like semijoin materialization, weedout works on the basic idea that a semijoin
914  is just like an inner join as we long as we can get rid of the duplicates
915  somehow. (This is advantageous, because inner joins can be reordered, whereas
916  semijoins generally can't.) However, unlike semijoin materialization, weedout
917  removes duplicates after the join, not before it. Consider something like
918 
919  SELECT * FROM t1 WHERE a IN ( SELECT b FROM t2 );
920 
921  Semijoin materialization solves this by materializing t2, with deduplication,
922  and then joining. Weedout joins t1 to t2 and then leaves only one output row
923  per t1 row. The disadvantage is that this potentially needs to discard more
924  rows; the (potential) advantage is that we deduplicate on t1 instead of t2.
925 
926  Weedout, unlike materialization, works in a streaming fashion; rows are output
927  (or discarded) as they come in, with a temporary table used for recording the
928  row IDs we've seen before. (We need to deduplicate on t1's row IDs, not its
929  contents.) See SJ_TMP_TABLE for details about the table format.
930  */
932  public:
934  SJ_TMP_TABLE *sj);
935 
936  bool Init() override;
937  int Read() override;
938  std::vector<std::string> DebugString() const override;
939 
940  std::vector<Child> children() const override {
941  return std::vector<Child>{{m_source.get(), ""}};
942  }
943 
944  void SetNullRowFlag(bool is_null_row) override {
945  m_source->SetNullRowFlag(is_null_row);
946  }
947 
948  void EndPSIBatchModeIfStarted() override {
949  m_source->EndPSIBatchModeIfStarted();
950  }
951  void UnlockRow() override { m_source->UnlockRow(); }
952 
953  private:
956 
957  // The cached value of QEP_TAB::rowid_status for each of the tables in the
958  // weedout. Index 0 corresponds to the first table in m_sj.
959  // See QEP_TAB::rowid_status for why we need to cache this value.
961 };
962 
963 /**
964  An iterator that removes consecutive rows that are the same according to
965  a given index (or more accurately, its keypart), so-called “loose scan”
966  (not to be confused with “loose index scan”, which is a QUICK_SELECT_I).
967  This is similar in spirit to WeedoutIterator above (removing duplicates
968  allows us to treat the semijoin as a normal join), but is much cheaper
969  if the data is already ordered/grouped correctly, as the removal can
970  happen before the join, and it does not need a temporary table.
971  */
973  public:
976  const TABLE *table, KEY *key, size_t key_len);
977 
978  bool Init() override;
979  int Read() override;
980  std::vector<std::string> DebugString() const override;
981 
982  std::vector<Child> children() const override {
983  return std::vector<Child>{{m_source.get(), ""}};
984  }
985 
986  void SetNullRowFlag(bool is_null_row) override {
987  m_source->SetNullRowFlag(is_null_row);
988  }
989 
990  void StartPSIBatchMode() override { m_source->StartPSIBatchMode(); }
991  void EndPSIBatchModeIfStarted() override {
992  m_source->EndPSIBatchModeIfStarted();
993  }
994  void UnlockRow() override { m_source->UnlockRow(); }
995 
996  private:
998  const TABLE *m_table;
1000  uchar *m_key_buf; // Owned by the THD's MEM_ROOT.
1001  const size_t m_key_len;
1003 };
1004 
1005 /**
1006  An iterator that is semantically equivalent to a semijoin NestedLoopIterator
1007  immediately followed by a RemoveDuplicatesIterator. It is used to implement
1008  the “loose scan” strategy in queries with multiple tables on the inside of a
1009  semijoin, like
1010 
1011  ... FROM t1 WHERE ... IN ( SELECT ... FROM t2 JOIN t3 ... )
1012 
1013  In this case, the query tree without this iterator would ostensibly look like
1014 
1015  -> Table scan on t1
1016  -> Remove duplicates on t2_idx
1017  -> Nested loop semijoin
1018  -> Index scan on t2 using t2_idx
1019  -> Filter (e.g. t3.a = t2.a)
1020  -> Table scan on t3
1021 
1022  (t3 will be marked as “first match” on t2 when implementing loose scan,
1023  thus the semijoin.)
1024 
1025  First note that we can't put the duplicate removal directly on t2 in this
1026  case, as the first t2 row doesn't necessarily match anything in t3, so it
1027  needs to be above. However, this is wasteful, because once we find a matching
1028  t2/t3 pair, we should stop scanning t3 until we have a new t2.
1029 
1030  NestedLoopSemiJoinWithDuplicateRemovalIterator solves the problem by doing
1031  exactly this; it gets a row from the outer side, gets exactly one row from the
1032  inner side, and then skips over rows from the outer side (_without_ scanning
1033  the inner side) until its keypart changes.
1034  */
1036  : public RowIterator {
1037  public:
1040  unique_ptr_destroy_only<RowIterator> source_inner, const TABLE *table,
1041  KEY *key, size_t key_len);
1042 
1043  bool Init() override;
1044 
1045  int Read() override;
1046 
1047  void SetNullRowFlag(bool is_null_row) override {
1048  m_source_outer->SetNullRowFlag(is_null_row);
1049  m_source_inner->SetNullRowFlag(is_null_row);
1050  }
1051 
1052  void EndPSIBatchModeIfStarted() override {
1053  m_source_outer->EndPSIBatchModeIfStarted();
1054  m_source_inner->EndPSIBatchModeIfStarted();
1055  }
1056 
1057  void UnlockRow() override {
1058  m_source_outer->UnlockRow();
1059  m_source_inner->UnlockRow();
1060  }
1061 
1062  std::vector<std::string> DebugString() const override;
1063 
1064  std::vector<Child> children() const override {
1065  return std::vector<Child>{{m_source_outer.get(), ""},
1066  {m_source_inner.get(), ""}};
1067  }
1068 
1069  private:
1072 
1075  uchar *m_key_buf; // Owned by the THD's MEM_ROOT.
1076  const size_t m_key_len;
1078 };
1079 
1080 /**
1081  WindowingIterator is similar to AggregateIterator, but deals with windowed
1082  aggregates (i.e., OVER expressions). It deals specifically with aggregates
1083  that don't need to buffer rows.
1084 
1085  WindowingIterator always outputs to a temporary table. Similarly to
1086  AggregateIterator, needs to do some of MaterializeIterator's work in
1087  copying fields and Items into the destination fields (see AggregateIterator
1088  for more information).
1089  */
1091  public:
1093  Temp_table_param *temp_table_param, // Includes the window.
1094  JOIN *join, int output_slice);
1095 
1096  bool Init() override;
1097 
1098  int Read() override;
1099 
1100  void SetNullRowFlag(bool is_null_row) override {
1101  m_source->SetNullRowFlag(is_null_row);
1102  }
1103 
1104  void StartPSIBatchMode() override { m_source->StartPSIBatchMode(); }
1105  void EndPSIBatchModeIfStarted() override {
1106  m_source->EndPSIBatchModeIfStarted();
1107  }
1108 
1109  void UnlockRow() override {
1110  // There's nothing we can do here.
1111  }
1112 
1113  std::vector<std::string> DebugString() const override;
1114 
1115  std::vector<Child> children() const override {
1116  return std::vector<Child>{{m_source.get(), ""}};
1117  }
1118 
1119  private:
1120  /// The iterator we are reading from.
1122 
1123  /// Parameters for the temporary table we are outputting to.
1125 
1126  /// The window function itself.
1128 
1129  /// The join we are a part of.
1131 
1132  /// The slice we will be using when reading rows.
1134 
1135  /// The slice we will be using when outputting rows.
1137 };
1138 
1139 /**
1140  BufferingWindowingIterator is like WindowingIterator, but deals with window
1141  functions that need to buffer rows.
1142  */
1144  public:
1147  Temp_table_param *temp_table_param, // Includes the window.
1148  JOIN *join, int output_slice);
1149 
1150  bool Init() override;
1151 
1152  int Read() override;
1153 
1154  void SetNullRowFlag(bool is_null_row) override {
1155  m_source->SetNullRowFlag(is_null_row);
1156  }
1157 
1158  void StartPSIBatchMode() override { m_source->StartPSIBatchMode(); }
1159  void EndPSIBatchModeIfStarted() override {
1160  m_source->EndPSIBatchModeIfStarted();
1161  }
1162 
1163  void UnlockRow() override {
1164  // There's nothing we can do here.
1165  }
1166 
1167  std::vector<std::string> DebugString() const override;
1168 
1169  std::vector<Child> children() const override {
1170  return std::vector<Child>{{m_source.get(), ""}};
1171  }
1172 
1173  private:
1174  int ReadBufferedRow(bool new_partition_or_eof);
1175 
1176  /// The iterator we are reading from.
1178 
1179  /// Parameters for the temporary table we are outputting to.
1181 
1182  /// The window function itself.
1184 
1185  /// The join we are a part of.
1187 
1188  /// The slice we will be using when reading rows.
1190 
1191  /// The slice we will be using when outputting rows.
1193 
1194  /// If true, we may have more buffered rows to process that need to be
1195  /// checked for before reading more rows from the source.
1197 
1198  /// Whether the last input row started a new partition, and was tucked away
1199  /// to finalize the previous partition; if so, we need to bring it back
1200  /// for processing before we read more rows.
1202 
1203  /// Whether we have seen the last input row.
1204  bool m_eof;
1205 };
1206 
1207 /**
1208  MaterializeInformationSchemaTableIterator makes sure a given I_S temporary
1209  table is materialized (filled out) before we try to scan it.
1210  */
1212  public:
1214  THD *thd, QEP_TAB *qep_tab,
1215  unique_ptr_destroy_only<RowIterator> table_iterator);
1216 
1217  bool Init() override;
1218  int Read() override { return m_table_iterator->Read(); }
1219  std::vector<std::string> DebugString() const override;
1220 
1221  std::vector<Child> children() const override {
1222  // We don't list the table iterator as an explicit child; we mark it in
1223  // our DebugString() instead. (Anything else would look confusingly much
1224  // like a join.)
1225  return {};
1226  }
1227 
1228  void SetNullRowFlag(bool is_null_row) override {
1229  m_table_iterator->SetNullRowFlag(is_null_row);
1230  }
1231 
1232  void StartPSIBatchMode() override { m_table_iterator->StartPSIBatchMode(); }
1233  void EndPSIBatchModeIfStarted() override {
1234  m_table_iterator->EndPSIBatchModeIfStarted();
1235  }
1236 
1237  // The temporary table is private to us, so there's no need to worry about
1238  // locks to other transactions.
1239  void UnlockRow() override {}
1240 
1241  private:
1242  /// The iterator that reads from the materialized table.
1245 };
1246 
1247 /**
1248  Takes in two or more iterators and output rows from them sequentially
1249  (first all rows from the first one, the all from the second one, etc.).
1250  Used for implementing UNION ALL, typically together with StreamingIterator.
1251  */
1253  public:
1255  THD *thd,
1257 
1258  bool Init() override;
1259  int Read() override;
1260 
1261  std::vector<std::string> DebugString() const override { return {"Append"}; }
1262  std::vector<Child> children() const override;
1263 
1264  void StartPSIBatchMode() override;
1265  void EndPSIBatchModeIfStarted() override;
1266 
1267  void SetNullRowFlag(bool is_null_row) override;
1268  void UnlockRow() override;
1269 
1270  private:
1271  std::vector<unique_ptr_destroy_only<RowIterator>> m_sub_iterators;
1274 };
1275 
1276 #endif // SQL_COMPOSITE_ITERATORS_INCLUDED
A simple nested loop join, taking in two iterators (left/outer and right/inner) and joining them toge...
Definition: composite_iterators.h:422
Definition: composite_iterators.h:251
After parsing, a Common Table Expression is accessed through a TABLE_LIST.
Definition: table.h:3887
Mem_root_array< Item * > * m_current_fields
If we have replaced the field list, this is the list of Item pointers that each Item_ref points into...
Definition: composite_iterators.h:300
MaterializedTableFunctionIterator(THD *thd, Table_function *table_function, TABLE *table, unique_ptr_destroy_only< RowIterator > table_iterator)
Definition: composite_iterators.cc:1524
std::vector< Child > children() const override
List of zero or more iterators which are direct children of this one.
Definition: composite_iterators.cc:1517
unique_ptr_destroy_only< RowIterator > m_source_iterator
Definition: composite_iterators.h:532
unsigned char uchar
Definition: my_inttypes.h:51
enum NestedLoopIterator::@38 m_state
Definition: sql_optimizer.h:177
int Read() override
Read a single row.
Definition: composite_iterators.h:1218
int ReadBufferedRow(bool new_partition_or_eof)
Definition: composite_iterators.cc:1936
bool m_seen_eof
Whether we have seen the last input row.
Definition: composite_iterators.h:273
Temp_table_param * m_temp_table_param
Definition: composite_iterators.h:863
Definition: row_iterator.h:263
An iterator that helps invalidating caches.
Definition: composite_iterators.h:498
RemoveDuplicatesIterator(THD *thd, unique_ptr_destroy_only< RowIterator > source, const TABLE *table, KEY *key, size_t key_len)
Definition: composite_iterators.cc:1622
ulonglong table_map
Definition: my_table_map.h:32
unique_ptr_destroy_only< RowIterator > const m_source_inner
Definition: composite_iterators.h:1071
void UnlockRow() override
Definition: composite_iterators.h:904
bool doing_deduplication() const
Whether we are deduplicating, whether through a hash field or a regular unique index.
Definition: composite_iterators.cc:1215
std::vector< std::string > DebugString() const override
Returns a short string (used for EXPLAIN FORMAT=tree) with user-readable information for this iterato...
Definition: composite_iterators.cc:1987
Temp_table_param * m_temp_table_param
Definition: composite_iterators.h:819
void SetNullRowFlag(bool is_null_row) override
Mark the current row buffer as containing a NULL row or not, so that if you read from it and the flag...
Definition: composite_iterators.h:893
Definition: composite_iterators.h:250
std::string m_name
Definition: composite_iterators.h:534
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:1233
std::vector< Child > children() const override
List of zero or more iterators which are direct children of this one.
Definition: composite_iterators.h:469
void SetNullRowFlag(bool is_null_row) override
Mark the current row buffer as containing a NULL row or not, so that if you read from it and the flag...
Definition: composite_iterators.h:226
void UnlockRow() override
Definition: composite_iterators.h:458
ha_rows m_seen_rows
Definition: composite_iterators.h:174
enum AggregateIterator::@37 m_state
std::vector< T, ut_allocator< T > > vector
Specialization of vector which uses ut_allocator.
Definition: ut0new.h:1281
MaterializeInformationSchemaTableIterator(THD *thd, QEP_TAB *qep_tab, unique_ptr_destroy_only< RowIterator > table_iterator)
Definition: composite_iterators.cc:1963
bool m_deduplicate_against_previous_row
Definition: composite_iterators.h:1077
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.cc:744
void SetNullRowFlag(bool is_null_row) override
Mark the current row buffer as containing a NULL row or not, so that if you read from it and the flag...
Definition: composite_iterators.h:447
std::vector< Child > children() const override
List of zero or more iterators which are direct children of this one.
Definition: composite_iterators.h:982
An iterator that wraps a Table_function (e.g.
Definition: composite_iterators.h:882
std::vector< std::string > DebugString() const override
Returns a short string (used for EXPLAIN FORMAT=tree) with user-readable information for this iterato...
Definition: composite_iterators.cc:670
void UnlockRow() override
Definition: composite_iterators.h:994
int64_t m_generation
Definition: composite_iterators.h:533
Prealloced_array< rowid_statuses, 4 > m_rowid_status
Definition: composite_iterators.h:960
void UnlockRow() override
Definition: composite_iterators.h:522
const bool m_pfs_batch_mode
Whether to use batch mode when scanning the inner iterator.
Definition: composite_iterators.h:487
void StartPSIBatchMode() override
Start performance schema batch mode, if supported (otherwise ignored).
Definition: composite_iterators.h:897
Field * hash_field
Field used by unique constraint.
Definition: table.h:1389
std::vector< std::string > DebugString() const override
Returns a short string (used for EXPLAIN FORMAT=tree) with user-readable information for this iterato...
Definition: composite_iterators.h:92
A context for reading through a single table using a chosen access method: index read...
Definition: row_iterator.h:61
AggregateIterator(THD *thd, unique_ptr_destroy_only< RowIterator > source, JOIN *join, Temp_table_param *temp_table_param, int output_slice, bool rollup)
Definition: composite_iterators.cc:190
KEY * m_key
Definition: composite_iterators.h:999
int Read() override
Read a single row.
Definition: composite_iterators.h:512
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.h:507
JoinType
Definition: composite_iterators.h:406
table_map m_save_nullinfo
Used to save NULL information in the specific case where we have zero input rows. ...
Definition: composite_iterators.h:279
SELECT_LEX_UNIT * m_unit
The query expression we are materializing.
Definition: composite_iterators.h:730
This class represents a query block, aka a query specification, which is a query consisting of a SELE...
Definition: sql_lex.h:971
Definition: composite_iterators.h:747
int Read() override
Read a single row.
Definition: composite_iterators.cc:1773
void UnlockRow() override
Definition: composite_iterators.h:234
const int m_ref_slice
Definition: composite_iterators.h:866
Represents the (explicit) window of a SQL 2003 section 7.11 <window clause>, or the implicit (inlined...
Definition: window.h:79
JOIN * m_join
The join we are part of.
Definition: composite_iterators.h:264
int m_input_slice
The slice of the fields we are reading from (see the class comment).
Definition: composite_iterators.h:267
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:1105
Temp_table_param * m_temp_table_param
Parameters for the temporary table we are outputting to.
Definition: composite_iterators.h:1124
string ItemToString(const Item *item)
Definition: item.cc:9643
int Read() override
Read a single row.
Definition: composite_iterators.h:889
std::vector< Child > children() const override
List of zero or more iterators which are direct children of this one.
Definition: composite_iterators.h:1169
Similar to AggregateIterator, but asusmes that the actual aggregates are already have been filled out...
Definition: composite_iterators.h:356
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:991
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:948
const JoinType m_join_type
Definition: composite_iterators.h:484
bool m_last_input_row_started_new_partition
Whether the last input row started a new partition, and was tucked away to finalize the previous part...
Definition: composite_iterators.h:1201
void SetNullRowFlag(bool is_null_row) override
Mark the current row buffer as containing a NULL row or not, so that if you read from it and the flag...
Definition: composite_iterators.h:137
void UnlockRow() override
Definition: composite_iterators.h:951
std::vector< Child > children() const override
List of zero or more iterators which are direct children of this one.
Definition: composite_iterators.h:1221
WindowingIterator(THD *thd, unique_ptr_destroy_only< RowIterator > source, Temp_table_param *temp_table_param, JOIN *join, int output_slice)
Definition: composite_iterators.cc:1749
std::string join(Container cont, const std::string &delim)
join elements of an container into a string seperated by a delimiter.
Definition: string.h:144
void UnlockRow() override
Definition: composite_iterators.h:1239
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:85
unique_ptr_destroy_only< RowIterator > m_table_iterator
Definition: composite_iterators.h:716
PrecomputedAggregateIterator(THD *thd, unique_ptr_destroy_only< RowIterator > source, JOIN *join, Temp_table_param *temp_table_param, int output_slice)
Definition: composite_iterators.h:358
std::vector< Child > children() const override
List of zero or more iterators which are direct children of this one.
Definition: composite_iterators.h:524
JOIN *const m_join
See constructor.
Definition: composite_iterators.h:733
MaterializeInformationSchemaTableIterator makes sure a given I_S temporary table is materialized (fil...
Definition: composite_iterators.h:1211
const int m_ref_slice
The slice to set when accessing temporary table; used if anything upstream (e.g.
Definition: composite_iterators.h:738
unique_ptr_destroy_only< RowIterator > const m_source
The iterator we are reading from.
Definition: composite_iterators.h:1121
std::vector< std::string > DebugString() const override
Returns a short string (used for EXPLAIN FORMAT=tree) with user-readable information for this iterato...
Definition: composite_iterators.h:1261
const List< Item > * m_current_fields_source
The list that the current values in m_current_fields come from.
Definition: composite_iterators.h:308
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.cc:1565
void StartPSIBatchMode() override
Start performance schema batch mode, if supported (otherwise ignored).
Definition: composite_iterators.h:1104
std::vector< std::string > DebugString() const override
Returns a short string (used for EXPLAIN FORMAT=tree) with user-readable information for this iterato...
Definition: composite_iterators.cc:1795
Handles aggregation (typically used for GROUP BY) for the case where the rows are already properly gr...
Definition: composite_iterators.h:218
Mem_root_array< QueryBlock > m_query_blocks_to_materialize
Definition: composite_iterators.h:715
unique_ptr_destroy_only< RowIterator > m_subquery_iterator
Definition: composite_iterators.h:818
int m_current_rollup_position
If we are in state OUTPUTTING_ROLLUP_ROWS, where we are in the iteration.
Definition: composite_iterators.h:336
bool m_possibly_buffered_rows
If true, we may have more buffered rows to process that need to be checked for before reading more ro...
Definition: composite_iterators.h:1196
Definition: table.h:1301
void SetNullRowFlag(bool is_null_row) override
Mark the current row buffer as containing a NULL row or not, so that if you read from it and the flag...
Definition: composite_iterators.h:517
std::vector< std::string > DebugString() const override
Returns a short string (used for EXPLAIN FORMAT=tree) with user-readable information for this iterato...
Definition: composite_iterators.cc:1086
int Read() override
Read a single row.
Definition: composite_iterators.cc:1637
unique_ptr_destroy_only< RowIterator > subquery_iterator
The iterator to read the actual rows from.
Definition: composite_iterators.h:566
int select_number
Used only for optimizer trace.
Definition: composite_iterators.h:569
unique_ptr_destroy_only< RowIterator > m_source
Definition: composite_iterators.h:169
bool disable_deduplication_by_hash_field
If true, unique constraint checking via hash key is disabled when materializing this query block (ie...
Definition: composite_iterators.h:589
void SetNullRowFlag(bool is_null_row) override
Mark the current row buffer as containing a NULL row or not, so that if you read from it and the flag...
Definition: composite_iterators.h:370
void StartPSIBatchMode() override
Start performance schema batch mode, if supported (otherwise ignored).
Definition: composite_iterators.h:1232
MaterializeIterator(THD *thd, Mem_root_array< QueryBlock > query_blocks_to_materialize, TABLE *table, unique_ptr_destroy_only< RowIterator > table_iterator, const Common_table_expr *cte, SELECT_LEX_UNIT *unit, JOIN *join, int ref_slice, bool rematerialize, ha_rows limit_rows)
Definition: composite_iterators.cc:692
An iterator that is semantically equivalent to a semijoin NestedLoopIterator immediately followed by ...
Definition: composite_iterators.h:1035
std::vector< std::string > DebugString() const override
Returns a short string (used for EXPLAIN FORMAT=tree) with user-readable information for this iterato...
Definition: composite_iterators.cc:1604
Item * m_condition
Definition: composite_iterators.h:98
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.cc:1208
This file includes constants used by all storage engines.
CacheInvalidatorIterator(THD *thd, unique_ptr_destroy_only< RowIterator > source_iterator, const std::string &name)
Definition: composite_iterators.h:500
#define DBUG_ASSERT(A)
Definition: my_dbug.h:197
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:453
JOIN * m_join
The join we are a part of.
Definition: composite_iterators.h:1186
std::vector< std::string > DebugString() const override
Returns a short string (used for EXPLAIN FORMAT=tree) with user-readable information for this iterato...
Definition: composite_iterators.cc:1743
KEY * m_key
Definition: composite_iterators.h:1074
bool m_provide_rowid
Definition: composite_iterators.h:826
Table_function * m_table_function
Definition: composite_iterators.h:909
std::vector< std::string > DebugString() const override
Returns a short string (used for EXPLAIN FORMAT=tree) with user-readable information for this iterato...
Definition: composite_iterators.cc:1511
int Read() override
Read a single row.
Definition: composite_iterators.cc:114
FilterIterator(THD *thd, unique_ptr_destroy_only< RowIterator > source, Item *condition)
Definition: composite_iterators.h:72
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.cc:1761
StreamingIterator is a minimal version of MaterializeIterator that does not actually materialize; ins...
Definition: composite_iterators.h:790
void StartPSIBatchMode() override
Start performance schema batch mode, if supported (otherwise ignored).
Definition: composite_iterators.cc:2064
std::vector< std::string > DebugString() const override
Returns a short string (used for EXPLAIN FORMAT=tree) with user-readable information for this iterato...
Definition: composite_iterators.h:890
int Read() override
Read a single row.
Definition: composite_iterators.cc:75
ha_rows m_row_number
Definition: composite_iterators.h:821
JOIN * m_join
The join we are part of.
Definition: composite_iterators.h:397
bool copy_fields_and_items
If set to false, the Field objects in the output row are presumed already to be filled out...
Definition: composite_iterators.h:594
void SetNullRowFlag(bool is_null_row) override
Mark the current row buffer as containing a NULL row or not, so that if you read from it and the flag...
Definition: composite_iterators.h:1047
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:142
int m_output_slice
The slice we will be using when outputting rows.
Definition: composite_iterators.h:1136
const CacheInvalidatorIterator * iterator
Definition: composite_iterators.h:748
const size_t m_key_len
Definition: composite_iterators.h:1001
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.h:76
TABLE * table() const
Definition: row_iterator.h:275
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.cc:1680
const Common_table_expr * m_cte
If we are materializing a CTE, points to it (otherwise nullptr).
Definition: composite_iterators.h:721
std::vector< std::string > DebugString() const override
Returns a short string (used for EXPLAIN FORMAT=tree) with user-readable information for this iterato...
Definition: composite_iterators.cc:1660
Definition: aggregate_check.h:523
unique_ptr_destroy_only< RowIterator > const m_source_outer
Definition: composite_iterators.h:1070
SELECT_LEX * m_select_lex
Definition: composite_iterators.h:864
Temp_table_param * m_temp_table_param
The parameters for the temporary table we are materializing into, if any.
Definition: composite_iterators.h:282
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.cc:1970
int Read() override
Read a single row.
Definition: composite_iterators.cc:596
const TABLE * m_table
Definition: composite_iterators.h:998
void SetNullRowFlag(bool is_null_row) override
Mark the current row buffer as containing a NULL row or not, so that if you read from it and the flag...
Definition: composite_iterators.cc:2059
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:898
JOIN *const m_join
Definition: composite_iterators.h:865
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:375
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.cc:585
JOIN * join
The JOIN that this query block represents.
Definition: composite_iterators.h:576
unique_ptr_destroy_only< RowIterator > m_table_iterator
The iterator that reads from the materialized table.
Definition: composite_iterators.h:1243
std::vector< Child > children() const override
List of zero or more iterators which are direct children of this one.
Definition: composite_iterators.h:382
int m_output_slice
The slice we will be using when outputting rows.
Definition: composite_iterators.h:1192
bool m_replace_field_list
Whether we have a rollup query where we needed to replace m_join->fields with a set of Item_refs...
Definition: composite_iterators.h:291
NestedLoopIterator(THD *thd, unique_ptr_destroy_only< RowIterator > source_outer, unique_ptr_destroy_only< RowIterator > source_inner, JoinType join_type, bool pfs_batch_mode)
Definition: composite_iterators.h:424
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.cc:2020
Definition: item.h:668
#define final(a, b, c)
Definition: hash.c:109
bool doing_hash_deduplication() const
Whether we are deduplicating using a hash field on the temporary table.
Definition: composite_iterators.h:766
Mem_root_array< Invalidator > m_invalidators
Definition: composite_iterators.h:751
FollowTailIterator * recursive_reader
Definition: composite_iterators.h:609
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.cc:1811
void UnlockRow() override
Definition: composite_iterators.cc:2077
FollowTailIterator is a special version of TableScanIterator that is used as part of WITH RECURSIVE q...
Definition: basic_row_iterators.h:476
An iterator that takes in a stream of rows and passes through only those that meet some criteria (i...
Definition: composite_iterators.h:70
std::vector< Child > children() const override
List of zero or more iterators which are direct children of this one.
Definition: composite_iterators.h:241
std::vector< Child > children() const override
List of zero or more iterators which are direct children of this one.
Definition: composite_iterators.h:940
Definition: composite_iterators.h:252
Temp_table_param * m_temp_table_param
The parameters for the temporary table we are materializing into, if any.
Definition: composite_iterators.h:400
Aggregates unsorted data into a temporary table, using update operations to keep running aggregates...
Definition: composite_iterators.h:834
const bool m_count_all_rows
Definition: composite_iterators.h:182
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.cc:2069
Window * m_window
The window function itself.
Definition: composite_iterators.h:1183
This class represents a query expression (one query block or several query blocks combined with UNION...
Definition: sql_lex.h:554
THD * thd() const
Definition: row_iterator.h:254
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:812
const ha_rows m_offset
Definition: composite_iterators.h:181
void UnlockRow() override
Definition: composite_iterators.h:1109
std::vector< unique_ptr_destroy_only< RowIterator > > m_sub_iterators
Definition: composite_iterators.h:1271
void StartPSIBatchMode() override
Start performance schema batch mode, if supported (otherwise ignored).
Definition: composite_iterators.h:141
void SetNullRowFlag(bool is_null_row) override
Mark the current row buffer as containing a NULL row or not, so that if you read from it and the flag...
Definition: composite_iterators.h:1154
void StartPSIBatchMode() override
Start performance schema batch mode, if supported (otherwise ignored).
Definition: composite_iterators.h:809
size_t m_current_iterator_index
Definition: composite_iterators.h:1272
A typesafe replacement for DYNAMIC_ARRAY.
Definition: mem_root_array.h:398
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.cc:536
Handles materialization; the first call to Init() will scan the given iterator to the end...
Definition: composite_iterators.h:562
bool m_pfs_batch_mode_enabled
Definition: composite_iterators.h:1273
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:1159
std::vector< std::string > DebugString() const override
Returns a short string (used for EXPLAIN FORMAT=tree) with user-readable information for this iterato...
Definition: composite_iterators.cc:1958
JOIN * m_join
The join we are a part of.
Definition: composite_iterators.h:1130
std::vector< std::string > DebugString() const override
Returns a short string (used for EXPLAIN FORMAT=tree) with user-readable information for this iterato...
Definition: composite_iterators.cc:506
StreamingIterator(THD *thd, unique_ptr_destroy_only< RowIterator > subquery_iterator, Temp_table_param *temp_table_param, TABLE *table, bool copy_fields_and_items)
Definition: composite_iterators.cc:1243
void SetNullRowFlag(bool is_null_row) override
Mark the current row buffer as containing a NULL row or not, so that if you read from it and the flag...
Definition: composite_iterators.h:986
void SwitchFieldList(List< Item > *fields)
Definition: composite_iterators.h:338
void UnlockRow() override
Definition: composite_iterators.h:815
Definition: sql_executor.h:406
static const char * key
Definition: suite_stubs.c:14
std::unique_ptr< T, Destroy_only< T > > unique_ptr_destroy_only
std::unique_ptr, but only destroying.
Definition: my_alloc.h:408
int Read() override
Read a single row.
Definition: composite_iterators.cc:1071
Definition: composite_iterators.h:253
void SetNullRowFlag(bool is_null_row) override
Mark the current row buffer as containing a NULL row or not, so that if you read from it and the flag...
Definition: composite_iterators.h:844
Definition: composite_iterators.h:476
void StartPSIBatchMode() override
Start performance schema batch mode, if supported (otherwise ignored).
Definition: composite_iterators.h:1158
An iterator that removes consecutive rows that are the same according to a given index (or more accur...
Definition: composite_iterators.h:972
int Read() override
Read a single row.
Definition: composite_iterators.cc:1497
std::vector< Child > children() const override
List of zero or more iterators which are direct children of this one.
Definition: composite_iterators.h:1064
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.cc:1531
void SetNullRowFlag(bool is_null_row) override
Mark the current row buffer as containing a NULL row or not, so that if you read from it and the flag...
Definition: composite_iterators.h:696
void AddInvalidator(const CacheInvalidatorIterator *invalidator)
Add a cache invalidator that must be checked on every Init().
Definition: composite_iterators.cc:1232
void StartPSIBatchMode() override
Start performance schema batch mode, if supported (otherwise ignored).
Definition: composite_iterators.h:230
const ha_rows m_limit
Definition: composite_iterators.h:181
unique_ptr_destroy_only< RowIterator > const m_source
The iterator we are reading from.
Definition: composite_iterators.h:1177
Class representing a table function.
Definition: table_function.h:52
int64_t generation() const
Definition: composite_iterators.h:528
int m_last_unchanged_group_item_idx
For rollup: The index of the first group item that did not change when we last switched groups...
Definition: composite_iterators.h:328
Definition: composite_iterators.h:249
const size_t m_key_len
Definition: composite_iterators.h:1076
int Read() override
Read a single row.
Definition: composite_iterators.cc:1827
const ha_rows m_limit_rows
See constructor.
Definition: composite_iterators.h:745
Definition: row_iterator.h:129
unique_ptr_destroy_only< RowIterator > m_subquery_iterator
The iterator we are reading rows from.
Definition: composite_iterators.h:858
int m_input_slice
The slice we will be using when reading rows.
Definition: composite_iterators.h:1189
Definition: composite_iterators.h:477
BufferingWindowingIterator(THD *thd, unique_ptr_destroy_only< RowIterator > source, Temp_table_param *temp_table_param, JOIN *join, int output_slice)
Definition: composite_iterators.cc:1799
void StartPSIBatchMode() override
Start performance schema batch mode, if supported (otherwise ignored).
Definition: composite_iterators.h:990
int Read() override
Read a single row.
Definition: composite_iterators.cc:1572
unique_ptr_destroy_only< RowIterator > m_table_iterator
The iterator used to scan the resulting temporary table.
Definition: composite_iterators.h:861
Definition: sql_executor.h:108
void StartPSIBatchMode() override
Start performance schema batch mode, if supported (otherwise ignored).
Definition: composite_iterators.h:700
std::vector< Child > children() const override
List of zero or more iterators which are direct children of this one.
Definition: composite_iterators.h:1115
bool m_eof
Whether we have seen the last input row.
Definition: composite_iterators.h:1204
Window * m_window
The window function itself.
Definition: composite_iterators.h:1127
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:847
void UnlockRow() override
Definition: composite_iterators.h:88
WindowingIterator is similar to AggregateIterator, but deals with windowed aggregates (i...
Definition: composite_iterators.h:1090
WeedoutIterator(THD *thd, unique_ptr_destroy_only< RowIterator > source, SJ_TMP_TABLE *sj)
Definition: composite_iterators.cc:1545
Definition: key.h:111
std::vector< std::string > DebugString() const override
Returns a short string (used for EXPLAIN FORMAT=tree) with user-readable information for this iterato...
Definition: composite_iterators.cc:558
void UnlockRow() override
Definition: composite_iterators.h:1163
int Read() override
Read a single row.
Definition: composite_iterators.cc:1688
bool m_first_row
Definition: composite_iterators.h:1002
const TABLE * m_table_outer
Definition: composite_iterators.h:1073
std::vector< std::string > DebugString() const override
Returns a short string (used for EXPLAIN FORMAT=tree) with user-readable information for this iterato...
Definition: composite_iterators.h:151
std::vector< Child > children() const override
List of zero or more iterators which are direct children of this one.
Definition: composite_iterators.cc:163
NestedLoopSemiJoinWithDuplicateRemovalIterator(THD *thd, unique_ptr_destroy_only< RowIterator > source_outer, unique_ptr_destroy_only< RowIterator > source_inner, const TABLE *table, KEY *key, size_t key_len)
Definition: composite_iterators.cc:1665
#define HA_POS_ERROR
Definition: my_base.h:1132
bool is_recursive_reference
Definition: composite_iterators.h:602
void UnlockRow() override
Definition: composite_iterators.h:145
void SetNullRowFlag(bool is_null_row) override
Mark the current row buffer as containing a NULL row or not, so that if you read from it and the flag...
Definition: composite_iterators.h:1100
Temp_table_param * temp_table_param
If copy_fields_and_items is true, used for copying the Field objects into the temporary table row...
Definition: composite_iterators.h:598
std::vector< Child > children() const override
List of zero or more iterators which are direct children of this one.
Definition: composite_iterators.cc:2051
std::vector< std::string > DebugString() const override
Returns a short string (used for EXPLAIN FORMAT=tree) with user-readable information for this iterato...
Definition: composite_iterators.cc:686
Definition: composite_iterators.h:564
QEP_TAB * m_qep_tab
Definition: composite_iterators.h:1244
Definition: composite_iterators.h:478
int m_output_slice
The slice of the fields we are outputting to.
Definition: composite_iterators.h:403
unique_ptr_destroy_only< RowIterator > const m_source_inner
Definition: composite_iterators.h:483
void UnlockRow() override
Definition: composite_iterators.h:851
void SetNullRowFlag(bool is_null_row) override
Mark the current row buffer as containing a NULL row or not, so that if you read from it and the flag...
Definition: composite_iterators.h:80
AppendIterator(THD *thd, std::vector< unique_ptr_destroy_only< RowIterator >> &&sub_iterators)
Definition: composite_iterators.cc:2014
bool using_hash_key() const
Definition: composite_iterators.h:869
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.cc:1632
void SetNullRowFlag(bool is_null_row) override
Mark the current row buffer as containing a NULL row or not, so that if you read from it and the flag...
Definition: composite_iterators.h:1228
unique_ptr_destroy_only< RowIterator > m_source
Definition: composite_iterators.h:389
unique_ptr_destroy_only< RowIterator > m_table_iterator
Definition: composite_iterators.h:907
bool MaterializeRecursive()
Recursive materialization happens much like regular materialization, but some steps are repeated mult...
Definition: composite_iterators.cc:887
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.cc:1280
int Read() override
Read a single row.
Definition: composite_iterators.cc:2026
unique_ptr_destroy_only< RowIterator > m_source
Definition: composite_iterators.h:997
TemptableAggregateIterator(THD *thd, unique_ptr_destroy_only< RowIterator > subquery_iterator, Temp_table_param *temp_table_param, TABLE *table, unique_ptr_destroy_only< RowIterator > table_iterator, SELECT_LEX *select_lex, JOIN *join, int ref_slice)
Definition: composite_iterators.cc:1306
const bool m_copy_fields_and_items
Definition: composite_iterators.h:820
bool m_needs_offset
Whether we have OFFSET rows that we still need to skip.
Definition: composite_iterators.h:179
std::vector< Child > children() const override
List of zero or more iterators which are direct children of this one.
Definition: composite_iterators.cc:1156
std::vector< Child > children() const override
List of zero or more iterators which are direct children of this one.
Definition: composite_iterators.h:147
const bool m_rematerialize
If true, we need to materialize anew for each Init() (because the contents of the table will depend o...
Definition: composite_iterators.h:742
int m_input_slice
The slice we will be using when reading rows.
Definition: composite_iterators.h:1133
BufferingWindowingIterator is like WindowingIterator, but deals with window functions that need to bu...
Definition: composite_iterators.h:1143
int m_output_slice
The slice of the fields we are outputting to. See the class comment.
Definition: composite_iterators.h:270
LimitOffsetIterator(THD *thd, unique_ptr_destroy_only< RowIterator > source, ha_rows limit, ha_rows offset, bool count_all_rows, ha_rows *skipped_rows)
Definition: composite_iterators.h:119
Takes in two or more iterators and output rows from them sequentially (first all rows from the first ...
Definition: composite_iterators.h:1252
void StartPSIBatchMode() override
Start performance schema batch mode, if supported (otherwise ignored).
Definition: composite_iterators.h:84
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:1052
unique_ptr_destroy_only< RowIterator > m_source
Definition: composite_iterators.h:954
int Read() override
Read a single row.
Definition: composite_iterators.cc:542
Handles LIMIT and/or OFFSET; Init() eats the first "offset" rows, and Read() stops as soon as it&#39;s se...
Definition: composite_iterators.h:105
uchar * m_key_buf
Definition: composite_iterators.h:1075
void SetNullRowFlag(bool is_null_row) override
Mark the current row buffer as containing a NULL row or not, so that if you read from it and the flag...
Definition: composite_iterators.h:944
void UnlockRow() override
Definition: composite_iterators.h:705
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.cc:1319
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:231
join_type
Definition: sql_opt_exec_shared.h:169
Like semijoin materialization, weedout works on the basic idea that a semijoin is just like an inner ...
Definition: composite_iterators.h:931
std::vector< Child > children() const override
List of zero or more iterators which are direct children of this one.
Definition: composite_iterators.h:805
void UnlockRow() override
Definition: composite_iterators.h:1057
void StartPSIBatchMode() override
Start performance schema batch mode, if supported (otherwise ignored).
Definition: composite_iterators.h:374
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.cc:240
Definition: composite_iterators.h:479
SJ_TMP_TABLE * m_sj
Definition: composite_iterators.h:955
ha_rows * m_skipped_rows
Definition: composite_iterators.h:183
my_off_t ha_rows
Definition: my_base.h:1130
void UnlockRow() override
Definition: composite_iterators.h:378
Object containing parameters used when creating and using temporary tables.
Definition: temp_table_param.h:70
std::vector< std::string > DebugString() const override
Returns a short string (used for EXPLAIN FORMAT=tree) with user-readable information for this iterato...
Definition: composite_iterators.h:801
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.cc:100
List< Item > * m_original_fields
If we have replaced the field list, contains the original field list.
Definition: composite_iterators.h:294
int Read() override
Read a single row.
Definition: composite_iterators.cc:262
unique_ptr_destroy_only< RowIterator > m_source
Definition: composite_iterators.h:97
bool MaterializeQueryBlock(const QueryBlock &query_block, ha_rows *stored_rows)
Definition: composite_iterators.cc:999
const bool m_rollup
Whether this is a rollup query.
Definition: composite_iterators.h:285
int64_t generation_at_last_materialize
Definition: composite_iterators.h:749
This file follows Google coding style, except for the name MEM_ROOT (which is kept for historical rea...
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:778
unique_ptr_destroy_only< RowIterator > const m_source_outer
Definition: composite_iterators.h:482
unique_ptr_destroy_only< RowIterator > m_source
Definition: composite_iterators.h:256
Temp_table_param * m_temp_table_param
Parameters for the temporary table we are outputting to.
Definition: composite_iterators.h:1180
uchar * m_key_buf
Definition: composite_iterators.h:1000
int Read() override
Read a single row.
Definition: composite_iterators.cc:1289
std::string name() const
Definition: composite_iterators.h:529