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