1#ifndef SQL_ITERATORS_COMPOSITE_ITERATORS_H_
2#define SQL_ITERATORS_COMPOSITE_ITERATORS_H_
93 m_source->SetNullRowFlag(is_null_row);
98 m_source->EndPSIBatchModeIfStarted();
129 bool reject_multiple_rows,
ha_rows *skipped_rows)
137 if (count_all_rows) {
142 bool Init()
override;
147 m_source->SetNullRowFlag(is_null_row);
152 m_source->EndPSIBatchModeIfStarted();
213 std::span<AccessPath *> single_row_index_lookups,
216 bool Init()
override;
219 m_source->SetNullRowFlag(is_null_row);
224 m_source->EndPSIBatchModeIfStarted();
349 assert(!pfs_batch_mode);
353 bool Init()
override;
405 const std::string &
name)
585 bool provide_rowid,
JOIN *
join,
int ref_slice);
587 bool Init()
override;
629 bool Init()
override;
674 bool Init()
override;
678 m_source->SetNullRowFlag(is_null_row);
682 m_source->EndPSIBatchModeIfStarted();
707 int group_items_size);
709 bool Init()
override;
713 m_source->SetNullRowFlag(is_null_row);
718 m_source->EndPSIBatchModeIfStarted();
740 bool Init()
override;
744 m_source->SetNullRowFlag(is_null_row);
749 m_source->EndPSIBatchModeIfStarted();
799 KEY *
key,
size_t key_len);
801 bool Init()
override;
841 bool Init()
override;
875 bool Init()
override;
Handles aggregation (typically used for GROUP BY) for the case where the rows are already properly gr...
Definition: composite_iterators.h:209
void UnlockRow() override
Definition: composite_iterators.h:226
int m_current_rollup_position
If we are in state OUTPUTTING_ROLLUP_ROWS, where we are in the iteration.
Definition: composite_iterators.h:282
void StartPSIBatchMode() override
Start performance schema batch mode, if supported (otherwise ignored).
Definition: composite_iterators.h:222
int Read() override
Read a single row.
Definition: composite_iterators.cc:260
JOIN * m_join
The join we are part of.
Definition: composite_iterators.h:249
bool m_seen_eof
Whether we have seen the last input row.
Definition: composite_iterators.h:252
AggregateIterator(THD *thd, unique_ptr_destroy_only< RowIterator > source, JOIN *join, pack_rows::TableCollection tables, std::span< AccessPath * > single_row_index_lookups, bool rollup)
Definition: composite_iterators.cc:196
pack_rows::TableCollection m_tables
The list of tables we are reading from; they are the ones for which we need to save and restore rows.
Definition: composite_iterators.h:288
String m_first_row_this_group
Packed version of the first row in the group we are currently processing.
Definition: composite_iterators.h:291
String m_first_row_next_group
If applicable, packed version of the first row in the next group.
Definition: composite_iterators.h:304
table_map m_save_nullinfo
Used to save NULL information in the specific case where we have zero input rows.
Definition: composite_iterators.h:258
@ LAST_ROW_STARTED_NEW_GROUP
Definition: composite_iterators.h:236
@ READING_FIRST_ROW
Definition: composite_iterators.h:235
@ OUTPUTTING_ROLLUP_ROWS
Definition: composite_iterators.h:237
@ DONE_OUTPUTTING_ROWS
Definition: composite_iterators.h:238
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.cc:216
unique_ptr_destroy_only< RowIterator > m_source
Definition: composite_iterators.h:241
int m_output_slice
The slice we're setting when returning rows.
Definition: composite_iterators.h:313
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:223
const bool m_rollup
Whether this is a rollup query.
Definition: composite_iterators.h:261
std::span< AccessPath * > m_single_row_index_lookups
All the single-row index lookups that provide rows to this iterator.
Definition: composite_iterators.h:307
enum AggregateIterator::@62 m_state
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: composite_iterators.h:218
void SetRollupLevel(int level)
Definition: composite_iterators.cc:482
int m_last_unchanged_group_item_idx
For rollup: The index of the first group item that did not change when we last switched groups.
Definition: composite_iterators.h:273
Takes in two or more iterators and output rows from them sequentially (first all rows from the first ...
Definition: composite_iterators.h:869
size_t m_current_iterator_index
Definition: composite_iterators.h:886
AppendIterator(THD *thd, std::vector< unique_ptr_destroy_only< RowIterator > > &&sub_iterators)
Definition: composite_iterators.cc:4463
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: composite_iterators.cc:4500
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.cc:4469
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.cc:4510
void UnlockRow() override
Definition: composite_iterators.cc:4518
std::vector< unique_ptr_destroy_only< RowIterator > > m_sub_iterators
Definition: composite_iterators.h:885
int Read() override
Read a single row.
Definition: composite_iterators.cc:4475
bool m_pfs_batch_mode_enabled
Definition: composite_iterators.h:887
void StartPSIBatchMode() override
Start performance schema batch mode, if supported (otherwise ignored).
Definition: composite_iterators.cc:4505
A wrapper class which provides array bounds checking.
Definition: sql_array.h:47
An iterator that helps invalidating caches.
Definition: composite_iterators.h:401
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.h:410
CacheInvalidatorIterator(THD *thd, unique_ptr_destroy_only< RowIterator > source_iterator, const std::string &name)
Definition: composite_iterators.h:403
std::string m_name
Definition: composite_iterators.h:433
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: composite_iterators.h:420
unique_ptr_destroy_only< RowIterator > m_source_iterator
Definition: composite_iterators.h:431
void UnlockRow() override
Definition: composite_iterators.h:425
int64_t m_generation
Definition: composite_iterators.h:432
int Read() override
Read a single row.
Definition: composite_iterators.h:415
std::string name() const
Definition: composite_iterators.h:428
int64_t generation() const
Definition: composite_iterators.h:427
This is used for segregating rows in groups (e.g.
Definition: item.h:6485
An iterator that takes in a stream of rows and passes through only those that meet some criteria (i....
Definition: composite_iterators.h:82
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:97
int Read() override
Read a single row.
Definition: composite_iterators.cc:95
void UnlockRow() override
Definition: composite_iterators.h:100
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.h:88
unique_ptr_destroy_only< RowIterator > m_source
Definition: composite_iterators.h:103
FilterIterator(THD *thd, unique_ptr_destroy_only< RowIterator > source, Item *condition)
Definition: composite_iterators.h:84
void StartPSIBatchMode() override
Start performance schema batch mode, if supported (otherwise ignored).
Definition: composite_iterators.h:96
Item * m_condition
Definition: composite_iterators.h:104
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: composite_iterators.h:92
FollowTailIterator is a special version of TableScanIterator that is used as part of WITH RECURSIVE q...
Definition: basic_row_iterators.h:470
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:930
Definition: sql_optimizer.h:133
Handles LIMIT and/or OFFSET; Init() eats the first "offset" rows, and Read() stops as soon as it's se...
Definition: composite_iterators.h:111
void UnlockRow() override
Definition: composite_iterators.h:154
LimitOffsetIterator(THD *thd, unique_ptr_destroy_only< RowIterator > source, ha_rows limit, ha_rows offset, bool count_all_rows, bool reject_multiple_rows, ha_rows *skipped_rows)
Definition: composite_iterators.h:127
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.cc:120
ha_rows m_seen_rows
Definition: composite_iterators.h:162
const bool m_count_all_rows
Definition: composite_iterators.h:170
ha_rows * m_skipped_rows
Definition: composite_iterators.h:172
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:151
const ha_rows m_limit
Definition: composite_iterators.h:169
const ha_rows m_offset
Definition: composite_iterators.h:169
bool m_needs_offset
Whether we have OFFSET rows that we still need to skip.
Definition: composite_iterators.h:167
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: composite_iterators.h:146
unique_ptr_destroy_only< RowIterator > m_source
Definition: composite_iterators.h:157
int Read() override
Read a single row.
Definition: composite_iterators.cc:134
const bool m_reject_multiple_rows
Definition: composite_iterators.h:171
void StartPSIBatchMode() override
Start performance schema batch mode, if supported (otherwise ignored).
Definition: composite_iterators.h:150
An iterator that wraps a Table_function (e.g.
Definition: composite_iterators.h:623
Table_function * m_table_function
Definition: composite_iterators.h:647
unique_ptr_destroy_only< RowIterator > m_table_iterator
Definition: composite_iterators.h:645
void StartPSIBatchMode() override
Start performance schema batch mode, if supported (otherwise ignored).
Definition: composite_iterators.h:635
void UnlockRow() override
Definition: composite_iterators.h:642
int Read() override
Read a single row.
Definition: composite_iterators.h:630
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: composite_iterators.h:631
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:636
MaterializedTableFunctionIterator(THD *thd, Table_function *table_function, TABLE *table, unique_ptr_destroy_only< RowIterator > table_iterator)
Definition: composite_iterators.cc:4195
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.cc:4202
A typesafe replacement for DYNAMIC_ARRAY.
Definition: mem_root_array.h:432
A simple nested loop join, taking in two iterators (left/outer and right/inner) and joining them toge...
Definition: composite_iterators.h:332
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.cc:494
@ END_OF_ROWS
Definition: composite_iterators.h:382
@ READING_INNER_ROWS
Definition: composite_iterators.h:381
@ NEEDS_OUTER_ROW
Definition: composite_iterators.h:379
@ READING_FIRST_INNER_ROW
Definition: composite_iterators.h:380
int Read() override
Read a single row.
Definition: composite_iterators.cc:505
void UnlockRow() override
Definition: composite_iterators.h:368
const bool m_pfs_batch_mode
Whether to use batch mode when scanning the inner iterator.
Definition: composite_iterators.h:390
NestedLoopIterator(THD *thd, unique_ptr_destroy_only< RowIterator > source_outer, unique_ptr_destroy_only< RowIterator > source_inner, JoinType join_type, bool pfs_batch_mode)
Definition: composite_iterators.h:334
unique_ptr_destroy_only< RowIterator > const m_source_inner
Definition: composite_iterators.h:386
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:363
const JoinType m_join_type
Definition: composite_iterators.h:387
enum NestedLoopIterator::@63 m_state
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: composite_iterators.h:357
unique_ptr_destroy_only< RowIterator > const m_source_outer
Definition: composite_iterators.h:385
An iterator that is semantically equivalent to a semijoin NestedLoopIterator immediately followed by ...
Definition: composite_iterators.h:794
int Read() override
Read a single row.
Definition: composite_iterators.cc:4382
void UnlockRow() override
Definition: composite_iterators.h:815
KEY * m_key
Definition: composite_iterators.h:825
unique_ptr_destroy_only< RowIterator > const m_source_outer
Definition: composite_iterators.h:821
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: composite_iterators.h:805
const size_t m_key_len
Definition: composite_iterators.h:827
bool m_deduplicate_against_previous_row
Definition: composite_iterators.h:828
uchar * m_key_buf
Definition: composite_iterators.h:826
unique_ptr_destroy_only< RowIterator > const m_source_inner
Definition: composite_iterators.h:822
NestedLoopSemiJoinWithDuplicateRemovalIterator(THD *thd, unique_ptr_destroy_only< RowIterator > source_outer, unique_ptr_destroy_only< RowIterator > source_inner, const TABLE *table, KEY *key, size_t key_len)
Definition: composite_iterators.cc:4359
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:810
const TABLE * m_table_outer
Definition: composite_iterators.h:824
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.cc:4374
An iterator that removes consecutive rows that are the same according to a set of items (typically th...
Definition: composite_iterators.h:702
void StartPSIBatchMode() override
Start performance schema batch mode, if supported (otherwise ignored).
Definition: composite_iterators.h:716
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:717
void UnlockRow() override
Definition: composite_iterators.h:720
int Read() override
Read a single row.
Definition: composite_iterators.cc:4293
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: composite_iterators.h:712
bool m_first_row
Definition: composite_iterators.h:725
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.cc:4288
Bounds_checked_array< Cached_item * > m_caches
Definition: composite_iterators.h:724
RemoveDuplicatesIterator(THD *thd, unique_ptr_destroy_only< RowIterator > source, JOIN *join, Item **group_items, int group_items_size)
Definition: composite_iterators.cc:4276
unique_ptr_destroy_only< RowIterator > m_source
Definition: composite_iterators.h:723
Much like RemoveDuplicatesIterator, but works on the basis of a given index (or more accurately,...
Definition: composite_iterators.h:734
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.cc:4330
void UnlockRow() override
Definition: composite_iterators.h:751
uchar * m_key_buf
Definition: composite_iterators.h:757
bool m_first_row
Definition: composite_iterators.h:759
const TABLE * m_table
Definition: composite_iterators.h:755
void StartPSIBatchMode() override
Start performance schema batch mode, if supported (otherwise ignored).
Definition: composite_iterators.h:747
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: composite_iterators.h:743
const size_t m_key_len
Definition: composite_iterators.h:758
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:748
RemoveDuplicatesOnIndexIterator(THD *thd, unique_ptr_destroy_only< RowIterator > source, const TABLE *table, KEY *key, size_t key_len)
Definition: composite_iterators.cc:4320
KEY * m_key
Definition: composite_iterators.h:756
int Read() override
Read a single row.
Definition: composite_iterators.cc:4335
unique_ptr_destroy_only< RowIterator > m_source
Definition: composite_iterators.h:754
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
Definition: sql_executor.h:95
StreamingIterator is a minimal version of MaterializeIterator that does not actually materialize; ins...
Definition: composite_iterators.h:568
JOIN *const m_join
Definition: composite_iterators.h:603
void UnlockRow() override
Definition: composite_iterators.h:597
void StartPSIBatchMode() override
Start performance schema batch mode, if supported (otherwise ignored).
Definition: composite_iterators.h:591
int Read() override
Read a single row.
Definition: composite_iterators.cc:3787
StreamingIterator(THD *thd, unique_ptr_destroy_only< RowIterator > subquery_iterator, Temp_table_param *temp_table_param, TABLE *table, bool provide_rowid, JOIN *join, int ref_slice)
Definition: composite_iterators.cc:3735
Temp_table_param * m_temp_table_param
Definition: composite_iterators.h:601
const bool m_provide_rowid
Definition: composite_iterators.h:610
const int m_output_slice
Definition: composite_iterators.h:604
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:594
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.cc:3764
int m_input_slice
Definition: composite_iterators.h:605
unique_ptr_destroy_only< RowIterator > m_subquery_iterator
Definition: composite_iterators.h:600
ha_rows m_row_number
Definition: composite_iterators.h:602
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:167
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
Class representing a table function.
Definition: table_function.h:53
Object containing parameters used when creating and using temporary tables.
Definition: temp_table_param.h:97
Like semijoin materialization, weedout works on the basic idea that a semijoin is just like an inner ...
Definition: composite_iterators.h:669
unique_ptr_destroy_only< RowIterator > m_source
Definition: composite_iterators.h:687
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:681
WeedoutIterator(THD *thd, unique_ptr_destroy_only< RowIterator > source, SJ_TMP_TABLE *sj, table_map tables_to_get_rowid_for)
Definition: composite_iterators.cc:4215
int Read() override
Read a single row.
Definition: composite_iterators.cc:4245
const table_map m_tables_to_get_rowid_for
Definition: composite_iterators.h:689
SJ_TMP_TABLE * m_sj
Definition: composite_iterators.h:688
void UnlockRow() override
Definition: composite_iterators.h:684
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: composite_iterators.h:677
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.cc:4228
A structure that contains a list of input tables for a hash join operation, BKA join operation or a s...
Definition: pack_rows.h:84
JoinType
Definition: join_type.h:28
@ ANTI
Left antijoin, i.e.
@ SEMI
Left semijoin, i.e.
This file follows Google coding style, except for the name MEM_ROOT (which is kept for historical rea...
std::unique_ptr< T, Destroy_only< T > > unique_ptr_destroy_only
std::unique_ptr, but only destroying.
Definition: my_alloc.h:480
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
uint64_t table_map
Definition: my_table_map.h:30
static PFS_engine_table_share_proxy table
Definition: pfs.cc:61
Definition: composite_iterators.h:436
RowIterator * CreateIterator(THD *thd, Mem_root_array< materialize_iterator::Operand > operands, const MaterializePathParameters *path_params, unique_ptr_destroy_only< RowIterator > table_iterator, JOIN *join)
Create an iterator that materializes a set of row into a temporary table and sets up a (pre-existing)...
Definition: composite_iterators.cc:3712
std::string join(const detail::range auto &rng, std::string_view delim)
join elements of a range into a string separated by a delimiter.
Definition: string.h:74
Definition: gcs_xcom_synode.h:64
Definition: composite_iterators.h:530
RowIterator * CreateIterator(THD *thd, unique_ptr_destroy_only< RowIterator > subquery_iterator, Temp_table_param *temp_table_param, TABLE *table, unique_ptr_destroy_only< RowIterator > table_iterator, JOIN *join, int ref_slice)
Create an iterator that aggregates the output rows from another iterator into a temporary table and t...
Definition: composite_iterators.cc:4167
std::vector< T, ut::allocator< T > > vector
Specialization of vector which uses allocator.
Definition: ut0new.h:2876
Generic routines for packing rows (possibly from multiple tables at the same time) into strings,...
required string key
Definition: replication_asynchronous_connection_failover.proto:60
repeated Source source
Definition: replication_asynchronous_connection_failover.proto:42
join_type
Definition: sql_opt_exec_shared.h:186
Our own string classes, used pervasively throughout the executor.
Definition: materialize_path_parameters.h:40
An operand (query block) to be materialized by MaterializeIterator.
Definition: composite_iterators.h:441
unique_ptr_destroy_only< RowIterator > subquery_iterator
The iterator to read the actual rows from.
Definition: composite_iterators.h:443
bool copy_items
If set to false, the Field objects in the output row are presumed already to be filled out.
Definition: composite_iterators.h:471
Temp_table_param * temp_table_param
If copy_items is true, used for copying the Field objects into the temporary table row.
Definition: composite_iterators.h:487
double m_estimated_output_rows
The estimated number of rows produced by this block.
Definition: composite_iterators.h:501
ulonglong m_operand_idx
The current operand (i.e.
Definition: composite_iterators.h:478
bool is_recursive_reference
Definition: composite_iterators.h:491
FollowTailIterator * recursive_reader
Definition: composite_iterators.h:498
int select_number
Used only for optimizer trace.
Definition: composite_iterators.h:446
ulonglong m_total_operands
The number of operands (i.e.
Definition: composite_iterators.h:475
uint m_first_distinct
Used for EXCEPT computation: the index of the first operand involved in a N-ary except operation whic...
Definition: composite_iterators.h:483
bool disable_deduplication_by_hash_field
If true, de-duplication checking via hash key is disabled when materializing this query block (ie....
Definition: composite_iterators.h:466
JOIN * join
The JOIN that this query block represents.
Definition: composite_iterators.h:453