1#ifndef SQL_ITERATORS_COMPOSITE_ITERATORS_H_
2#define SQL_ITERATORS_COMPOSITE_ITERATORS_H_
89 m_source->SetNullRowFlag(is_null_row);
94 m_source->EndPSIBatchModeIfStarted();
128 bool reject_multiple_rows,
ha_rows *skipped_rows)
136 if (count_all_rows) {
142 m_source->SetNullRowFlag(is_null_row);
147 m_source->EndPSIBatchModeIfStarted();
211 std::span<AccessPath *> single_row_index_lookups,
215 m_source->SetNullRowFlag(is_null_row);
220 m_source->EndPSIBatchModeIfStarted();
348 assert(!pfs_batch_mode);
403 const std::string &
name)
585 bool provide_rowid,
JOIN *
join,
int ref_slice);
674 m_source->SetNullRowFlag(is_null_row);
678 m_source->EndPSIBatchModeIfStarted();
704 JOIN *
join, std::span<Item *> group_items);
707 m_source->SetNullRowFlag(is_null_row);
712 m_source->EndPSIBatchModeIfStarted();
737 m_source->SetNullRowFlag(is_null_row);
742 m_source->EndPSIBatchModeIfStarted();
795 KEY *
key,
size_t key_len);
Handles aggregation (typically used for GROUP BY) for the case where the rows are already properly gr...
Definition: composite_iterators.h:207
void UnlockRow() override
Definition: composite_iterators.h:222
int m_current_rollup_position
If we are in state OUTPUTTING_ROLLUP_ROWS, where we are in the iteration.
Definition: composite_iterators.h:281
void StartPSIBatchMode() override
Start performance schema batch mode, if supported (otherwise ignored).
Definition: composite_iterators.h:218
JOIN * m_join
The join we are part of.
Definition: composite_iterators.h:248
bool m_seen_eof
Whether we have seen the last input row.
Definition: composite_iterators.h:251
int DoRead() override
Definition: composite_iterators.cc:261
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:197
bool DoInit() override
Definition: composite_iterators.cc:217
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:287
@ LAST_ROW_STARTED_NEW_GROUP
Definition: composite_iterators.h:235
@ READING_FIRST_ROW
Definition: composite_iterators.h:234
@ OUTPUTTING_ROLLUP_ROWS
Definition: composite_iterators.h:236
@ DONE_OUTPUTTING_ROWS
Definition: composite_iterators.h:237
String m_first_row_this_group
Packed version of the first row in the group we are currently processing.
Definition: composite_iterators.h:290
String m_first_row_next_group
If applicable, packed version of the first row in the next group.
Definition: composite_iterators.h:303
table_map m_save_nullinfo
Used to save NULL information in the specific case where we have zero input rows.
Definition: composite_iterators.h:257
enum AggregateIterator::@65 m_state
unique_ptr_destroy_only< RowIterator > m_source
Definition: composite_iterators.h:240
int m_output_slice
The slice we're setting when returning rows.
Definition: composite_iterators.h:312
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:219
const bool m_rollup
Whether this is a rollup query.
Definition: composite_iterators.h:260
std::span< AccessPath * > m_single_row_index_lookups
All the single-row index lookups that provide rows to this iterator.
Definition: composite_iterators.h:306
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:214
void SetRollupLevel(int level)
Definition: composite_iterators.cc:477
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:272
Takes in two or more iterators and output rows from them sequentially (first all rows from the first ...
Definition: composite_iterators.h:864
size_t m_current_iterator_index
Definition: composite_iterators.h:881
AppendIterator(THD *thd, std::vector< unique_ptr_destroy_only< RowIterator > > &&sub_iterators)
Definition: composite_iterators.cc:4500
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:4537
int DoRead() override
Definition: composite_iterators.cc:4512
bool DoInit() override
Definition: composite_iterators.cc:4506
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.cc:4547
void UnlockRow() override
Definition: composite_iterators.cc:4555
std::vector< unique_ptr_destroy_only< RowIterator > > m_sub_iterators
Definition: composite_iterators.h:880
bool m_pfs_batch_mode_enabled
Definition: composite_iterators.h:882
void StartPSIBatchMode() override
Start performance schema batch mode, if supported (otherwise ignored).
Definition: composite_iterators.cc:4542
A wrapper class which provides array bounds checking.
Definition: sql_array.h:48
An iterator that helps invalidating caches.
Definition: composite_iterators.h:399
CacheInvalidatorIterator(THD *thd, unique_ptr_destroy_only< RowIterator > source_iterator, const std::string &name)
Definition: composite_iterators.h:401
int DoRead() override
Definition: composite_iterators.h:414
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
bool DoInit() override
Definition: composite_iterators.h:409
int64_t m_generation
Definition: composite_iterators.h:432
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:6572
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:93
void UnlockRow() override
Definition: composite_iterators.h:96
int DoRead() override
Definition: composite_iterators.cc:96
unique_ptr_destroy_only< RowIterator > m_source
Definition: composite_iterators.h:102
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:92
Item * m_condition
Definition: composite_iterators.h:103
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:88
bool DoInit() override
Definition: composite_iterators.h:99
FollowTailIterator is a special version of TableScanIterator that is used as part of WITH RECURSIVE q...
Definition: basic_row_iterators.h:476
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:928
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:110
void UnlockRow() override
Definition: composite_iterators.h:149
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:126
ha_rows m_seen_rows
Definition: composite_iterators.h:160
const bool m_count_all_rows
Definition: composite_iterators.h:168
ha_rows * m_skipped_rows
Definition: composite_iterators.h:170
int DoRead() override
Definition: composite_iterators.cc:135
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:146
const ha_rows m_limit
Definition: composite_iterators.h:167
const ha_rows m_offset
Definition: composite_iterators.h:167
bool m_needs_offset
Whether we have OFFSET rows that we still need to skip.
Definition: composite_iterators.h:165
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:141
unique_ptr_destroy_only< RowIterator > m_source
Definition: composite_iterators.h:155
const bool m_reject_multiple_rows
Definition: composite_iterators.h:169
bool DoInit() override
Definition: composite_iterators.cc:121
void StartPSIBatchMode() override
Start performance schema batch mode, if supported (otherwise ignored).
Definition: composite_iterators.h:145
An iterator that wraps a Table_function (e.g.
Definition: composite_iterators.h:621
Table_function * m_table_function
Definition: composite_iterators.h:646
unique_ptr_destroy_only< RowIterator > m_table_iterator
Definition: composite_iterators.h:644
int DoRead() override
Definition: composite_iterators.h:642
bool DoInit() override
Definition: composite_iterators.cc:4236
void StartPSIBatchMode() override
Start performance schema batch mode, if supported (otherwise ignored).
Definition: composite_iterators.h:631
void UnlockRow() override
Definition: composite_iterators.h:638
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:627
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:632
MaterializedTableFunctionIterator(THD *thd, Table_function *table_function, TABLE *table, unique_ptr_destroy_only< RowIterator > table_iterator)
Definition: composite_iterators.cc:4229
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:331
int DoRead() override
Definition: composite_iterators.cc:500
void UnlockRow() override
Definition: composite_iterators.h:363
@ END_OF_ROWS
Definition: composite_iterators.h:380
@ READING_INNER_ROWS
Definition: composite_iterators.h:379
@ NEEDS_OUTER_ROW
Definition: composite_iterators.h:377
@ READING_FIRST_INNER_ROW
Definition: composite_iterators.h:378
const bool m_pfs_batch_mode
Whether to use batch mode when scanning the inner iterator.
Definition: composite_iterators.h:388
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:333
unique_ptr_destroy_only< RowIterator > const m_source_inner
Definition: composite_iterators.h:384
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:358
const JoinType m_join_type
Definition: composite_iterators.h:385
bool DoInit() override
Definition: composite_iterators.cc:489
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:352
unique_ptr_destroy_only< RowIterator > const m_source_outer
Definition: composite_iterators.h:383
enum NestedLoopIterator::@66 m_state
An iterator that is semantically equivalent to a semijoin NestedLoopIterator immediately followed by ...
Definition: composite_iterators.h:790
void UnlockRow() override
Definition: composite_iterators.h:807
int DoRead() override
Definition: composite_iterators.cc:4418
KEY * m_key
Definition: composite_iterators.h:820
unique_ptr_destroy_only< RowIterator > const m_source_outer
Definition: composite_iterators.h:816
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:797
const size_t m_key_len
Definition: composite_iterators.h:822
bool m_deduplicate_against_previous_row
Definition: composite_iterators.h:823
bool DoInit() override
Definition: composite_iterators.cc:4410
uchar * m_key_buf
Definition: composite_iterators.h:821
unique_ptr_destroy_only< RowIterator > const m_source_inner
Definition: composite_iterators.h:817
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:4395
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:802
const TABLE * m_table_outer
Definition: composite_iterators.h:819
An iterator that removes consecutive rows that are the same according to a set of items (typically th...
Definition: composite_iterators.h:700
void StartPSIBatchMode() override
Start performance schema batch mode, if supported (otherwise ignored).
Definition: composite_iterators.h:710
RemoveDuplicatesIterator(THD *thd, unique_ptr_destroy_only< RowIterator > source, JOIN *join, std::span< Item * > group_items)
Definition: composite_iterators.cc:4310
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:711
void UnlockRow() override
Definition: composite_iterators.h:714
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:706
bool m_first_row
Definition: composite_iterators.h:721
bool DoInit() override
Definition: composite_iterators.cc:4322
Bounds_checked_array< Cached_item * > m_caches
Definition: composite_iterators.h:720
int DoRead() override
Definition: composite_iterators.cc:4327
unique_ptr_destroy_only< RowIterator > m_source
Definition: composite_iterators.h:719
Much like RemoveDuplicatesIterator, but works on the basis of a given index (or more accurately,...
Definition: composite_iterators.h:730
int DoRead() override
Definition: composite_iterators.cc:4369
void UnlockRow() override
Definition: composite_iterators.h:744
uchar * m_key_buf
Definition: composite_iterators.h:753
bool m_first_row
Definition: composite_iterators.h:755
const TABLE * m_table
Definition: composite_iterators.h:751
void StartPSIBatchMode() override
Start performance schema batch mode, if supported (otherwise ignored).
Definition: composite_iterators.h:740
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:736
const size_t m_key_len
Definition: composite_iterators.h:754
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:741
RemoveDuplicatesOnIndexIterator(THD *thd, unique_ptr_destroy_only< RowIterator > source, const TABLE *table, KEY *key, size_t key_len)
Definition: composite_iterators.cc:4354
KEY * m_key
Definition: composite_iterators.h:752
unique_ptr_destroy_only< RowIterator > m_source
Definition: composite_iterators.h:750
bool DoInit() override
Definition: composite_iterators.cc:4364
A context for reading through a single table using a chosen access method: index read,...
Definition: row_iterator.h:82
THD * thd() const
Definition: row_iterator.h:255
Definition: sql_executor.h:95
StreamingIterator is a minimal version of MaterializeIterator that does not actually materialize; ins...
Definition: composite_iterators.h:568
bool DoInit() override
Definition: composite_iterators.cc:3795
JOIN *const m_join
Definition: composite_iterators.h:601
void UnlockRow() override
Definition: composite_iterators.h:593
int DoRead() override
Definition: composite_iterators.cc:3818
void StartPSIBatchMode() override
Start performance schema batch mode, if supported (otherwise ignored).
Definition: composite_iterators.h:587
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:3766
Temp_table_param * m_temp_table_param
Definition: composite_iterators.h:599
const bool m_provide_rowid
Definition: composite_iterators.h:608
const int m_output_slice
Definition: composite_iterators.h:602
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:590
int m_input_slice
Definition: composite_iterators.h:603
unique_ptr_destroy_only< RowIterator > m_subquery_iterator
Definition: composite_iterators.h:598
ha_rows m_row_number
Definition: composite_iterators.h:600
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:169
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
Definition: row_iterator.h:267
TABLE * table() const
Definition: row_iterator.h:279
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:668
bool DoInit() override
Definition: composite_iterators.cc:4262
unique_ptr_destroy_only< RowIterator > m_source
Definition: composite_iterators.h:685
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:677
WeedoutIterator(THD *thd, unique_ptr_destroy_only< RowIterator > source, SJ_TMP_TABLE *sj, table_map tables_to_get_rowid_for)
Definition: composite_iterators.cc:4249
const table_map m_tables_to_get_rowid_for
Definition: composite_iterators.h:687
int DoRead() override
Definition: composite_iterators.cc:4279
SJ_TMP_TABLE * m_sj
Definition: composite_iterators.h:686
void UnlockRow() override
Definition: composite_iterators.h:680
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:673
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:1217
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:56
unsigned char uchar
Definition: my_inttypes.h:52
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:3743
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:4201
std::vector< T, ut::allocator< T > > vector
Specialization of vector which uses allocator.
Definition: ut0new.h:2880
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