MySQL  8.0.27
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, 2021, 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  */
60 class TableScanIterator final : public TableRowIterator {
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>
81 class IndexScanIterator final : public TableRowIterator {
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>
169 class SortBufferIterator final : public RowIterator {
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) override {
182  // Handled by SortingIterator.
183  assert(false);
184  }
185 
186  private:
187  // NOTE: No m_record -- unpacks directly into each Field's field->ptr.
193 };
194 
195 /**
196  Fetch the record IDs from a memory buffer, but the records themselves from
197  the table on disk.
198 
199  Used when the above (comment on SortBufferIterator) is not true, UPDATE,
200  DELETE and so forth and SELECT's involving large BLOBs. It is also used for
201  the result of Unique, which returns row IDs in the same format as filesort.
202  In this case the record data is fetched from the handler using the saved
203  reference using the rnd_pos handler call.
204  */
206  public:
207  // Ownership here is suboptimal: Takes only partial ownership of
208  // "sort_result", so it must be alive for as long as the RowIterator is.
209  // However, it _does_ free the buffers within on destruction.
210  //
211  // The pushed condition can be nullptr.
212  //
213  // "examined_rows", if not nullptr, is incremented for each successful Read().
215  Sort_result *sort_result,
216  bool ignore_not_found_rows, bool has_null_flags,
217  ha_rows *examined_rows);
218  ~SortBufferIndirectIterator() override;
219  bool Init() override;
220  int Read() override;
221  void SetNullRowFlag(bool) override {
222  // Handled by SortingIterator.
223  assert(false);
224  }
225  void UnlockRow() override {}
226 
227  private:
232  uchar *m_cache_pos = nullptr, *m_cache_end = nullptr;
235 };
236 
237 /**
238  Fetch the records from a tempoary file.
239 
240  There used to be a comment here saying “should obviously not really happen
241  other than in strange configurations”, but especially with packed addons
242  and InnoDB (where fetching rows needs a primary key lookup), it's not
243  necessarily suboptimal compared to e.g. SortBufferIndirectIterator.
244  */
245 template <bool Packed_addon_fields>
246 class SortFileIterator final : public RowIterator {
247  public:
248  // Takes ownership of tempfile.
249  // The table is used solely for NULL row flags.
251  Filesort_info *sort, ha_rows *examined_rows);
252  ~SortFileIterator() override;
253 
254  bool Init() override { return false; }
255  int Read() override;
256  void UnlockRow() override {}
257  void SetNullRowFlag(bool) override {
258  // Handled by SortingIterator.
259  assert(false);
260  }
261 
262  private:
263  uchar *const m_rec_buf;
269 };
270 
271 /**
272  Fetch the record IDs from a temporary file, then the records themselves from
273  the table on disk.
274 
275  Same as SortBufferIndirectIterator except that references are fetched
276  from temporary file instead of from a memory buffer. So first the record IDs
277  are read from file, then those record IDs are used to look up rows in the
278  table.
279  */
280 class SortFileIndirectIterator final : public RowIterator {
281  public:
282  // Takes ownership of tempfile.
283  //
284  // The pushed condition can be nullptr.
285  //
286  // "examined_rows", if not nullptr, is incremented for each successful Read().
288  IO_CACHE *tempfile, bool ignore_not_found_rows,
289  bool has_null_flags, ha_rows *examined_rows);
290  ~SortFileIndirectIterator() override;
291 
292  bool Init() override;
293  int Read() override;
294  void SetNullRowFlag(bool) override {
295  // Handled by SortingIterator.
296  assert(false);
297  }
298  void UnlockRow() override {}
299 
300  private:
301  IO_CACHE *m_io_cache = nullptr;
304  uchar *m_ref_pos = nullptr;
307 
309 };
310 
311 // Used when the plan is const, ie. is known to contain a single row
312 // (and all values have been read in advance, so we don't need to read
313 // a single table).
314 class FakeSingleRowIterator final : public RowIterator {
315  public:
316  // "examined_rows", if not nullptr, is incremented for each successful Read().
318  : RowIterator(thd), m_examined_rows(examined_rows) {}
319 
320  bool Init() override {
321  m_has_row = true;
322  return false;
323  }
324 
325  int Read() override {
326  if (m_has_row) {
327  m_has_row = false;
328  if (m_examined_rows != nullptr) {
329  ++*m_examined_rows;
330  }
331  return 0;
332  } else {
333  return -1;
334  }
335  }
336 
337  void SetNullRowFlag(bool is_null_row [[maybe_unused]]) override {
338  assert(!is_null_row);
339  }
340 
341  void UnlockRow() override {}
342 
343  private:
344  bool m_has_row;
346 };
347 
348 /**
349  An iterator for unqualified COUNT(*) (ie., no WHERE, no join conditions,
350  etc.), taking a special fast path in the handler. It returns a single row,
351  much like FakeSingleRowIterator; however, unlike said iterator, it actually
352  does the counting in Read() instead of expecting all fields to already be
353  filled out.
354  */
355 class UnqualifiedCountIterator final : public RowIterator {
356  public:
358  : RowIterator(thd), m_join(join) {}
359 
360  bool Init() override {
361  m_has_row = true;
362  return false;
363  }
364 
365  int Read() override;
366 
367  void SetNullRowFlag(bool) override { assert(false); }
368 
369  void UnlockRow() override {}
370 
371  private:
372  bool m_has_row;
373  JOIN *const m_join;
374 };
375 
376 /**
377  A simple iterator that takes no input and produces zero output rows.
378  Used when the optimizer has figured out ahead of time that a given table
379  can produce no output (e.g. SELECT ... WHERE 2+2 = 5).
380 
381  The child iterator is optional (can be nullptr) if SetNullRowFlag() is
382  not to be called. It is used when a subtree used on the inner side of an
383  outer join is found to be never executable, and replaced with a
384  ZeroRowsIterator; in that case, we need to forward the SetNullRowFlag call
385  to it. This child is not printed as part of the iterator tree.
386  */
387 class ZeroRowsIterator final : public RowIterator {
388  public:
391  : RowIterator(thd), m_child_iterator(std::move(child_iterator)) {}
392 
393  bool Init() override { return false; }
394 
395  int Read() override { return -1; }
396 
397  void SetNullRowFlag(bool is_null_row) override {
398  assert(m_child_iterator != nullptr);
399  m_child_iterator->SetNullRowFlag(is_null_row);
400  }
401 
402  void UnlockRow() override {}
403 
404  private:
406 };
407 
408 class Query_block;
409 
410 /**
411  Like ZeroRowsIterator, but produces a single output row, since there are
412  aggregation functions present and no GROUP BY. E.g.,
413 
414  SELECT SUM(f1) FROM t1 WHERE 2+2 = 5;
415 
416  should produce a single row, containing only the value NULL.
417  */
419  public:
420  // "examined_rows", if not nullptr, is incremented for each successful Read().
422  : RowIterator(thd), m_join(join), m_examined_rows(examined_rows) {}
423 
424  bool Init() override {
425  m_has_row = true;
426  return false;
427  }
428 
429  int Read() override;
430 
431  void SetNullRowFlag(bool) override { assert(false); }
432 
433  void UnlockRow() override {}
434 
435  private:
436  bool m_has_row;
437  JOIN *const m_join;
439 };
440 
441 /**
442  FollowTailIterator is a special version of TableScanIterator that is used
443  as part of WITH RECURSIVE queries. It is designed to read from a temporary
444  table at the same time as MaterializeIterator writes to the same table,
445  picking up new records in the order they come in -- it follows the tail,
446  much like the UNIX tool “tail -f”.
447 
448  Furthermore, when materializing a recursive query expression consisting of
449  multiple query blocks, MaterializeIterator needs to run each block several
450  times until convergence. (For a single query block, one iteration suffices,
451  since the iterator sees new records as they come in.) Each such run, the
452  recursive references should see only rows that were added since the last
453  iteration, even though Init() is called anew. FollowTailIterator is thus
454  different from TableScanIterator in that subsequent calls to Init() do not
455  move the cursor back to the start.
456 
457  In addition, FollowTailIterator implements the WITH RECURSIVE iteration limit.
458  This is not specified in terms of Init() calls, since one run can encompass
459  many iterations. Instead, it keeps track of the number of records in the table
460  at the start of iteration, and when it has read all of those records, the next
461  iteration is deemed to have begun. If the iteration counter is above the
462  user-set limit, it raises an error to stop runaway queries with infinite
463  recursion.
464  */
465 class FollowTailIterator final : public TableRowIterator {
466  public:
467  // "examined_rows", if not nullptr, is incremented for each successful Read().
468  FollowTailIterator(THD *thd, TABLE *table, double expected_rows,
469  ha_rows *examined_rows);
470  ~FollowTailIterator() override;
471 
472  bool Init() override;
473  int Read() override;
474 
475  /**
476  Signal where we can expect to find the number of generated rows for this
477  materialization (this points into the MaterializeIterator's data).
478 
479  This must be called when we start materializing the CTE,
480  before Init() runs.
481  */
482  void set_stored_rows_pointer(ha_rows *stored_rows) {
483  m_stored_rows = stored_rows;
484  }
485 
486  /**
487  Signal to the iterator that the underlying table was closed and replaced
488  with an InnoDB table with the same data, due to a spill-to-disk
489  (e.g. the table used to be MEMORY and now is InnoDB). This is
490  required so that Read() can continue scanning from the right place.
491  Called by MaterializeIterator::MaterializeRecursive().
492  */
494 
495  private:
496  bool m_inited = false;
497  uchar *const m_record;
498  const double m_expected_rows;
503 
504  // Points into MaterializeIterator's data; set by BeginMaterialization() only.
505  ha_rows *m_stored_rows = nullptr;
506 };
507 
508 /**
509  TableValueConstructor is the iterator for the table value constructor case of
510  a query_primary (i.e. queries of the form VALUES row_list; e.g. VALUES ROW(1,
511  10), ROW(2, 20)).
512 
513  The iterator is passed the field list of its parent JOIN object, which may
514  contain Item_values_column objects that are created during
515  Query_block::prepare_values(). This is required so that Read() can replace the
516  currently selected row by simply changing the references of Item_values_column
517  objects to the next row.
518 
519  The iterator must output multiple rows without being materialized, and does
520  not scan any tables. The indirection of Item_values_column is required, as the
521  executor outputs what is contained in join->fields (either directly, or
522  indirectly through ConvertItemsToCopy), and is thus responsible for ensuring
523  that join->fields contains the correct next row.
524  */
526  public:
528  THD *thd, ha_rows *examined_rows,
529  const mem_root_deque<mem_root_deque<Item *> *> &row_value_list,
530  mem_root_deque<Item *> *join_fields);
531 
532  bool Init() override;
533  int Read() override;
534 
535  void SetNullRowFlag(bool) override { assert(false); }
536 
537  void UnlockRow() override {}
538 
539  private:
540  ha_rows *const m_examined_rows{nullptr};
541 
542  /// Contains the row values that are part of a VALUES clause. Read() will
543  /// modify contained Item objects during execution by calls to is_null() and
544  /// the required val function to extract its value.
547 
548  /// References to the row we currently want to output. When multiple rows must
549  /// be output, this contains Item_values_column objects. In this case, each
550  /// call to Read() will replace its current reference with the next row.
552 };
553 
554 #endif // SQL_BASIC_ROW_ITERATORS_H_
Definition: basic_row_iterators.h:314
int Read() override
Read a single row.
Definition: basic_row_iterators.h:325
void UnlockRow() override
Definition: basic_row_iterators.h:341
bool m_has_row
Definition: basic_row_iterators.h:344
ha_rows *const m_examined_rows
Definition: basic_row_iterators.h:345
bool Init() override
Initialize or reinitialize the iterator.
Definition: basic_row_iterators.h:320
FakeSingleRowIterator(THD *thd, ha_rows *examined_rows)
Definition: basic_row_iterators.h:317
void SetNullRowFlag(bool is_null_row[[maybe_unused]]) override
Definition: basic_row_iterators.h:337
A class wrapping misc buffers used for sorting.
Definition: sql_sort.h:177
FollowTailIterator is a special version of TableScanIterator that is used as part of WITH RECURSIVE q...
Definition: basic_row_iterators.h:465
bool RepositionCursorAfterSpillToDisk()
Signal to the iterator that the underlying table was closed and replaced with an InnoDB table with th...
Definition: records.cc:553
FollowTailIterator(THD *thd, TABLE *table, double expected_rows, ha_rows *examined_rows)
Definition: records.cc:414
ha_rows *const m_examined_rows
Definition: basic_row_iterators.h:499
unsigned m_recursive_iteration_count
Definition: basic_row_iterators.h:502
const double m_expected_rows
Definition: basic_row_iterators.h:498
bool Init() override
Initialize or reinitialize the iterator.
Definition: records.cc:428
bool m_inited
Definition: basic_row_iterators.h:496
uchar *const m_record
Definition: basic_row_iterators.h:497
ha_rows * m_stored_rows
Definition: basic_row_iterators.h:505
ha_rows m_read_rows
Definition: basic_row_iterators.h:500
int Read() override
Read a single row.
Definition: records.cc:478
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:482
~FollowTailIterator() override
Definition: records.cc:422
ha_rows m_end_of_current_iteration
Definition: basic_row_iterators.h:501
Scan a given range of the table (a “quick”), using an index.
Definition: basic_row_iterators.h:121
IndexRangeScanIterator(THD *thd, TABLE *table, QUICK_SELECT_I *quick, double expected_rows, ha_rows *examined_rows)
Definition: records.cc:256
const double m_expected_rows
Definition: basic_row_iterators.h:140
bool Init() override
Initialize or reinitialize the iterator.
Definition: records.cc:313
int Read() override
Read a single row.
Definition: records.cc:340
bool m_seen_eof
Definition: basic_row_iterators.h:146
QUICK_SELECT_I *const m_quick
Definition: basic_row_iterators.h:139
ha_rows *const m_examined_rows
Definition: basic_row_iterators.h:141
Perform a full index scan along an index.
Definition: basic_row_iterators.h:81
const int m_idx
Definition: basic_row_iterators.h:104
ha_rows *const m_examined_rows
Definition: basic_row_iterators.h:107
int Read() override
Read a single row.
bool Init() override
Initialize or reinitialize the iterator.
Definition: records.cc:81
IndexScanIterator(THD *thd, TABLE *table, int idx, bool use_order, double expected_rows, ha_rows *examined_rows)
Definition: records.cc:62
uchar *const m_record
Definition: basic_row_iterators.h:103
~IndexScanIterator() override
Definition: records.cc:74
const bool m_use_order
Definition: basic_row_iterators.h:105
const double m_expected_rows
Definition: basic_row_iterators.h:106
bool m_first
Definition: basic_row_iterators.h:108
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:802
Definition: sql_optimizer.h:125
Definition: range_optimizer.h:221
This class represents a query block, aka a query specification, which is a query consisting of a SELE...
Definition: sql_lex.h:1123
A context for reading through a single table using a chosen access method: index read,...
Definition: row_iterator.h:60
THD * thd() const
Definition: row_iterator.h:190
Fetch the record IDs from a memory buffer, but the records themselves from the table on disk.
Definition: basic_row_iterators.h:205
uchar * m_cache_end
Definition: basic_row_iterators.h:232
bool m_has_null_flags
Definition: basic_row_iterators.h:234
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:309
ha_rows *const m_examined_rows
Definition: basic_row_iterators.h:231
bool m_ignore_not_found_rows
Definition: basic_row_iterators.h:233
void UnlockRow() override
Definition: basic_row_iterators.h:225
bool Init() override
Initialize or reinitialize the iterator.
Definition: sorting_iterator.cc:329
Mem_root_array< TABLE * > m_tables
Definition: basic_row_iterators.h:229
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:221
uint m_sum_ref_length
Definition: basic_row_iterators.h:230
Sort_result *const m_sort_result
Definition: basic_row_iterators.h:228
uchar * m_cache_pos
Definition: basic_row_iterators.h:232
~SortBufferIndirectIterator() override
Definition: sorting_iterator.cc:319
int Read() override
Read a single row.
Definition: sorting_iterator.cc:362
Fetch the records from a memory buffer.
Definition: basic_row_iterators.h:169
void UnlockRow() override
Definition: basic_row_iterators.h:180
bool Init() override
Initialize or reinitialize the iterator.
Definition: sorting_iterator.cc:271
unsigned m_unpack_counter
Definition: basic_row_iterators.h:190
Sort_result *const m_sort_result
Definition: basic_row_iterators.h:189
~SortBufferIterator() override
Definition: sorting_iterator.cc:265
int Read() override
Read a result set record from a buffer after sorting.
Definition: sorting_iterator.cc:295
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:181
ha_rows *const m_examined_rows
Definition: basic_row_iterators.h:191
SortBufferIterator(THD *thd, Mem_root_array< TABLE * > tables, Filesort_info *sort, Sort_result *sort_result, ha_rows *examined_rows)
Definition: sorting_iterator.cc:255
Mem_root_array< TABLE * > m_tables
Definition: basic_row_iterators.h:192
Filesort_info *const m_sort
Definition: basic_row_iterators.h:188
Fetch the record IDs from a temporary file, then the records themselves from the table on disk.
Definition: basic_row_iterators.h:280
int Read() override
Read a single row.
Definition: sorting_iterator.cc:156
IO_CACHE * m_io_cache
Definition: basic_row_iterators.h:301
~SortFileIndirectIterator() override
Definition: sorting_iterator.cc:96
Mem_root_array< TABLE * > m_tables
Definition: basic_row_iterators.h:303
ha_rows *const m_examined_rows
Definition: basic_row_iterators.h:302
bool m_has_null_flags
Definition: basic_row_iterators.h:306
bool m_ignore_not_found_rows
Definition: basic_row_iterators.h:305
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:86
void UnlockRow() override
Definition: basic_row_iterators.h:298
uint m_sum_ref_length
Definition: basic_row_iterators.h:308
bool Init() override
Initialize or reinitialize the iterator.
Definition: sorting_iterator.cc:105
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:294
uchar * m_ref_pos
Definition: basic_row_iterators.h:304
Fetch the records from a tempoary file.
Definition: basic_row_iterators.h:246
int Read() override
Read a result set record from a temporary file after sorting.
Definition: sorting_iterator.cc:228
const uint m_buf_length
Definition: basic_row_iterators.h:264
void UnlockRow() override
Definition: basic_row_iterators.h:256
ha_rows *const m_examined_rows
Definition: basic_row_iterators.h:268
uchar *const m_rec_buf
Definition: basic_row_iterators.h:263
IO_CACHE *const m_io_cache
Definition: basic_row_iterators.h:266
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:257
Filesort_info *const m_sort
Definition: basic_row_iterators.h:267
SortFileIterator(THD *thd, Mem_root_array< TABLE * > tables, IO_CACHE *tempfile, Filesort_info *sort, ha_rows *examined_rows)
Definition: sorting_iterator.cc:195
Mem_root_array< TABLE * > m_tables
Definition: basic_row_iterators.h:265
~SortFileIterator() override
Definition: sorting_iterator.cc:207
bool Init() override
Initialize or reinitialize the iterator.
Definition: basic_row_iterators.h:254
Definition: sql_sort.h:144
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:821
Definition: row_iterator.h:196
TABLE * table() const
Definition: row_iterator.h:208
Scan a table from beginning to end.
Definition: basic_row_iterators.h:60
const double m_expected_rows
Definition: basic_row_iterators.h:75
uchar *const m_record
Definition: basic_row_iterators.h:74
ha_rows *const m_examined_rows
Definition: basic_row_iterators.h:76
bool Init() override
Initialize or reinitialize the iterator.
Definition: records.cc:376
TableScanIterator(THD *thd, TABLE *table, double expected_rows, ha_rows *examined_rows)
Definition: records.cc:362
~TableScanIterator() override
Definition: records.cc:370
int Read() override
Read a single row.
Definition: records.cc:398
TableValueConstructor is the iterator for the table value constructor case of a query_primary (i....
Definition: basic_row_iterators.h:525
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:545
int Read() override
Read a single row.
Definition: sql_executor.cc:5317
bool Init() override
Initialize or reinitialize the iterator.
Definition: sql_executor.cc:5312
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:535
mem_root_deque< Item * > *const m_output_refs
References to the row we currently want to output.
Definition: basic_row_iterators.h:551
mem_root_deque< mem_root_deque< Item * > * >::const_iterator m_row_it
Definition: basic_row_iterators.h:546
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:5301
ha_rows *const m_examined_rows
Definition: basic_row_iterators.h:540
void UnlockRow() override
Definition: basic_row_iterators.h:537
An iterator for unqualified COUNT(*) (ie., no WHERE, no join conditions, etc.), taking a special fast...
Definition: basic_row_iterators.h:355
int Read() override
(end of group Query_Executor)
Definition: sql_executor.cc:5243
void UnlockRow() override
Definition: basic_row_iterators.h:369
bool Init() override
Initialize or reinitialize the iterator.
Definition: basic_row_iterators.h:360
UnqualifiedCountIterator(THD *thd, JOIN *join)
Definition: basic_row_iterators.h:357
bool m_has_row
Definition: basic_row_iterators.h:372
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:367
JOIN *const m_join
Definition: basic_row_iterators.h:373
Like ZeroRowsIterator, but produces a single output row, since there are aggregation functions presen...
Definition: basic_row_iterators.h:418
int Read() override
Read a single row.
Definition: sql_executor.cc:5272
JOIN *const m_join
Definition: basic_row_iterators.h:437
bool m_has_row
Definition: basic_row_iterators.h:436
ha_rows *const m_examined_rows
Definition: basic_row_iterators.h:438
ZeroRowsAggregatedIterator(THD *thd, JOIN *join, ha_rows *examined_rows)
Definition: basic_row_iterators.h:421
void UnlockRow() override
Definition: basic_row_iterators.h:433
bool Init() override
Initialize or reinitialize the iterator.
Definition: basic_row_iterators.h:424
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:431
A simple iterator that takes no input and produces zero output rows.
Definition: basic_row_iterators.h:387
unique_ptr_destroy_only< RowIterator > m_child_iterator
Definition: basic_row_iterators.h:405
bool Init() override
Initialize or reinitialize the iterator.
Definition: basic_row_iterators.h:393
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:397
int Read() override
Read a single row.
Definition: basic_row_iterators.h:395
void UnlockRow() override
Definition: basic_row_iterators.h:402
ZeroRowsIterator(THD *thd, unique_ptr_destroy_only< RowIterator > child_iterator)
Definition: basic_row_iterators.h:389
The handler class is the interface for dynamically loadable storage engines.
Definition: handler.h:4131
A (partial) implementation of std::deque allocating its blocks on a MEM_ROOT.
Definition: mem_root_deque.h:109
This file follows Google coding style, except for the name MEM_ROOT (which is kept for historical rea...
std::unique_ptr< T, Destroy_only< T > > unique_ptr_destroy_only
std::unique_ptr, but only destroying.
Definition: my_alloc.h:464
This file includes constants used by all storage engines.
my_off_t ha_rows
Definition: my_base.h:1138
Some integer typedefs for easier portability.
unsigned char uchar
Definition: my_inttypes.h:51
static bool quick
Definition: mysql.cc:154
std::string join(Container cont, const std::string &delim)
join elements of an container into a string separated by a delimiter.
Definition: string.h:144
Definition: varlen_sort.h:183
Definition: my_sys.h:340
Definition: table.h:1394
unsigned int uint
Definition: uca-dump.cc:29