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