MySQL 9.5.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, 2025, 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 private:
77 bool DoInit() override;
78 int DoRead() override;
79
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 private:
122 bool DoInit() override;
123 int DoRead() override;
124
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);
149
150 private:
151 bool DoInit() override;
152 int DoRead() override;
153
155 const int m_idx;
157 const double m_expected_rows;
159 bool m_first = true;
160};
161
162// Readers relating to reading sorted data (from filesort).
163//
164// Filesort will produce references to the records sorted; these
165// references can be stored in memory or in a temporary file.
166//
167// The temporary file is normally used when the references doesn't fit into
168// a properly sized memory buffer. For most small queries the references
169// are stored in the memory buffer.
170//
171// The temporary file is also used when performing an update where a key is
172// modified.
173
174/**
175 Fetch the records from a memory buffer.
176
177 This method is used when table->sort.addon_field is allocated.
178 This is allocated for most SELECT queries not involving any BLOB's.
179 In this case the records are fetched from a memory buffer.
180 */
181template <bool Packed_addon_fields>
182class SortBufferIterator final : public RowIterator {
183 public:
184 // "examined_rows", if not nullptr, is incremented for each successful Read().
185 // The table is used solely for NULL row flags.
187 Filesort_info *sort, Sort_result *sort_result,
188 ha_rows *examined_rows);
189 ~SortBufferIterator() override;
190
191 void UnlockRow() override {}
192 void SetNullRowFlag(bool) override {
193 // Handled by SortingIterator.
194 assert(false);
195 }
196
197 private:
198 bool DoInit() override;
199 int DoRead() override;
200
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 void SetNullRowFlag(bool) override {
234 // Handled by SortingIterator.
235 assert(false);
236 }
237 void UnlockRow() override {}
238
239 private:
240 bool DoInit() override;
241 int DoRead() override;
242
247 uchar *m_cache_pos = nullptr, *m_cache_end = nullptr;
250};
251
252/**
253 Fetch the records from a tempoary file.
254
255 There used to be a comment here saying “should obviously not really happen
256 other than in strange configurations”, but especially with packed addons
257 and InnoDB (where fetching rows needs a primary key lookup), it's not
258 necessarily suboptimal compared to e.g. SortBufferIndirectIterator.
259 */
260template <bool Packed_addon_fields>
261class SortFileIterator final : public RowIterator {
262 public:
263 // Takes ownership of tempfile.
264 // The table is used solely for NULL row flags.
266 Filesort_info *sort, ha_rows *examined_rows);
267 ~SortFileIterator() override;
268
269 void UnlockRow() override {}
270 void SetNullRowFlag(bool) override {
271 // Handled by SortingIterator.
272 assert(false);
273 }
274
275 private:
276 bool DoInit() override { return false; }
277 int DoRead() override;
278
280 const uint m_buf_length;
285};
286
287/**
288 Fetch the record IDs from a temporary file, then the records themselves from
289 the table on disk.
290
291 Same as SortBufferIndirectIterator except that references are fetched
292 from temporary file instead of from a memory buffer. So first the record IDs
293 are read from file, then those record IDs are used to look up rows in the
294 table.
295 */
297 public:
298 // Takes ownership of tempfile.
299 //
300 // The pushed condition can be nullptr.
301 //
302 // "examined_rows", if not nullptr, is incremented for each successful Read().
304 IO_CACHE *tempfile, bool ignore_not_found_rows,
305 bool has_null_flags, ha_rows *examined_rows);
306 ~SortFileIndirectIterator() override;
307
308 void SetNullRowFlag(bool) override {
309 // Handled by SortingIterator.
310 assert(false);
311 }
312 void UnlockRow() override {}
313
314 private:
315 bool DoInit() override;
316 int DoRead() override;
317
321 uchar *m_ref_pos = nullptr;
324
326};
327
328// Used when the plan is const, ie. is known to contain a single row
329// (and all values have been read in advance, so we don't need to read
330// a single table).
331class FakeSingleRowIterator final : public RowIterator {
332 public:
333 // "examined_rows", if not nullptr, is incremented for each successful Read().
335 : RowIterator(thd), m_examined_rows(examined_rows) {}
336
337 private:
338 bool DoInit() override {
339 m_has_row = true;
340 return false;
341 }
342
343 int DoRead() override {
344 if (m_has_row) {
345 m_has_row = false;
346 if (m_examined_rows != nullptr) {
348 }
349 return 0;
350 } else {
351 return -1;
352 }
353 }
354
355 public:
356 void SetNullRowFlag(bool is_null_row [[maybe_unused]]) override {
357 assert(!is_null_row);
358 }
359
360 void UnlockRow() override {}
361
362 private:
365};
366
367/**
368 An iterator for unqualified COUNT(*) (ie., no WHERE, no join conditions,
369 etc.), taking a special fast path in the handler. It returns a single row,
370 much like FakeSingleRowIterator; however, unlike said iterator, it actually
371 does the counting in Read() instead of expecting all fields to already be
372 filled out.
373 */
375 public:
377 : RowIterator(thd), m_join(join) {}
378
379 void SetNullRowFlag(bool) override { assert(false); }
380
381 void UnlockRow() override {}
382
383 private:
384 bool DoInit() override {
385 m_has_row = true;
386 return false;
387 }
388
389 int DoRead() override;
390
392 JOIN *const m_join;
393};
394
395/**
396 A simple iterator that takes no input and produces zero output rows.
397 Used when the optimizer has figured out ahead of time that a given table
398 can produce no output (e.g. SELECT ... WHERE 2+2 = 5).
399
400 The iterator can optionally have an array of the tables that are pruned away
401 from the join tree by this iterator. It is only required when the iterator is
402 on the inner side of an outer join, in which case it needs it in order to
403 NULL-complement the rows in SetNullRowFlag().
404 */
405class ZeroRowsIterator final : public RowIterator {
406 public:
408
409 void SetNullRowFlag(bool is_null_row) override;
410
411 void UnlockRow() override {}
412
413 private:
414 bool DoInit() override { return false; }
415
416 int DoRead() override { return -1; }
417
419};
420
421/**
422 Like ZeroRowsIterator, but produces a single output row, since there are
423 aggregation functions present and no GROUP BY. E.g.,
424
425 SELECT SUM(f1) FROM t1 WHERE 2+2 = 5;
426
427 should produce a single row, containing only the value NULL.
428 */
430 public:
431 // "examined_rows", if not nullptr, is incremented for each successful Read().
433 : RowIterator(thd), m_join(join), m_examined_rows(examined_rows) {}
434
435 void SetNullRowFlag(bool) override { assert(false); }
436
437 void UnlockRow() override {}
438
439 private:
440 bool DoInit() override {
441 m_has_row = true;
442 return false;
443 }
444
445 int DoRead() override;
446
448 JOIN *const m_join;
450};
451
452/**
453 FollowTailIterator is a special version of TableScanIterator that is used
454 as part of WITH RECURSIVE queries. It is designed to read from a temporary
455 table at the same time as MaterializeIterator writes to the same table,
456 picking up new records in the order they come in -- it follows the tail,
457 much like the UNIX tool “tail -f”.
458
459 Furthermore, when materializing a recursive query expression consisting of
460 multiple query blocks, MaterializeIterator needs to run each block several
461 times until convergence. (For a single query block, one iteration suffices,
462 since the iterator sees new records as they come in.) Each such run, the
463 recursive references should see only rows that were added since the last
464 iteration, even though Init() is called anew. FollowTailIterator is thus
465 different from TableScanIterator in that subsequent calls to Init() do not
466 move the cursor back to the start.
467
468 In addition, FollowTailIterator implements the WITH RECURSIVE iteration limit.
469 This is not specified in terms of Init() calls, since one run can encompass
470 many iterations. Instead, it keeps track of the number of records in the table
471 at the start of iteration, and when it has read all of those records, the next
472 iteration is deemed to have begun. If the iteration counter is above the
473 user-set limit, it raises an error to stop runaway queries with infinite
474 recursion.
475 */
477 public:
478 // "examined_rows", if not nullptr, is incremented for each successful Read().
479 FollowTailIterator(THD *thd, TABLE *table, double expected_rows,
480 ha_rows *examined_rows);
481 ~FollowTailIterator() override;
482
483 /**
484 Signal where we can expect to find the number of generated rows for this
485 materialization (this points into the MaterializeIterator's data).
486
487 This must be called when we start materializing the CTE,
488 before Init() runs.
489 */
490 void set_stored_rows_pointer(ha_rows *stored_rows) {
491 m_stored_rows = stored_rows;
492 }
493
494 /**
495 Signal to the iterator that the underlying table was closed and replaced
496 with an InnoDB table with the same data, due to a spill-to-disk
497 (e.g. the table used to be MEMORY and now is InnoDB). This is
498 required so that Read() can continue scanning from the right place.
499 Called by MaterializeIterator::MaterializeRecursive().
500 */
502
503 private:
504 bool DoInit() override;
505 int DoRead() override;
506
507 bool m_inited = false;
509 const double m_expected_rows;
514
515 // Points into MaterializeIterator's data; set by BeginMaterialization() only.
517};
518
519/**
520 TableValueConstructor is the iterator for the table value constructor case of
521 a query_primary (i.e. queries of the form VALUES row_list; e.g. VALUES ROW(1,
522 10), ROW(2, 20)).
523
524 The iterator is passed the field list of its parent JOIN object, which may
525 contain Item_values_column objects that are created during
526 Query_block::prepare_values(). This is required so that Read() can replace the
527 currently selected row by simply changing the references of Item_values_column
528 objects to the next row.
529
530 The iterator must output multiple rows without being materialized, and does
531 not scan any tables. The indirection of Item_values_column is required, as the
532 executor outputs what is contained in join->fields (either directly, or
533 indirectly through ConvertItemsToCopy), and is thus responsible for ensuring
534 that join->fields contains the correct next row.
535 */
537 public:
539 THD *thd, ha_rows *examined_rows,
540 const mem_root_deque<mem_root_deque<Item *> *> &row_value_list,
542
543 void SetNullRowFlag(bool) override { assert(false); }
544
545 void UnlockRow() override {}
546
547 private:
548 bool DoInit() override;
549 int DoRead() override;
550
551 ha_rows *const m_examined_rows{nullptr};
552
553 /// Contains the row values that are part of a VALUES clause. Read() will
554 /// modify contained Item objects during execution by calls to is_null() and
555 /// the required val function to extract its value.
558
559 /// References to the row we currently want to output. When multiple rows must
560 /// be output, this contains Item_values_column objects. In this case, each
561 /// call to Read() will replace its current reference with the next row.
562 /// It is nullptr if there is only one row.
564};
565
566/**
567 Auxiliary class to squeeze two 32 bits integers into a 64 bits one, cf.
568 logic of INTERSECT ALL in
569 MaterializeIterator<Profiler>::MaterializeOperand.
570 For INTERSECT ALL we need two counters: the number of duplicates in the left
571 operand, and the number of matches seen (so far) from the right operand.
572 Instead of adding another field to the temporary table, we subdivide the
573 64 bits counter we already have. This imposes an implementation restriction
574 on INTERSECT ALL: the resulting table must have <= uint32::max duplicates of
575 any row.
576 */
578 union {
579 /// [0]: # of duplicates on left side of INTERSECT ALL
580 /// [1]: # of duplicates on right side of INTERSECT ALL. Always <= [0].
581 uint32_t m_value[2];
582 uint64_t m_value64;
584
585 public:
586 HalfCounter(uint64_t packed) { data.m_value64 = packed; }
587 uint64_t value() const { return data.m_value64; }
588 uint32_t &operator[](size_t idx) {
589 assert(idx == 0 || idx == 1);
590 return data.m_value[idx];
591 }
592};
593
594#endif // SQL_ITERATORS_BASIC_ROW_ITERATORS_H_
Definition: basic_row_iterators.h:331
void UnlockRow() override
Definition: basic_row_iterators.h:360
bool m_has_row
Definition: basic_row_iterators.h:363
int DoRead() override
Definition: basic_row_iterators.h:343
ha_rows *const m_examined_rows
Definition: basic_row_iterators.h:364
bool DoInit() override
Definition: basic_row_iterators.h:338
FakeSingleRowIterator(THD *thd, ha_rows *examined_rows)
Definition: basic_row_iterators.h:334
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:356
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:476
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:492
FollowTailIterator(THD *thd, TABLE *table, double expected_rows, ha_rows *examined_rows)
Definition: basic_row_iterators.cc:353
ha_rows *const m_examined_rows
Definition: basic_row_iterators.h:510
int DoRead() override
Definition: basic_row_iterators.cc:417
unsigned m_recursive_iteration_count
Definition: basic_row_iterators.h:513
const double m_expected_rows
Definition: basic_row_iterators.h:509
bool DoInit() override
Definition: basic_row_iterators.cc:367
bool m_inited
Definition: basic_row_iterators.h:507
uchar *const m_record
Definition: basic_row_iterators.h:508
ha_rows * m_stored_rows
Definition: basic_row_iterators.h:516
ha_rows m_read_rows
Definition: basic_row_iterators.h:511
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:490
~FollowTailIterator() override
Definition: basic_row_iterators.cc:361
ha_rows m_end_of_current_iteration
Definition: basic_row_iterators.h:512
Auxiliary class to squeeze two 32 bits integers into a 64 bits one, cf.
Definition: basic_row_iterators.h:577
HalfCounter(uint64_t packed)
Definition: basic_row_iterators.h:586
union HalfCounter::@63 data
uint64_t value() const
Definition: basic_row_iterators.h:587
uint32_t & operator[](size_t idx)
Definition: basic_row_iterators.h:588
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:581
uint64_t m_value64
Definition: basic_row_iterators.h:582
Perform a distance index scan along an index.
Definition: basic_row_iterators.h:138
QUICK_RANGE * m_query_mbr
Definition: basic_row_iterators.h:156
ha_rows *const m_examined_rows
Definition: basic_row_iterators.h:158
bool DoInit() override
Definition: basic_row_iterators.cc:154
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:159
int DoRead() override
Definition: basic_row_iterators.cc:172
const int m_idx
Definition: basic_row_iterators.h:155
uchar *const m_record
Definition: basic_row_iterators.h:154
const double m_expected_rows
Definition: basic_row_iterators.h:157
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
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
int DoRead() override
const double m_expected_rows
Definition: basic_row_iterators.h:128
bool DoInit() override
Definition: basic_row_iterators.cc:78
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:7417
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:928
Definition: sql_optimizer.h:133
A typesafe replacement for DYNAMIC_ARRAY.
Definition: mem_root_array.h:432
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:255
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:247
bool m_has_null_flags
Definition: basic_row_iterators.h:249
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:310
ha_rows *const m_examined_rows
Definition: basic_row_iterators.h:246
int DoRead() override
Definition: sorting_iterator.cc:363
bool m_ignore_not_found_rows
Definition: basic_row_iterators.h:248
void UnlockRow() override
Definition: basic_row_iterators.h:237
Mem_root_array< TABLE * > m_tables
Definition: basic_row_iterators.h:244
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:233
uint m_sum_ref_length
Definition: basic_row_iterators.h:245
Sort_result *const m_sort_result
Definition: basic_row_iterators.h:243
uchar * m_cache_pos
Definition: basic_row_iterators.h:247
bool DoInit() override
Definition: sorting_iterator.cc:330
~SortBufferIndirectIterator() override
Definition: sorting_iterator.cc:320
Fetch the records from a memory buffer.
Definition: basic_row_iterators.h:182
int DoRead() override
Read a result set record from a buffer after sorting.
Definition: sorting_iterator.cc:296
void UnlockRow() override
Definition: basic_row_iterators.h:191
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: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:192
bool DoInit() override
Definition: sorting_iterator.cc:272
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:256
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:296
IO_CACHE * m_io_cache
Definition: basic_row_iterators.h:318
~SortFileIndirectIterator() override
Definition: sorting_iterator.cc:97
Mem_root_array< TABLE * > m_tables
Definition: basic_row_iterators.h:320
bool DoInit() override
Definition: sorting_iterator.cc:106
ha_rows *const m_examined_rows
Definition: basic_row_iterators.h:319
bool m_has_null_flags
Definition: basic_row_iterators.h:323
int DoRead() override
Definition: sorting_iterator.cc:157
bool m_ignore_not_found_rows
Definition: basic_row_iterators.h:322
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:87
void UnlockRow() override
Definition: basic_row_iterators.h:312
uint m_sum_ref_length
Definition: basic_row_iterators.h:325
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:321
Fetch the records from a tempoary file.
Definition: basic_row_iterators.h:261
const uint m_buf_length
Definition: basic_row_iterators.h:280
void UnlockRow() override
Definition: basic_row_iterators.h:269
ha_rows *const m_examined_rows
Definition: basic_row_iterators.h:284
uchar *const m_rec_buf
Definition: basic_row_iterators.h:279
IO_CACHE *const m_io_cache
Definition: basic_row_iterators.h:282
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:270
Filesort_info *const m_sort
Definition: basic_row_iterators.h:283
SortFileIterator(THD *thd, Mem_root_array< TABLE * > tables, IO_CACHE *tempfile, Filesort_info *sort, ha_rows *examined_rows)
Definition: sorting_iterator.cc:196
int DoRead() override
Read a result set record from a temporary file after sorting.
Definition: sorting_iterator.cc:229
Mem_root_array< TABLE * > m_tables
Definition: basic_row_iterators.h:281
~SortFileIterator() override
Definition: sorting_iterator.cc:208
bool DoInit() override
Definition: basic_row_iterators.h:276
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:267
TABLE * table() const
Definition: row_iterator.h:279
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
int DoRead() override
Definition: basic_row_iterators.cc:276
bool DoInit() override
Definition: basic_row_iterators.cc:252
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
TableScanIterator(THD *thd, TABLE *table, double expected_rows, ha_rows *examined_rows)
Definition: basic_row_iterators.cc:236
~TableScanIterator() override
Definition: basic_row_iterators.cc:246
TableValueConstructor is the iterator for the table value constructor case of a query_primary (i....
Definition: basic_row_iterators.h:536
Mem_root_array< Item_values_column * > * m_output_refs
References to the row we currently want to output.
Definition: basic_row_iterators.h:563
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:556
mem_root_deque< mem_root_deque< Item * > * >::const_iterator m_row_it
Definition: basic_row_iterators.h:557
int DoRead() override
Definition: ref_row_iterators.cc:922
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:543
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:551
void UnlockRow() override
Definition: basic_row_iterators.h:545
bool DoInit() override
Definition: ref_row_iterators.cc:917
An iterator for unqualified COUNT(*) (ie., no WHERE, no join conditions, etc.), taking a special fast...
Definition: basic_row_iterators.h:374
bool DoInit() override
Definition: basic_row_iterators.h:384
int DoRead() override
Definition: ref_row_iterators.cc:848
void UnlockRow() override
Definition: basic_row_iterators.h:381
UnqualifiedCountIterator(THD *thd, JOIN *join)
Definition: basic_row_iterators.h:376
bool m_has_row
Definition: basic_row_iterators.h:391
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:379
JOIN *const m_join
Definition: basic_row_iterators.h:392
Like ZeroRowsIterator, but produces a single output row, since there are aggregation functions presen...
Definition: basic_row_iterators.h:429
int DoRead() override
Definition: ref_row_iterators.cc:877
JOIN *const m_join
Definition: basic_row_iterators.h:448
bool m_has_row
Definition: basic_row_iterators.h:447
ha_rows *const m_examined_rows
Definition: basic_row_iterators.h:449
ZeroRowsAggregatedIterator(THD *thd, JOIN *join, ha_rows *examined_rows)
Definition: basic_row_iterators.h:432
void UnlockRow() override
Definition: basic_row_iterators.h:437
bool DoInit() override
Definition: basic_row_iterators.h:440
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:435
A simple iterator that takes no input and produces zero output rows.
Definition: basic_row_iterators.h:405
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:342
bool DoInit() override
Definition: basic_row_iterators.h:414
void UnlockRow() override
Definition: basic_row_iterators.h:411
ZeroRowsIterator(THD *thd, Mem_root_array< TABLE * > pruned_tables)
Definition: basic_row_iterators.cc:338
const Mem_root_array< TABLE * > m_pruned_tables
Definition: basic_row_iterators.h:418
int DoRead() override
Definition: basic_row_iterators.h:416
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:1217
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(const detail::range auto &rng, std::string_view delim)
join elements of a range into a string separated by a delimiter.
Definition: string.h:74
Definition: my_sys.h:339
Definition: table.h:1435