MySQL  8.0.23
Source Code Documentation
basic_row_iterators.h
Go to the documentation of this file.
1 #ifndef SQL_BASIC_ROW_ITERATORS_H_
2 #define SQL_BASIC_ROW_ITERATORS_H_
3 
4 /* Copyright (c) 2018, 2020, 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 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
28  Row iterators that scan a single table without reference to other tables
29  or iterators.
30  */
31 
32 #include <sys/types.h>
33 
34 #include <memory>
35 
36 #include "map_helpers.h"
37 #include "mem_root_deque.h"
38 #include "my_alloc.h"
39 #include "my_base.h"
40 #include "my_inttypes.h"
41 #include "sql/mem_root_array.h"
42 #include "sql/row_iterator.h"
43 #include "sql/sql_list.h"
44 
45 class Filesort_info;
46 class Item;
47 class QUICK_SELECT_I;
48 class Sort_result;
49 class THD;
50 class handler;
51 struct IO_CACHE;
52 struct TABLE;
53 
54 /**
55  Scan a table from beginning to end.
56 
57  This is the most basic access method of a table using rnd_init,
58  ha_rnd_next and rnd_end. No indexes are used.
59  */
61  public:
62  // “expected_rows” is used for scaling the record buffer.
63  // If zero or less, no record buffer will be set up.
64  //
65  // "examined_rows", if not nullptr, is incremented for each successful Read().
66  TableScanIterator(THD *thd, TABLE *table, double expected_rows,
67  ha_rows *examined_rows);
68  ~TableScanIterator() override;
69 
70  bool Init() override;
71  int Read() override;
72 
73  private:
74  uchar *const m_record;
75  const double m_expected_rows;
77 };
78 
79 /** Perform a full index scan along an index. */
80 template <bool Reverse>
82  public:
83  // use_order must be set to true if you actually need to get the records
84  // back in index order. It can be set to false if you wish to scan
85  // using the index (e.g. for an index-only scan of the entire table),
86  // but do not actually care about the order. In particular, partitioned
87  // tables can use this to deliver more efficient scans.
88  //
89  // “expected_rows” is used for scaling the record buffer.
90  // If zero or less, no record buffer will be set up.
91  //
92  // The pushed condition can be nullptr.
93  //
94  // "examined_rows", if not nullptr, is incremented for each successful Read().
95  IndexScanIterator(THD *thd, TABLE *table, int idx, bool use_order,
96  double expected_rows, ha_rows *examined_rows);
97  ~IndexScanIterator() override;
98 
99  bool Init() override;
100  int Read() override;
101 
102  private:
103  uchar *const m_record;
104  const int m_idx;
105  const bool m_use_order;
106  const double m_expected_rows;
108  bool m_first = true;
109 };
110 
111 /**
112  Scan a given range of the table (a “quick”), using an index.
113 
114  IndexRangeScanIterator uses one of the QUICK_SELECT classes in opt_range.cc
115  to perform an index scan. There are loads of functionality hidden
116  in these quick classes. It handles all index scans of various kinds.
117 
118  TODO: Convert the QUICK_SELECT framework to RowIterator, so that
119  we do not need this adapter.
120  */
122  public:
123  // Does _not_ take ownership of "quick" (but maybe it should).
124  //
125  // “expected_rows” is used for scaling the record buffer.
126  // If zero or less, no record buffer will be set up.
127  //
128  // The pushed condition can be nullptr.
129  //
130  // "examined_rows", if not nullptr, is incremented for each successful Read().
132  double expected_rows, ha_rows *examined_rows);
133 
134  bool Init() override;
135  int Read() override;
136 
137  private:
138  // NOTE: No destructor; quick_range will call ha_index_or_rnd_end() for us.
140  const double m_expected_rows;
142 
143  // After m_quick has returned EOF, some of its members are destroyed, making
144  // subsequent requests for new rows undefined. We flag EOF so that the
145  // iterator does not request a new row.
146  bool m_seen_eof{false};
147 };
148 
149 // Readers relating to reading sorted data (from filesort).
150 //
151 // Filesort will produce references to the records sorted; these
152 // references can be stored in memory or in a temporary file.
153 //
154 // The temporary file is normally used when the references doesn't fit into
155 // a properly sized memory buffer. For most small queries the references
156 // are stored in the memory buffer.
157 //
158 // The temporary file is also used when performing an update where a key is
159 // modified.
160 
161 /**
162  Fetch the records from a memory buffer.
163 
164  This method is used when table->sort.addon_field is allocated.
165  This is allocated for most SELECT queries not involving any BLOB's.
166  In this case the records are fetched from a memory buffer.
167  */
168 template <bool Packed_addon_fields>
170  public:
171  // "examined_rows", if not nullptr, is incremented for each successful Read().
172  // The table is used solely for NULL row flags.
174  Filesort_info *sort, Sort_result *sort_result,
175  ha_rows *examined_rows);
176  ~SortBufferIterator() override;
177 
178  bool Init() override;
179  int Read() override;
180  void UnlockRow() override {}
181  void SetNullRowFlag(bool is_null_row) override;
182 
183  private:
184  // NOTE: No m_record -- unpacks directly into each Field's field->ptr.
190 };
191 
192 /**
193  Fetch the record IDs from a memory buffer, but the records themselves from
194  the table on disk.
195 
196  Used when the above (comment on SortBufferIterator) is not true, UPDATE,
197  DELETE and so forth and SELECT's involving large BLOBs. It is also used for
198  the result of Unique, which returns row IDs in the same format as filesort.
199  In this case the record data is fetched from the handler using the saved
200  reference using the rnd_pos handler call.
201  */
203  public:
204  // Ownership here is suboptimal: Takes only partial ownership of
205  // "sort_result", so it must be alive for as long as the RowIterator is.
206  // However, it _does_ free the buffers within on destruction.
207  //
208  // The pushed condition can be nullptr.
209  //
210  // "examined_rows", if not nullptr, is incremented for each successful Read().
212  Sort_result *sort_result,
213  bool ignore_not_found_rows, bool has_null_flags,
214  ha_rows *examined_rows);
215  ~SortBufferIndirectIterator() override;
216  bool Init() override;
217  int Read() override;
218  void SetNullRowFlag(bool is_null_row) override;
219  void UnlockRow() override {}
220 
221  private:
226  uchar *m_cache_pos = nullptr, *m_cache_end = nullptr;
229 };
230 
231 /**
232  Fetch the records from a tempoary file.
233 
234  There used to be a comment here saying “should obviously not really happen
235  other than in strange configurations”, but especially with packed addons
236  and InnoDB (where fetching rows needs a primary key lookup), it's not
237  necessarily suboptimal compared to e.g. SortBufferIndirectIterator.
238  */
239 template <bool Packed_addon_fields>
241  public:
242  // Takes ownership of tempfile.
243  // The table is used solely for NULL row flags.
245  Filesort_info *sort, ha_rows *examined_rows);
246  ~SortFileIterator() override;
247 
248  bool Init() override { return false; }
249  int Read() override;
250  void UnlockRow() override {}
251  void SetNullRowFlag(bool is_null_row) override;
252 
253  private:
254  uchar *const m_rec_buf;
260 };
261 
262 /**
263  Fetch the record IDs from a temporary file, then the records themselves from
264  the table on disk.
265 
266  Same as SortBufferIndirectIterator except that references are fetched
267  from temporary file instead of from a memory buffer. So first the record IDs
268  are read from file, then those record IDs are used to look up rows in the
269  table.
270  */
272  public:
273  // Takes ownership of tempfile.
274  //
275  // The pushed condition can be nullptr.
276  //
277  // "examined_rows", if not nullptr, is incremented for each successful Read().
279  IO_CACHE *tempfile, bool ignore_not_found_rows,
280  bool has_null_flags, ha_rows *examined_rows);
281  ~SortFileIndirectIterator() override;
282 
283  bool Init() override;
284  int Read() override;
285  void SetNullRowFlag(bool is_null_row) override;
286  void UnlockRow() override {}
287 
288  private:
289  IO_CACHE *m_io_cache = nullptr;
292  uchar *m_ref_pos = nullptr;
295 
297 };
298 
299 // Used when the plan is const, ie. is known to contain a single row
300 // (and all values have been read in advance, so we don't need to read
301 // a single table).
303  public:
304  // "examined_rows", if not nullptr, is incremented for each successful Read().
306  : RowIterator(thd), m_examined_rows(examined_rows) {}
307 
308  bool Init() override {
309  m_has_row = true;
310  return false;
311  }
312 
313  int Read() override {
314  if (m_has_row) {
315  m_has_row = false;
316  if (m_examined_rows != nullptr) {
317  ++*m_examined_rows;
318  }
319  return 0;
320  } else {
321  return -1;
322  }
323  }
324 
325  void SetNullRowFlag(bool is_null_row MY_ATTRIBUTE((unused))) override {
326  DBUG_ASSERT(!is_null_row);
327  }
328 
329  void UnlockRow() override {}
330 
331  private:
332  bool m_has_row;
334 };
335 
336 /**
337  An iterator for unqualified COUNT(*) (ie., no WHERE, no join conditions,
338  etc.), taking a special fast path in the handler. It returns a single row,
339  much like FakeSingleRowIterator; however, unlike said iterator, it actually
340  does the counting in Read() instead of expecting all fields to already be
341  filled out.
342  */
344  public:
346  : RowIterator(thd), m_join(join) {}
347 
348  bool Init() override {
349  m_has_row = true;
350  return false;
351  }
352 
353  int Read() override;
354 
355  void SetNullRowFlag(bool) override { DBUG_ASSERT(false); }
356 
357  void UnlockRow() override {}
358 
359  private:
360  bool m_has_row;
361  JOIN *const m_join;
362 };
363 
364 /**
365  A simple iterator that takes no input and produces zero output rows.
366  Used when the optimizer has figured out ahead of time that a given table
367  can produce no output (e.g. SELECT ... WHERE 2+2 = 5).
368 
369  The child iterator is optional (can be nullptr) if SetNullRowFlag() is
370  not to be called. It is used when a subtree used on the inner side of an
371  outer join is found to be never executable, and replaced with a
372  ZeroRowsIterator; in that case, we need to forward the SetNullRowFlag call
373  to it. This child is not printed as part of the iterator tree.
374  */
376  public:
379  : RowIterator(thd), m_child_iterator(std::move(child_iterator)) {}
380 
381  bool Init() override { return false; }
382 
383  int Read() override { return -1; }
384 
385  void SetNullRowFlag(bool is_null_row) override {
386  DBUG_ASSERT(m_child_iterator != nullptr);
387  m_child_iterator->SetNullRowFlag(is_null_row);
388  }
389 
390  void UnlockRow() override {}
391 
392  private:
394 };
395 
396 class SELECT_LEX;
397 
398 /**
399  Like ZeroRowsIterator, but produces a single output row, since there are
400  aggregation functions present and no GROUP BY. E.g.,
401 
402  SELECT SUM(f1) FROM t1 WHERE 2+2 = 5;
403 
404  should produce a single row, containing only the value NULL.
405  */
407  public:
408  // "examined_rows", if not nullptr, is incremented for each successful Read().
410  : RowIterator(thd), m_join(join), m_examined_rows(examined_rows) {}
411 
412  bool Init() override {
413  m_has_row = true;
414  return false;
415  }
416 
417  int Read() override;
418 
419  void SetNullRowFlag(bool) override { DBUG_ASSERT(false); }
420 
421  void UnlockRow() override {}
422 
423  private:
424  bool m_has_row;
425  JOIN *const m_join;
427 };
428 
429 /**
430  FollowTailIterator is a special version of TableScanIterator that is used
431  as part of WITH RECURSIVE queries. It is designed to read from a temporary
432  table at the same time as MaterializeIterator writes to the same table,
433  picking up new records in the order they come in -- it follows the tail,
434  much like the UNIX tool “tail -f”.
435 
436  Furthermore, when materializing a recursive query expression consisting of
437  multiple query blocks, MaterializeIterator needs to run each block several
438  times until convergence. (For a single query block, one iteration suffices,
439  since the iterator sees new records as they come in.) Each such run, the
440  recursive references should see only rows that were added since the last
441  iteration, even though Init() is called anew. FollowTailIterator is thus
442  different from TableScanIterator in that subsequent calls to Init() do not
443  move the cursor back to the start.
444 
445  In addition, FollowTailIterator implements the WITH RECURSIVE iteration limit.
446  This is not specified in terms of Init() calls, since one run can encompass
447  many iterations. Instead, it keeps track of the number of records in the table
448  at the start of iteration, and when it has read all of those records, the next
449  iteration is deemed to have begun. If the iteration counter is above the
450  user-set limit, it raises an error to stop runaway queries with infinite
451  recursion.
452  */
454  public:
455  // "examined_rows", if not nullptr, is incremented for each successful Read().
456  FollowTailIterator(THD *thd, TABLE *table, double expected_rows,
457  ha_rows *examined_rows);
458  ~FollowTailIterator() override;
459 
460  bool Init() override;
461  int Read() override;
462 
463  /**
464  Signal where we can expect to find the number of generated rows for this
465  materialization (this points into the MaterializeIterator's data).
466 
467  This must be called when we start materializing the CTE,
468  before Init() runs.
469  */
470  void set_stored_rows_pointer(ha_rows *stored_rows) {
471  m_stored_rows = stored_rows;
472  }
473 
474  /**
475  Signal to the iterator that the underlying table was closed and replaced
476  with an InnoDB table with the same data, due to a spill-to-disk
477  (e.g. the table used to be MEMORY and now is InnoDB). This is
478  required so that Read() can continue scanning from the right place.
479  Called by MaterializeIterator::MaterializeRecursive().
480  */
482 
483  private:
484  uchar *const m_record;
485  const double m_expected_rows;
490 
491  // Points into MaterializeIterator's data; set by BeginMaterialization() only.
492  ha_rows *m_stored_rows = nullptr;
493 };
494 
495 /**
496  TableValueConstructor is the iterator for the table value constructor case of
497  a query_primary (i.e. queries of the form VALUES row_list; e.g. VALUES ROW(1,
498  10), ROW(2, 20)).
499 
500  The iterator is passed the field list of its parent JOIN object, which may
501  contain Item_values_column objects that are created during
502  SELECT_LEX::prepare_values(). This is required so that Read() can replace the
503  currently selected row by simply changing the references of Item_values_column
504  objects to the next row.
505 
506  The iterator must output multiple rows without being materialized, and does
507  not scan any tables. The indirection of Item_values_column is required, as the
508  executor outputs what is contained in join->fields (either directly, or
509  indirectly through ConvertItemsToCopy), and is thus responsible for ensuring
510  that join->fields contains the correct next row.
511  */
513  public:
515  THD *thd, ha_rows *examined_rows,
516  const mem_root_deque<mem_root_deque<Item *> *> &row_value_list,
517  mem_root_deque<Item *> *join_fields);
518 
519  bool Init() override;
520  int Read() override;
521 
522  void SetNullRowFlag(bool) override { DBUG_ASSERT(false); }
523 
524  void UnlockRow() override {}
525 
526  private:
527  ha_rows *const m_examined_rows{nullptr};
528 
529  /// Contains the row values that are part of a VALUES clause. Read() will
530  /// modify contained Item objects during execution by calls to is_null() and
531  /// the required val function to extract its value.
534 
535  /// References to the row we currently want to output. When multiple rows must
536  /// be output, this contains Item_values_column objects. In this case, each
537  /// call to Read() will replace its current reference with the next row.
539 };
540 
541 #endif // SQL_BASIC_ROW_ITERATORS_H_
SortFileIndirectIterator::~SortFileIndirectIterator
~SortFileIndirectIterator() override
Definition: sorting_iterator.cc:78
SortFileIndirectIterator::m_sum_ref_length
uint m_sum_ref_length
Definition: basic_row_iterators.h:296
FakeSingleRowIterator::SetNullRowFlag
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: basic_row_iterators.h:325
SortFileIndirectIterator::Read
int Read() override
Read a single row.
Definition: sorting_iterator.cc:148
SortBufferIndirectIterator::m_examined_rows
ha_rows *const m_examined_rows
Definition: basic_row_iterators.h:225
Item
Definition: item.h:775
THD
Definition: sql_class.h:807
IndexScanIterator::m_record
uchar *const m_record
Definition: basic_row_iterators.h:103
Mem_root_array< TABLE * >
IndexScanIterator::~IndexScanIterator
~IndexScanIterator() override
Definition: records.cc:73
FollowTailIterator::m_record
uchar *const m_record
Definition: basic_row_iterators.h:484
IndexScanIterator::m_expected_rows
const double m_expected_rows
Definition: basic_row_iterators.h:106
SortBufferIterator::m_sort
Filesort_info *const m_sort
Definition: basic_row_iterators.h:185
my_base.h
SortFileIndirectIterator::m_tables
Mem_root_array< TABLE * > m_tables
Definition: basic_row_iterators.h:291
ZeroRowsIterator::Init
bool Init() override
Initialize or reinitialize the iterator.
Definition: basic_row_iterators.h:381
mem_root_deque
A (partial) implementation of std::deque allocating its blocks on a MEM_ROOT.
Definition: mem_root_deque.h:109
FakeSingleRowIterator::Init
bool Init() override
Initialize or reinitialize the iterator.
Definition: basic_row_iterators.h:308
IndexRangeScanIterator::m_seen_eof
bool m_seen_eof
Definition: basic_row_iterators.h:146
SortBufferIndirectIterator
Fetch the record IDs from a memory buffer, but the records themselves from the table on disk.
Definition: basic_row_iterators.h:202
TableRowIterator::table
TABLE * table() const
Definition: row_iterator.h:209
UnqualifiedCountIterator::m_has_row
bool m_has_row
Definition: basic_row_iterators.h:360
FollowTailIterator::RepositionCursorAfterSpillToDisk
bool RepositionCursorAfterSpillToDisk()
Signal to the iterator that the underlying table was closed and replaced with an InnoDB table with th...
Definition: records.cc:511
SortFileIndirectIterator::m_ref_pos
uchar * m_ref_pos
Definition: basic_row_iterators.h:292
FakeSingleRowIterator::m_has_row
bool m_has_row
Definition: basic_row_iterators.h:332
IndexRangeScanIterator::Init
bool Init() override
Initialize or reinitialize the iterator.
Definition: records.cc:272
SortBufferIterator::m_tables
Mem_root_array< TABLE * > m_tables
Definition: basic_row_iterators.h:189
UnqualifiedCountIterator::SetNullRowFlag
void SetNullRowFlag(bool) override
Mark the current row buffer as containing a NULL row or not, so that if you read from it and the flag...
Definition: basic_row_iterators.h:355
row_iterator.h
SortFileIterator::UnlockRow
void UnlockRow() override
Definition: basic_row_iterators.h:250
ZeroRowsIterator::m_child_iterator
unique_ptr_destroy_only< RowIterator > m_child_iterator
Definition: basic_row_iterators.h:393
TableScanIterator::TableScanIterator
TableScanIterator(THD *thd, TABLE *table, double expected_rows, ha_rows *examined_rows)
Definition: records.cc:323
SortBufferIndirectIterator::Read
int Read() override
Read a single row.
Definition: sorting_iterator.cc:376
SortBufferIterator::UnlockRow
void UnlockRow() override
Definition: basic_row_iterators.h:180
SortFileIterator::SetNullRowFlag
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: sorting_iterator.cc:247
SortFileIndirectIterator::m_ignore_not_found_rows
bool m_ignore_not_found_rows
Definition: basic_row_iterators.h:293
TABLE
Definition: table.h:1364
ZeroRowsIterator::SetNullRowFlag
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: basic_row_iterators.h:385
SortBufferIndirectIterator::~SortBufferIndirectIterator
~SortBufferIndirectIterator() override
Definition: sorting_iterator.cc:333
FakeSingleRowIterator::m_examined_rows
ha_rows *const m_examined_rows
Definition: basic_row_iterators.h:333
SortFileIterator::m_rec_buf
uchar *const m_rec_buf
Definition: basic_row_iterators.h:254
SortFileIndirectIterator
Fetch the record IDs from a temporary file, then the records themselves from the table on disk.
Definition: basic_row_iterators.h:271
SortFileIndirectIterator::Init
bool Init() override
Initialize or reinitialize the iterator.
Definition: sorting_iterator.cc:87
UnqualifiedCountIterator::Init
bool Init() override
Initialize or reinitialize the iterator.
Definition: basic_row_iterators.h:348
ZeroRowsIterator
A simple iterator that takes no input and produces zero output rows.
Definition: basic_row_iterators.h:375
mysql_harness::join
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
TableValueConstructorIterator::m_row_value_list
const mem_root_deque< mem_root_deque< Item * > * > & m_row_value_list
Contains the row values that are part of a VALUES clause.
Definition: basic_row_iterators.h:532
unique_ptr_destroy_only
std::unique_ptr< T, Destroy_only< T > > unique_ptr_destroy_only
std::unique_ptr, but only destroying.
Definition: my_alloc.h:465
ZeroRowsAggregatedIterator::UnlockRow
void UnlockRow() override
Definition: basic_row_iterators.h:421
IndexScanIterator::IndexScanIterator
IndexScanIterator(THD *thd, TABLE *table, int idx, bool use_order, double expected_rows, ha_rows *examined_rows)
Definition: records.cc:61
UnqualifiedCountIterator::m_join
JOIN *const m_join
Definition: basic_row_iterators.h:361
TableValueConstructorIterator::m_examined_rows
ha_rows *const m_examined_rows
Definition: basic_row_iterators.h:527
ZeroRowsAggregatedIterator::ZeroRowsAggregatedIterator
ZeroRowsAggregatedIterator(THD *thd, JOIN *join, ha_rows *examined_rows)
Definition: basic_row_iterators.h:409
FollowTailIterator
FollowTailIterator is a special version of TableScanIterator that is used as part of WITH RECURSIVE q...
Definition: basic_row_iterators.h:453
FollowTailIterator::FollowTailIterator
FollowTailIterator(THD *thd, TABLE *table, double expected_rows, ha_rows *examined_rows)
Definition: records.cc:375
mem_root_deque.h
SortFileIterator::Read
int Read() override
Read a result set record from a temporary file after sorting.
Definition: sorting_iterator.cc:220
SortBufferIterator::m_examined_rows
ha_rows *const m_examined_rows
Definition: basic_row_iterators.h:188
SortBufferIterator
Fetch the records from a memory buffer.
Definition: basic_row_iterators.h:169
TableValueConstructorIterator::m_row_it
mem_root_deque< mem_root_deque< Item * > * >::const_iterator m_row_it
Definition: basic_row_iterators.h:533
FollowTailIterator::m_read_rows
ha_rows m_read_rows
Definition: basic_row_iterators.h:487
SortBufferIndirectIterator::m_tables
Mem_root_array< TABLE * > m_tables
Definition: basic_row_iterators.h:223
UnqualifiedCountIterator::UnqualifiedCountIterator
UnqualifiedCountIterator(THD *thd, JOIN *join)
Definition: basic_row_iterators.h:345
my_alloc.h
SortFileIndirectIterator::UnlockRow
void UnlockRow() override
Definition: basic_row_iterators.h:286
SortBufferIterator::Init
bool Init() override
Initialize or reinitialize the iterator.
Definition: sorting_iterator.cc:274
UnqualifiedCountIterator::Read
int Read() override
(end of group Query_Executor)
Definition: sql_executor.cc:6524
IndexScanIterator
Perform a full index scan along an index.
Definition: basic_row_iterators.h:81
IndexScanIterator::m_first
bool m_first
Definition: basic_row_iterators.h:108
TableValueConstructorIterator::Read
int Read() override
Read a single row.
Definition: sql_executor.cc:6598
UnqualifiedCountIterator
An iterator for unqualified COUNT(*) (ie., no WHERE, no join conditions, etc.), taking a special fast...
Definition: basic_row_iterators.h:343
ZeroRowsAggregatedIterator::m_examined_rows
ha_rows *const m_examined_rows
Definition: basic_row_iterators.h:426
SortBufferIndirectIterator::SetNullRowFlag
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: sorting_iterator.cc:414
handler
The handler class is the interface for dynamically loadable storage engines.
Definition: handler.h:4048
JOIN
Definition: sql_optimizer.h:125
my_inttypes.h
ZeroRowsAggregatedIterator::Read
int Read() override
Read a single row.
Definition: sql_executor.cc:6553
SortBufferIndirectIterator::SortBufferIndirectIterator
SortBufferIndirectIterator(THD *thd, Mem_root_array< TABLE * > tables, Sort_result *sort_result, bool ignore_not_found_rows, bool has_null_flags, ha_rows *examined_rows)
Definition: sorting_iterator.cc:323
SortFileIterator::m_buf_length
const uint m_buf_length
Definition: basic_row_iterators.h:255
SortBufferIterator::m_sort_result
Sort_result *const m_sort_result
Definition: basic_row_iterators.h:186
SortBufferIndirectIterator::m_sum_ref_length
uint m_sum_ref_length
Definition: basic_row_iterators.h:224
FollowTailIterator::Init
bool Init() override
Initialize or reinitialize the iterator.
Definition: records.cc:389
FollowTailIterator::set_stored_rows_pointer
void set_stored_rows_pointer(ha_rows *stored_rows)
Signal where we can expect to find the number of generated rows for this materialization (this points...
Definition: basic_row_iterators.h:470
IndexScanIterator::m_use_order
const bool m_use_order
Definition: basic_row_iterators.h:105
SortBufferIterator::~SortBufferIterator
~SortBufferIterator() override
Definition: sorting_iterator.cc:268
SortFileIterator::Init
bool Init() override
Initialize or reinitialize the iterator.
Definition: basic_row_iterators.h:248
SortFileIterator::SortFileIterator
SortFileIterator(THD *thd, Mem_root_array< TABLE * > tables, IO_CACHE *tempfile, Filesort_info *sort, ha_rows *examined_rows)
Definition: sorting_iterator.cc:187
SortFileIterator::m_examined_rows
ha_rows *const m_examined_rows
Definition: basic_row_iterators.h:259
IndexRangeScanIterator::m_expected_rows
const double m_expected_rows
Definition: basic_row_iterators.h:140
RowIterator
A context for reading through a single table using a chosen access method: index read,...
Definition: row_iterator.h:61
SortFileIndirectIterator::m_examined_rows
ha_rows *const m_examined_rows
Definition: basic_row_iterators.h:290
FollowTailIterator::~FollowTailIterator
~FollowTailIterator() override
Definition: records.cc:383
ZeroRowsAggregatedIterator::m_join
JOIN *const m_join
Definition: basic_row_iterators.h:425
uint
unsigned int uint
Definition: uca-dump.cc:29
ZeroRowsIterator::ZeroRowsIterator
ZeroRowsIterator(THD *thd, unique_ptr_destroy_only< RowIterator > child_iterator)
Definition: basic_row_iterators.h:377
SortFileIterator::m_sort
Filesort_info *const m_sort
Definition: basic_row_iterators.h:258
map_helpers.h
SortBufferIndirectIterator::m_cache_pos
uchar * m_cache_pos
Definition: basic_row_iterators.h:226
IndexRangeScanIterator::IndexRangeScanIterator
IndexRangeScanIterator(THD *thd, TABLE *table, QUICK_SELECT_I *quick, double expected_rows, ha_rows *examined_rows)
Definition: records.cc:263
FollowTailIterator::m_stored_rows
ha_rows * m_stored_rows
Definition: basic_row_iterators.h:492
SortFileIterator::~SortFileIterator
~SortFileIterator() override
Definition: sorting_iterator.cc:199
uchar
unsigned char uchar
Definition: my_inttypes.h:51
SortFileIndirectIterator::m_io_cache
IO_CACHE * m_io_cache
Definition: basic_row_iterators.h:289
FollowTailIterator::m_recursive_iteration_count
unsigned m_recursive_iteration_count
Definition: basic_row_iterators.h:489
FakeSingleRowIterator
Definition: basic_row_iterators.h:302
SortBufferIndirectIterator::Init
bool Init() override
Initialize or reinitialize the iterator.
Definition: sorting_iterator.cc:343
TableRowIterator
Definition: row_iterator.h:197
SortFileIterator::m_io_cache
IO_CACHE *const m_io_cache
Definition: basic_row_iterators.h:257
FollowTailIterator::m_end_of_current_iteration
ha_rows m_end_of_current_iteration
Definition: basic_row_iterators.h:488
TableValueConstructorIterator::TableValueConstructorIterator
TableValueConstructorIterator(THD *thd, ha_rows *examined_rows, const mem_root_deque< mem_root_deque< Item * > * > &row_value_list, mem_root_deque< Item * > *join_fields)
Definition: sql_executor.cc:6582
IndexRangeScanIterator::m_quick
QUICK_SELECT_I *const m_quick
Definition: basic_row_iterators.h:139
ZeroRowsAggregatedIterator::Init
bool Init() override
Initialize or reinitialize the iterator.
Definition: basic_row_iterators.h:412
IndexRangeScanIterator::m_examined_rows
ha_rows *const m_examined_rows
Definition: basic_row_iterators.h:141
SortFileIndirectIterator::SortFileIndirectIterator
SortFileIndirectIterator(THD *thd, Mem_root_array< TABLE * > tables, IO_CACHE *tempfile, bool ignore_not_found_rows, bool has_null_flags, ha_rows *examined_rows)
Definition: sorting_iterator.cc:68
TableValueConstructorIterator
TableValueConstructor is the iterator for the table value constructor case of a query_primary (i....
Definition: basic_row_iterators.h:512
QUICK_SELECT_I
Definition: opt_range.h:229
TableValueConstructorIterator::Init
bool Init() override
Initialize or reinitialize the iterator.
Definition: sql_executor.cc:6593
SortBufferIterator::SortBufferIterator
SortBufferIterator(THD *thd, Mem_root_array< TABLE * > tables, Filesort_info *sort, Sort_result *sort_result, ha_rows *examined_rows)
Definition: sorting_iterator.cc:258
IO_CACHE
Definition: my_sys.h:342
Sort_result
Definition: sql_sort.h:143
sql_list.h
DBUG_ASSERT
#define DBUG_ASSERT(A)
Definition: my_dbug.h:199
RowIterator::thd
THD * thd() const
Definition: row_iterator.h:191
TableScanIterator::m_examined_rows
ha_rows *const m_examined_rows
Definition: basic_row_iterators.h:76
TableScanIterator
Scan a table from beginning to end.
Definition: basic_row_iterators.h:60
FollowTailIterator::Read
int Read() override
Read a single row.
Definition: records.cc:436
SortBufferIndirectIterator::m_sort_result
Sort_result *const m_sort_result
Definition: basic_row_iterators.h:222
SortFileIndirectIterator::m_has_null_flags
bool m_has_null_flags
Definition: basic_row_iterators.h:294
IndexRangeScanIterator::Read
int Read() override
Read a single row.
Definition: records.cc:301
std
Definition: varlen_sort.h:182
ZeroRowsAggregatedIterator::SetNullRowFlag
void SetNullRowFlag(bool) override
Mark the current row buffer as containing a NULL row or not, so that if you read from it and the flag...
Definition: basic_row_iterators.h:419
IndexScanIterator::Init
bool Init() override
Initialize or reinitialize the iterator.
Definition: records.cc:80
UnqualifiedCountIterator::UnlockRow
void UnlockRow() override
Definition: basic_row_iterators.h:357
IndexScanIterator::m_examined_rows
ha_rows *const m_examined_rows
Definition: basic_row_iterators.h:107
ZeroRowsIterator::UnlockRow
void UnlockRow() override
Definition: basic_row_iterators.h:390
IndexRangeScanIterator
Scan a given range of the table (a “quick”), using an index.
Definition: basic_row_iterators.h:121
TableScanIterator::m_record
uchar *const m_record
Definition: basic_row_iterators.h:74
SortFileIterator
Fetch the records from a tempoary file.
Definition: basic_row_iterators.h:240
FollowTailIterator::m_expected_rows
const double m_expected_rows
Definition: basic_row_iterators.h:485
Filesort_info
A class wrapping misc buffers used for sorting.
Definition: sql_sort.h:176
SortBufferIndirectIterator::m_cache_end
uchar * m_cache_end
Definition: basic_row_iterators.h:226
TableScanIterator::m_expected_rows
const double m_expected_rows
Definition: basic_row_iterators.h:75
ZeroRowsIterator::Read
int Read() override
Read a single row.
Definition: basic_row_iterators.h:383
ha_rows
my_off_t ha_rows
Definition: my_base.h:1136
TableValueConstructorIterator::m_output_refs
mem_root_deque< Item * > *const m_output_refs
References to the row we currently want to output.
Definition: basic_row_iterators.h:538
IndexScanIterator::m_idx
const int m_idx
Definition: basic_row_iterators.h:104
quick
static bool quick
Definition: mysql.cc:154
ZeroRowsAggregatedIterator::m_has_row
bool m_has_row
Definition: basic_row_iterators.h:424
SortFileIndirectIterator::SetNullRowFlag
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: sorting_iterator.cc:123
SELECT_LEX
This class represents a query block, aka a query specification, which is a query consisting of a SELE...
Definition: sql_lex.h:1098
FakeSingleRowIterator::FakeSingleRowIterator
FakeSingleRowIterator(THD *thd, ha_rows *examined_rows)
Definition: basic_row_iterators.h:305
SortBufferIndirectIterator::m_has_null_flags
bool m_has_null_flags
Definition: basic_row_iterators.h:228
SortBufferIndirectIterator::UnlockRow
void UnlockRow() override
Definition: basic_row_iterators.h:219
FakeSingleRowIterator::UnlockRow
void UnlockRow() override
Definition: basic_row_iterators.h:329
final
#define final(a, b, c)
Definition: hash.c:109
FakeSingleRowIterator::Read
int Read() override
Read a single row.
Definition: basic_row_iterators.h:313
SortBufferIterator::SetNullRowFlag
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: sorting_iterator.cc:313
FollowTailIterator::m_examined_rows
ha_rows *const m_examined_rows
Definition: basic_row_iterators.h:486
SortBufferIterator::Read
int Read() override
Read a result set record from a buffer after sorting.
Definition: sorting_iterator.cc:298
SortBufferIterator::m_unpack_counter
unsigned m_unpack_counter
Definition: basic_row_iterators.h:187
TableValueConstructorIterator::UnlockRow
void UnlockRow() override
Definition: basic_row_iterators.h:524
TableScanIterator::~TableScanIterator
~TableScanIterator() override
Definition: records.cc:331
mem_root_array.h
ZeroRowsAggregatedIterator
Like ZeroRowsIterator, but produces a single output row, since there are aggregation functions presen...
Definition: basic_row_iterators.h:406
TableValueConstructorIterator::SetNullRowFlag
void SetNullRowFlag(bool) override
Mark the current row buffer as containing a NULL row or not, so that if you read from it and the flag...
Definition: basic_row_iterators.h:522
SortFileIterator::m_tables
Mem_root_array< TABLE * > m_tables
Definition: basic_row_iterators.h:256
IndexScanIterator::Read
int Read() override
Read a single row.
TableScanIterator::Read
int Read() override
Read a single row.
Definition: records.cc:359
SortBufferIndirectIterator::m_ignore_not_found_rows
bool m_ignore_not_found_rows
Definition: basic_row_iterators.h:227
TableScanIterator::Init
bool Init() override
Initialize or reinitialize the iterator.
Definition: records.cc:337