MySQL 8.4.0
Source Code Documentation
basic_row_iterators.h
Go to the documentation of this file.
1#ifndef SQL_ITERATORS_BASIC_ROW_ITERATORS_H_
2#define SQL_ITERATORS_BASIC_ROW_ITERATORS_H_
3
4/* Copyright (c) 2018, 2024, Oracle and/or its affiliates.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License, version 2.0,
8 as published by the Free Software Foundation.
9
10 This program is designed to work with certain software (including
11 but not limited to OpenSSL) that is licensed under separate terms,
12 as designated in a particular file or component or in included license
13 documentation. The authors of MySQL hereby grant you an additional
14 permission to link the program and your derivative works with the
15 separately licensed software that they have either included with
16 the program or referenced in the documentation.
17
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License, version 2.0, for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software
25 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
26
27/**
28 @file
29 Row iterators that scan a single table without reference to other tables
30 or iterators.
31 */
32
33#include <assert.h>
34#include <sys/types.h>
35
36#include "mem_root_deque.h"
37#include "my_base.h"
38#include "my_inttypes.h"
40#include "sql/mem_root_array.h"
41
42class Filesort_info;
43class Item;
45class JOIN;
46class QUICK_RANGE;
47class Sort_result;
48class THD;
49struct IO_CACHE;
50struct TABLE;
51
52/**
53 Scan a table from beginning to end.
54
55 This is the most basic access method of a table using rnd_init,
56 ha_rnd_next and rnd_end. No indexes are used.
57*/
58class TableScanIterator final : public TableRowIterator {
59 public:
60 /**
61 @param thd session context
62 @param table table to be scanned. Notice that table may be a temporary
63 table that represents a set operation (UNION, INTERSECT or
64 EXCEPT). For the latter two, the counter field must be
65 interpreted by TableScanIterator::Read in order to give the
66 correct result set, but this is invisible to the consumer.
67 @param expected_rows is used for scaling the record buffer.
68 If zero or less, no record buffer will be set up.
69 @param examined_rows if not nullptr, is incremented for each successful
70 Read().
71 */
72 TableScanIterator(THD *thd, TABLE *table, double expected_rows,
73 ha_rows *examined_rows);
74 ~TableScanIterator() override;
75
76 bool Init() override;
77 int Read() override;
78
79 private:
81 const double m_expected_rows;
83 /// Used to keep track of how many more duplicates of the last read row that
84 /// remains to be written to the next stage: used for EXCEPT and INTERSECT
85 /// computation: we only ever materialize one row even if there are
86 /// duplicates of it, but with a counter, cf TABLE::m_set_counter. When we
87 /// start scanning we must produce as many duplicates as ALL semantics
88 /// mandate, so we initialize m_examined_rows based on TABLE::m_set_counter
89 /// and decrement for each row we emit, so as to produce the correct number
90 /// of duplicates for the next stage.
92 /// Used for EXCEPT and INTERSECT only: we cannot enforce limit during
93 /// materialization as for UNION and single table, so we have to do it during
94 /// the scan.
96 /// Used for EXCEPT and INTERSECT only: rows scanned so far, see also
97 /// m_limit_rows.
99};
100
101/** Perform a full index scan along an index. */
102template <bool Reverse>
104 public:
105 // use_order must be set to true if you actually need to get the records
106 // back in index order. It can be set to false if you wish to scan
107 // using the index (e.g. for an index-only scan of the entire table),
108 // but do not actually care about the order. In particular, partitioned
109 // tables can use this to deliver more efficient scans.
110 //
111 // “expected_rows” is used for scaling the record buffer.
112 // If zero or less, no record buffer will be set up.
113 //
114 // The pushed condition can be nullptr.
115 //
116 // "examined_rows", if not nullptr, is incremented for each successful Read().
117 IndexScanIterator(THD *thd, TABLE *table, int idx, bool use_order,
118 double expected_rows, ha_rows *examined_rows);
119 ~IndexScanIterator() override;
120
121 bool Init() override;
122 int Read() override;
123
124 private:
126 const int m_idx;
127 const bool m_use_order;
128 const double m_expected_rows;
130 bool m_first = true;
131};
132
133/**
134 Perform a distance index scan along an index.
135 For now it is just like the IndexScanIterator, waiting for innodb
136 implementation of distance index scan functions
137*/
139 public:
140 // “expected_rows” is used for scaling the record buffer.
141 // If zero or less, no record buffer will be set up.
142 //
143 // The pushed condition can be nullptr.
144 //
145 // "examined_rows", if not nullptr, is incremented for each successful Read().
147 QUICK_RANGE *query_mbr, double expected_rows,
148 ha_rows *examined_rows);
150
151 bool Init() override;
152 int Read() override;
153
154 private:
156 const int m_idx;
158 const double m_expected_rows;
160 bool m_first = true;
161};
162
163// Readers relating to reading sorted data (from filesort).
164//
165// Filesort will produce references to the records sorted; these
166// references can be stored in memory or in a temporary file.
167//
168// The temporary file is normally used when the references doesn't fit into
169// a properly sized memory buffer. For most small queries the references
170// are stored in the memory buffer.
171//
172// The temporary file is also used when performing an update where a key is
173// modified.
174
175/**
176 Fetch the records from a memory buffer.
177
178 This method is used when table->sort.addon_field is allocated.
179 This is allocated for most SELECT queries not involving any BLOB's.
180 In this case the records are fetched from a memory buffer.
181 */
182template <bool Packed_addon_fields>
183class SortBufferIterator final : public RowIterator {
184 public:
185 // "examined_rows", if not nullptr, is incremented for each successful Read().
186 // The table is used solely for NULL row flags.
188 Filesort_info *sort, Sort_result *sort_result,
189 ha_rows *examined_rows);
190 ~SortBufferIterator() override;
191
192 bool Init() override;
193 int Read() override;
194 void UnlockRow() override {}
195 void SetNullRowFlag(bool) override {
196 // Handled by SortingIterator.
197 assert(false);
198 }
199
200 private:
201 // NOTE: No m_record -- unpacks directly into each Field's field->ptr.
207};
208
209/**
210 Fetch the record IDs from a memory buffer, but the records themselves from
211 the table on disk.
212
213 Used when the above (comment on SortBufferIterator) is not true, UPDATE,
214 DELETE and so forth and SELECT's involving large BLOBs. It is also used for
215 the result of Unique, which returns row IDs in the same format as filesort.
216 In this case the record data is fetched from the handler using the saved
217 reference using the rnd_pos handler call.
218 */
220 public:
221 // Ownership here is suboptimal: Takes only partial ownership of
222 // "sort_result", so it must be alive for as long as the RowIterator is.
223 // However, it _does_ free the buffers within on destruction.
224 //
225 // The pushed condition can be nullptr.
226 //
227 // "examined_rows", if not nullptr, is incremented for each successful Read().
229 Sort_result *sort_result,
230 bool ignore_not_found_rows, bool has_null_flags,
231 ha_rows *examined_rows);
233 bool Init() override;
234 int Read() override;
235 void SetNullRowFlag(bool) override {
236 // Handled by SortingIterator.
237 assert(false);
238 }
239 void UnlockRow() override {}
240
241 private:
246 uchar *m_cache_pos = nullptr, *m_cache_end = nullptr;
249};
250
251/**
252 Fetch the records from a tempoary file.
253
254 There used to be a comment here saying “should obviously not really happen
255 other than in strange configurations”, but especially with packed addons
256 and InnoDB (where fetching rows needs a primary key lookup), it's not
257 necessarily suboptimal compared to e.g. SortBufferIndirectIterator.
258 */
259template <bool Packed_addon_fields>
260class SortFileIterator final : public RowIterator {
261 public:
262 // Takes ownership of tempfile.
263 // The table is used solely for NULL row flags.
265 Filesort_info *sort, ha_rows *examined_rows);
266 ~SortFileIterator() override;
267
268 bool Init() override { return false; }
269 int Read() override;
270 void UnlockRow() override {}
271 void SetNullRowFlag(bool) override {
272 // Handled by SortingIterator.
273 assert(false);
274 }
275
276 private:
278 const uint m_buf_length;
283};
284
285/**
286 Fetch the record IDs from a temporary file, then the records themselves from
287 the table on disk.
288
289 Same as SortBufferIndirectIterator except that references are fetched
290 from temporary file instead of from a memory buffer. So first the record IDs
291 are read from file, then those record IDs are used to look up rows in the
292 table.
293 */
295 public:
296 // Takes ownership of tempfile.
297 //
298 // The pushed condition can be nullptr.
299 //
300 // "examined_rows", if not nullptr, is incremented for each successful Read().
302 IO_CACHE *tempfile, bool ignore_not_found_rows,
303 bool has_null_flags, ha_rows *examined_rows);
304 ~SortFileIndirectIterator() override;
305
306 bool Init() override;
307 int Read() override;
308 void SetNullRowFlag(bool) override {
309 // Handled by SortingIterator.
310 assert(false);
311 }
312 void UnlockRow() override {}
313
314 private:
318 uchar *m_ref_pos = nullptr;
321
323};
324
325// Used when the plan is const, ie. is known to contain a single row
326// (and all values have been read in advance, so we don't need to read
327// a single table).
328class FakeSingleRowIterator final : public RowIterator {
329 public:
330 // "examined_rows", if not nullptr, is incremented for each successful Read().
332 : RowIterator(thd), m_examined_rows(examined_rows) {}
333
334 bool Init() override {
335 m_has_row = true;
336 return false;
337 }
338
339 int Read() override {
340 if (m_has_row) {
341 m_has_row = false;
342 if (m_examined_rows != nullptr) {
344 }
345 return 0;
346 } else {
347 return -1;
348 }
349 }
350
351 void SetNullRowFlag(bool is_null_row [[maybe_unused]]) override {
352 assert(!is_null_row);
353 }
354
355 void UnlockRow() override {}
356
357 private:
360};
361
362/**
363 An iterator for unqualified COUNT(*) (ie., no WHERE, no join conditions,
364 etc.), taking a special fast path in the handler. It returns a single row,
365 much like FakeSingleRowIterator; however, unlike said iterator, it actually
366 does the counting in Read() instead of expecting all fields to already be
367 filled out.
368 */
370 public:
372 : RowIterator(thd), m_join(join) {}
373
374 bool Init() override {
375 m_has_row = true;
376 return false;
377 }
378
379 int Read() override;
380
381 void SetNullRowFlag(bool) override { assert(false); }
382
383 void UnlockRow() override {}
384
385 private:
387 JOIN *const m_join;
388};
389
390/**
391 A simple iterator that takes no input and produces zero output rows.
392 Used when the optimizer has figured out ahead of time that a given table
393 can produce no output (e.g. SELECT ... WHERE 2+2 = 5).
394
395 The iterator can optionally have an array of the tables that are pruned away
396 from the join tree by this iterator. It is only required when the iterator is
397 on the inner side of an outer join, in which case it needs it in order to
398 NULL-complement the rows in SetNullRowFlag().
399 */
400class ZeroRowsIterator final : public RowIterator {
401 public:
403
404 bool Init() override { return false; }
405
406 int Read() override { return -1; }
407
408 void SetNullRowFlag(bool is_null_row) override;
409
410 void UnlockRow() override {}
411
412 private:
414};
415
416/**
417 Like ZeroRowsIterator, but produces a single output row, since there are
418 aggregation functions present and no GROUP BY. E.g.,
419
420 SELECT SUM(f1) FROM t1 WHERE 2+2 = 5;
421
422 should produce a single row, containing only the value NULL.
423 */
425 public:
426 // "examined_rows", if not nullptr, is incremented for each successful Read().
428 : RowIterator(thd), m_join(join), m_examined_rows(examined_rows) {}
429
430 bool Init() override {
431 m_has_row = true;
432 return false;
433 }
434
435 int Read() override;
436
437 void SetNullRowFlag(bool) override { assert(false); }
438
439 void UnlockRow() override {}
440
441 private:
443 JOIN *const m_join;
445};
446
447/**
448 FollowTailIterator is a special version of TableScanIterator that is used
449 as part of WITH RECURSIVE queries. It is designed to read from a temporary
450 table at the same time as MaterializeIterator writes to the same table,
451 picking up new records in the order they come in -- it follows the tail,
452 much like the UNIX tool “tail -f”.
453
454 Furthermore, when materializing a recursive query expression consisting of
455 multiple query blocks, MaterializeIterator needs to run each block several
456 times until convergence. (For a single query block, one iteration suffices,
457 since the iterator sees new records as they come in.) Each such run, the
458 recursive references should see only rows that were added since the last
459 iteration, even though Init() is called anew. FollowTailIterator is thus
460 different from TableScanIterator in that subsequent calls to Init() do not
461 move the cursor back to the start.
462
463 In addition, FollowTailIterator implements the WITH RECURSIVE iteration limit.
464 This is not specified in terms of Init() calls, since one run can encompass
465 many iterations. Instead, it keeps track of the number of records in the table
466 at the start of iteration, and when it has read all of those records, the next
467 iteration is deemed to have begun. If the iteration counter is above the
468 user-set limit, it raises an error to stop runaway queries with infinite
469 recursion.
470 */
472 public:
473 // "examined_rows", if not nullptr, is incremented for each successful Read().
474 FollowTailIterator(THD *thd, TABLE *table, double expected_rows,
475 ha_rows *examined_rows);
476 ~FollowTailIterator() override;
477
478 bool Init() override;
479 int Read() override;
480
481 /**
482 Signal where we can expect to find the number of generated rows for this
483 materialization (this points into the MaterializeIterator's data).
484
485 This must be called when we start materializing the CTE,
486 before Init() runs.
487 */
488 void set_stored_rows_pointer(ha_rows *stored_rows) {
489 m_stored_rows = stored_rows;
490 }
491
492 /**
493 Signal to the iterator that the underlying table was closed and replaced
494 with an InnoDB table with the same data, due to a spill-to-disk
495 (e.g. the table used to be MEMORY and now is InnoDB). This is
496 required so that Read() can continue scanning from the right place.
497 Called by MaterializeIterator::MaterializeRecursive().
498 */
500
501 private:
502 bool m_inited = false;
504 const double m_expected_rows;
509
510 // Points into MaterializeIterator's data; set by BeginMaterialization() only.
512};
513
514/**
515 TableValueConstructor is the iterator for the table value constructor case of
516 a query_primary (i.e. queries of the form VALUES row_list; e.g. VALUES ROW(1,
517 10), ROW(2, 20)).
518
519 The iterator is passed the field list of its parent JOIN object, which may
520 contain Item_values_column objects that are created during
521 Query_block::prepare_values(). This is required so that Read() can replace the
522 currently selected row by simply changing the references of Item_values_column
523 objects to the next row.
524
525 The iterator must output multiple rows without being materialized, and does
526 not scan any tables. The indirection of Item_values_column is required, as the
527 executor outputs what is contained in join->fields (either directly, or
528 indirectly through ConvertItemsToCopy), and is thus responsible for ensuring
529 that join->fields contains the correct next row.
530 */
532 public:
534 THD *thd, ha_rows *examined_rows,
535 const mem_root_deque<mem_root_deque<Item *> *> &row_value_list,
537
538 bool Init() override;
539 int Read() override;
540
541 void SetNullRowFlag(bool) override { assert(false); }
542
543 void UnlockRow() override {}
544
545 private:
546 ha_rows *const m_examined_rows{nullptr};
547
548 /// Contains the row values that are part of a VALUES clause. Read() will
549 /// modify contained Item objects during execution by calls to is_null() and
550 /// the required val function to extract its value.
553
554 /// References to the row we currently want to output. When multiple rows must
555 /// be output, this contains Item_values_column objects. In this case, each
556 /// call to Read() will replace its current reference with the next row.
557 /// It is nullptr if there is only one row.
559};
560
561/**
562 Auxiliary class to squeeze two 32 bits integers into a 64 bits one, cf.
563 logic of INTERSECT ALL in
564 MaterializeIterator<Profiler>::MaterializeOperand.
565 For INTERSECT ALL we need two counters: the number of duplicates in the left
566 operand, and the number of matches seen (so far) from the right operand.
567 Instead of adding another field to the temporary table, we subdivide the
568 64 bits counter we already have. This imposes an implementation restriction
569 on INTERSECT ALL: the resulting table must have <= uint32::max duplicates of
570 any row.
571 */
573 union {
574 /// [0]: # of duplicates on left side of INTERSECT ALL
575 /// [1]: # of duplicates on right side of INTERSECT ALL. Always <= [0].
576 uint32_t m_value[2];
577 uint64_t m_value64;
579
580 public:
581 HalfCounter(uint64_t packed) { data.m_value64 = packed; }
582 uint64_t value() const { return data.m_value64; }
583 uint32_t &operator[](size_t idx) {
584 assert(idx == 0 || idx == 1);
585 return data.m_value[idx];
586 }
587};
588
589#endif // SQL_ITERATORS_BASIC_ROW_ITERATORS_H_
Definition: basic_row_iterators.h:328
int Read() override
Read a single row.
Definition: basic_row_iterators.h:339
void UnlockRow() override
Definition: basic_row_iterators.h:355
bool m_has_row
Definition: basic_row_iterators.h:358
ha_rows *const m_examined_rows
Definition: basic_row_iterators.h:359
bool Init() override
Initialize or reinitialize the iterator.
Definition: basic_row_iterators.h:334
FakeSingleRowIterator(THD *thd, ha_rows *examined_rows)
Definition: basic_row_iterators.h:331
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:351
A class wrapping misc buffers used for sorting.
Definition: sql_sort.h:189
FollowTailIterator is a special version of TableScanIterator that is used as part of WITH RECURSIVE q...
Definition: basic_row_iterators.h:471
bool RepositionCursorAfterSpillToDisk()
Signal to the iterator that the underlying table was closed and replaced with an InnoDB table with th...
Definition: basic_row_iterators.cc:507
FollowTailIterator(THD *thd, TABLE *table, double expected_rows, ha_rows *examined_rows)
Definition: basic_row_iterators.cc:368
ha_rows *const m_examined_rows
Definition: basic_row_iterators.h:505
unsigned m_recursive_iteration_count
Definition: basic_row_iterators.h:508
const double m_expected_rows
Definition: basic_row_iterators.h:504
bool Init() override
Initialize or reinitialize the iterator.
Definition: basic_row_iterators.cc:382
bool m_inited
Definition: basic_row_iterators.h:502
uchar *const m_record
Definition: basic_row_iterators.h:503
ha_rows * m_stored_rows
Definition: basic_row_iterators.h:511
ha_rows m_read_rows
Definition: basic_row_iterators.h:506
int Read() override
Read a single row.
Definition: basic_row_iterators.cc:432
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:488
~FollowTailIterator() override
Definition: basic_row_iterators.cc:376
ha_rows m_end_of_current_iteration
Definition: basic_row_iterators.h:507
Auxiliary class to squeeze two 32 bits integers into a 64 bits one, cf.
Definition: basic_row_iterators.h:572
HalfCounter(uint64_t packed)
Definition: basic_row_iterators.h:581
union HalfCounter::@58 data
uint64_t value() const
Definition: basic_row_iterators.h:582
uint32_t & operator[](size_t idx)
Definition: basic_row_iterators.h:583
uint32_t m_value[2]
[0]: # of duplicates on left side of INTERSECT ALL [1]: # of duplicates on right side of INTERSECT AL...
Definition: basic_row_iterators.h:576
uint64_t m_value64
Definition: basic_row_iterators.h:577
Perform a distance index scan along an index.
Definition: basic_row_iterators.h:138
QUICK_RANGE * m_query_mbr
Definition: basic_row_iterators.h:157
ha_rows *const m_examined_rows
Definition: basic_row_iterators.h:159
~IndexDistanceScanIterator() override
Definition: basic_row_iterators.cc:153
int Read() override
Read a single row.
Definition: basic_row_iterators.cc:187
IndexDistanceScanIterator(THD *thd, TABLE *table, int idx, QUICK_RANGE *query_mbr, double expected_rows, ha_rows *examined_rows)
Definition: basic_row_iterators.cc:137
bool m_first
Definition: basic_row_iterators.h:160
const int m_idx
Definition: basic_row_iterators.h:156
uchar *const m_record
Definition: basic_row_iterators.h:155
const double m_expected_rows
Definition: basic_row_iterators.h:158
bool Init() override
Initialize or reinitialize the iterator.
Definition: basic_row_iterators.cc:161
Perform a full index scan along an index.
Definition: basic_row_iterators.h:103
const int m_idx
Definition: basic_row_iterators.h:126
ha_rows *const m_examined_rows
Definition: basic_row_iterators.h:129
int Read() override
Read a single row.
bool Init() override
Initialize or reinitialize the iterator.
Definition: basic_row_iterators.cc:78
IndexScanIterator(THD *thd, TABLE *table, int idx, bool use_order, double expected_rows, ha_rows *examined_rows)
Definition: basic_row_iterators.cc:59
uchar *const m_record
Definition: basic_row_iterators.h:125
~IndexScanIterator() override
Definition: basic_row_iterators.cc:71
const bool m_use_order
Definition: basic_row_iterators.h:127
const double m_expected_rows
Definition: basic_row_iterators.h:128
bool m_first
Definition: basic_row_iterators.h:130
Reference item that encapsulates both the type and the contained items of a single column of a VALUES...
Definition: item.h:7305
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:934
Definition: sql_optimizer.h:133
A typesafe replacement for DYNAMIC_ARRAY.
Definition: mem_root_array.h:426
Definition: range_optimizer.h:69
A context for reading through a single table using a chosen access method: index read,...
Definition: row_iterator.h:82
THD * thd() const
Definition: row_iterator.h:228
Fetch the record IDs from a memory buffer, but the records themselves from the table on disk.
Definition: basic_row_iterators.h:219
uchar * m_cache_end
Definition: basic_row_iterators.h:246
bool m_has_null_flags
Definition: basic_row_iterators.h:248
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:245
bool m_ignore_not_found_rows
Definition: basic_row_iterators.h:247
void UnlockRow() override
Definition: basic_row_iterators.h:239
bool Init() override
Initialize or reinitialize the iterator.
Definition: sorting_iterator.cc:329
Mem_root_array< TABLE * > m_tables
Definition: basic_row_iterators.h:243
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:235
uint m_sum_ref_length
Definition: basic_row_iterators.h:244
Sort_result *const m_sort_result
Definition: basic_row_iterators.h:242
uchar * m_cache_pos
Definition: basic_row_iterators.h:246
~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:183
void UnlockRow() override
Definition: basic_row_iterators.h:194
bool Init() override
Initialize or reinitialize the iterator.
Definition: sorting_iterator.cc:271
unsigned m_unpack_counter
Definition: basic_row_iterators.h:204
Sort_result *const m_sort_result
Definition: basic_row_iterators.h:203
~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:195
ha_rows *const m_examined_rows
Definition: basic_row_iterators.h:205
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:206
Filesort_info *const m_sort
Definition: basic_row_iterators.h:202
Fetch the record IDs from a temporary file, then the records themselves from the table on disk.
Definition: basic_row_iterators.h:294
int Read() override
Read a single row.
Definition: sorting_iterator.cc:156
IO_CACHE * m_io_cache
Definition: basic_row_iterators.h:315
~SortFileIndirectIterator() override
Definition: sorting_iterator.cc:96
Mem_root_array< TABLE * > m_tables
Definition: basic_row_iterators.h:317
ha_rows *const m_examined_rows
Definition: basic_row_iterators.h:316
bool m_has_null_flags
Definition: basic_row_iterators.h:320
bool m_ignore_not_found_rows
Definition: basic_row_iterators.h:319
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:312
uint m_sum_ref_length
Definition: basic_row_iterators.h:322
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:308
uchar * m_ref_pos
Definition: basic_row_iterators.h:318
Fetch the records from a tempoary file.
Definition: basic_row_iterators.h:260
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:278
void UnlockRow() override
Definition: basic_row_iterators.h:270
ha_rows *const m_examined_rows
Definition: basic_row_iterators.h:282
uchar *const m_rec_buf
Definition: basic_row_iterators.h:277
IO_CACHE *const m_io_cache
Definition: basic_row_iterators.h:280
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:271
Filesort_info *const m_sort
Definition: basic_row_iterators.h:281
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:279
~SortFileIterator() override
Definition: sorting_iterator.cc:207
bool Init() override
Initialize or reinitialize the iterator.
Definition: basic_row_iterators.h:268
Definition: sql_sort.h:156
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
Definition: row_iterator.h:234
TABLE * table() const
Definition: row_iterator.h:246
Scan a table from beginning to end.
Definition: basic_row_iterators.h:58
const double m_expected_rows
Definition: basic_row_iterators.h:81
uchar *const m_record
Definition: basic_row_iterators.h:80
const ha_rows m_limit_rows
Used for EXCEPT and INTERSECT only: we cannot enforce limit during materialization as for UNION and s...
Definition: basic_row_iterators.h:95
ha_rows *const m_examined_rows
Definition: basic_row_iterators.h:82
ulonglong m_remaining_dups
Used to keep track of how many more duplicates of the last read row that remains to be written to the...
Definition: basic_row_iterators.h:91
ha_rows m_stored_rows
Used for EXCEPT and INTERSECT only: rows scanned so far, see also m_limit_rows.
Definition: basic_row_iterators.h:98
bool Init() override
Initialize or reinitialize the iterator.
Definition: basic_row_iterators.cc:267
TableScanIterator(THD *thd, TABLE *table, double expected_rows, ha_rows *examined_rows)
Definition: basic_row_iterators.cc:251
~TableScanIterator() override
Definition: basic_row_iterators.cc:261
int Read() override
Read a single row.
Definition: basic_row_iterators.cc:291
TableValueConstructor is the iterator for the table value constructor case of a query_primary (i....
Definition: basic_row_iterators.h:531
Mem_root_array< Item_values_column * > * m_output_refs
References to the row we currently want to output.
Definition: basic_row_iterators.h:558
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:551
mem_root_deque< mem_root_deque< Item * > * >::const_iterator m_row_it
Definition: basic_row_iterators.h:552
int Read() override
Read a single row.
Definition: ref_row_iterators.cc:922
bool Init() override
Initialize or reinitialize the iterator.
Definition: ref_row_iterators.cc:917
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:541
TableValueConstructorIterator(THD *thd, ha_rows *examined_rows, const mem_root_deque< mem_root_deque< Item * > * > &row_value_list, Mem_root_array< Item_values_column * > *output_refs)
Definition: ref_row_iterators.cc:906
ha_rows *const m_examined_rows
Definition: basic_row_iterators.h:546
void UnlockRow() override
Definition: basic_row_iterators.h:543
An iterator for unqualified COUNT(*) (ie., no WHERE, no join conditions, etc.), taking a special fast...
Definition: basic_row_iterators.h:369
int Read() override
Read a single row.
Definition: ref_row_iterators.cc:848
void UnlockRow() override
Definition: basic_row_iterators.h:383
bool Init() override
Initialize or reinitialize the iterator.
Definition: basic_row_iterators.h:374
UnqualifiedCountIterator(THD *thd, JOIN *join)
Definition: basic_row_iterators.h:371
bool m_has_row
Definition: basic_row_iterators.h:386
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:381
JOIN *const m_join
Definition: basic_row_iterators.h:387
Like ZeroRowsIterator, but produces a single output row, since there are aggregation functions presen...
Definition: basic_row_iterators.h:424
int Read() override
Read a single row.
Definition: ref_row_iterators.cc:877
JOIN *const m_join
Definition: basic_row_iterators.h:443
bool m_has_row
Definition: basic_row_iterators.h:442
ha_rows *const m_examined_rows
Definition: basic_row_iterators.h:444
ZeroRowsAggregatedIterator(THD *thd, JOIN *join, ha_rows *examined_rows)
Definition: basic_row_iterators.h:427
void UnlockRow() override
Definition: basic_row_iterators.h:439
bool Init() override
Initialize or reinitialize the iterator.
Definition: basic_row_iterators.h:430
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:437
A simple iterator that takes no input and produces zero output rows.
Definition: basic_row_iterators.h:400
bool Init() override
Initialize or reinitialize the iterator.
Definition: basic_row_iterators.h:404
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.cc:357
int Read() override
Read a single row.
Definition: basic_row_iterators.h:406
void UnlockRow() override
Definition: basic_row_iterators.h:410
ZeroRowsIterator(THD *thd, Mem_root_array< TABLE * > pruned_tables)
Definition: basic_row_iterators.cc:353
const Mem_root_array< TABLE * > m_pruned_tables
Definition: basic_row_iterators.h:413
A (partial) implementation of std::deque allocating its blocks on a MEM_ROOT.
Definition: mem_root_deque.h:111
This file includes constants used by all storage engines.
my_off_t ha_rows
Definition: my_base.h:1141
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:56
unsigned char uchar
Definition: my_inttypes.h:52
std::string join(Container cont, const std::string &delim)
join elements of an container into a string separated by a delimiter.
Definition: string.h:151
Definition: my_sys.h:346
Definition: table.h:1405