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