1#ifndef SQL_ITERATORS_COMPOSITE_ITERATORS_H_
2#define SQL_ITERATORS_COMPOSITE_ITERATORS_H_
91 m_source->SetNullRowFlag(is_null_row);
96 m_source->EndPSIBatchModeIfStarted();
127 bool reject_multiple_rows,
ha_rows *skipped_rows)
135 if (count_all_rows) {
140 bool Init()
override;
145 m_source->SetNullRowFlag(is_null_row);
150 m_source->EndPSIBatchModeIfStarted();
212 bool Init()
override;
215 m_source->SetNullRowFlag(is_null_row);
220 m_source->EndPSIBatchModeIfStarted();
342 assert(!pfs_batch_mode);
346 bool Init()
override;
398 const std::string &
name)
578 bool provide_rowid,
JOIN *
join,
int ref_slice);
580 bool Init()
override;
622 bool Init()
override;
667 bool Init()
override;
671 m_source->SetNullRowFlag(is_null_row);
675 m_source->EndPSIBatchModeIfStarted();
700 int group_items_size);
702 bool Init()
override;
706 m_source->SetNullRowFlag(is_null_row);
711 m_source->EndPSIBatchModeIfStarted();
733 bool Init()
override;
737 m_source->SetNullRowFlag(is_null_row);
742 m_source->EndPSIBatchModeIfStarted();
792 KEY *
key,
size_t key_len);
794 bool Init()
override;
834 bool Init()
override;
868 bool Init()
override;
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:278
void StartPSIBatchMode() override
Start performance schema batch mode, if supported (otherwise ignored).
Definition: composite_iterators.h:218
int Read() override
Read a single row.
Definition: composite_iterators.cc:258
@ LAST_ROW_STARTED_NEW_GROUP
Definition: composite_iterators.h:232
@ READING_FIRST_ROW
Definition: composite_iterators.h:231
@ OUTPUTTING_ROLLUP_ROWS
Definition: composite_iterators.h:233
@ DONE_OUTPUTTING_ROWS
Definition: composite_iterators.h:234
JOIN * m_join
The join we are part of.
Definition: composite_iterators.h:245
bool m_seen_eof
Whether we have seen the last input row.
Definition: composite_iterators.h:248
enum AggregateIterator::@61 m_state
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:284
String m_first_row_this_group
Packed version of the first row in the group we are currently processing.
Definition: composite_iterators.h:287
String m_first_row_next_group
If applicable, packed version of the first row in the next group.
Definition: composite_iterators.h:300
table_map m_save_nullinfo
Used to save NULL information in the specific case where we have zero input rows.
Definition: composite_iterators.h:254
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.cc:211
unique_ptr_destroy_only< RowIterator > m_source
Definition: composite_iterators.h:237
int m_output_slice
The slice we're setting when returning rows.
Definition: composite_iterators.h:306
AggregateIterator(THD *thd, unique_ptr_destroy_only< RowIterator > source, JOIN *join, pack_rows::TableCollection tables, bool rollup)
Definition: composite_iterators.cc:193
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:257
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:473
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:269
Takes in two or more iterators and output rows from them sequentially (first all rows from the first ...
Definition: composite_iterators.h:862
size_t m_current_iterator_index
Definition: composite_iterators.h:879
AppendIterator(THD *thd, std::vector< unique_ptr_destroy_only< RowIterator > > &&sub_iterators)
Definition: composite_iterators.cc:4450
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:4487
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.cc:4456
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.cc:4497
void UnlockRow() override
Definition: composite_iterators.cc:4505
std::vector< unique_ptr_destroy_only< RowIterator > > m_sub_iterators
Definition: composite_iterators.h:878
int Read() override
Read a single row.
Definition: composite_iterators.cc:4462
bool m_pfs_batch_mode_enabled
Definition: composite_iterators.h:880
void StartPSIBatchMode() override
Start performance schema batch mode, if supported (otherwise ignored).
Definition: composite_iterators.cc:4492
A wrapper class which provides array bounds checking.
Definition: sql_array.h:47
An iterator that helps invalidating caches.
Definition: composite_iterators.h:394
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.h:403
CacheInvalidatorIterator(THD *thd, unique_ptr_destroy_only< RowIterator > source_iterator, const std::string &name)
Definition: composite_iterators.h:396
std::string m_name
Definition: composite_iterators.h:426
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:413
unique_ptr_destroy_only< RowIterator > m_source_iterator
Definition: composite_iterators.h:424
void UnlockRow() override
Definition: composite_iterators.h:418
int64_t m_generation
Definition: composite_iterators.h:425
int Read() override
Read a single row.
Definition: composite_iterators.h:408
std::string name() const
Definition: composite_iterators.h:421
int64_t generation() const
Definition: composite_iterators.h:420
This is used for segregating rows in groups (e.g.
Definition: item.h:6484
An iterator that takes in a stream of rows and passes through only those that meet some criteria (i....
Definition: composite_iterators.h:80
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:95
int Read() override
Read a single row.
Definition: composite_iterators.cc:92
void UnlockRow() override
Definition: composite_iterators.h:98
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.h:86
unique_ptr_destroy_only< RowIterator > m_source
Definition: composite_iterators.h:101
FilterIterator(THD *thd, unique_ptr_destroy_only< RowIterator > source, Item *condition)
Definition: composite_iterators.h:82
void StartPSIBatchMode() override
Start performance schema batch mode, if supported (otherwise ignored).
Definition: composite_iterators.h:94
Item * m_condition
Definition: composite_iterators.h:102
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:90
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:109
void UnlockRow() override
Definition: composite_iterators.h:152
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:125
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.cc:117
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
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:149
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:144
unique_ptr_destroy_only< RowIterator > m_source
Definition: composite_iterators.h:155
int Read() override
Read a single row.
Definition: composite_iterators.cc:131
const bool m_reject_multiple_rows
Definition: composite_iterators.h:169
void StartPSIBatchMode() override
Start performance schema batch mode, if supported (otherwise ignored).
Definition: composite_iterators.h:148
An iterator that wraps a Table_function (e.g.
Definition: composite_iterators.h:616
Table_function * m_table_function
Definition: composite_iterators.h:640
unique_ptr_destroy_only< RowIterator > m_table_iterator
Definition: composite_iterators.h:638
void StartPSIBatchMode() override
Start performance schema batch mode, if supported (otherwise ignored).
Definition: composite_iterators.h:628
void UnlockRow() override
Definition: composite_iterators.h:635
int Read() override
Read a single row.
Definition: composite_iterators.h:623
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:624
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:629
MaterializedTableFunctionIterator(THD *thd, Table_function *table_function, TABLE *table, unique_ptr_destroy_only< RowIterator > table_iterator)
Definition: composite_iterators.cc:4182
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.cc:4189
A typesafe replacement for DYNAMIC_ARRAY.
Definition: mem_root_array.h:426
A simple nested loop join, taking in two iterators (left/outer and right/inner) and joining them toge...
Definition: composite_iterators.h:325
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.cc:485
int Read() override
Read a single row.
Definition: composite_iterators.cc:496
void UnlockRow() override
Definition: composite_iterators.h:361
const bool m_pfs_batch_mode
Whether to use batch mode when scanning the inner iterator.
Definition: composite_iterators.h:383
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:327
unique_ptr_destroy_only< RowIterator > const m_source_inner
Definition: composite_iterators.h:379
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:356
const JoinType m_join_type
Definition: composite_iterators.h:380
@ END_OF_ROWS
Definition: composite_iterators.h:375
@ READING_INNER_ROWS
Definition: composite_iterators.h:374
@ NEEDS_OUTER_ROW
Definition: composite_iterators.h:372
@ READING_FIRST_INNER_ROW
Definition: composite_iterators.h:373
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:350
enum NestedLoopIterator::@62 m_state
unique_ptr_destroy_only< RowIterator > const m_source_outer
Definition: composite_iterators.h:378
An iterator that is semantically equivalent to a semijoin NestedLoopIterator immediately followed by ...
Definition: composite_iterators.h:787
int Read() override
Read a single row.
Definition: composite_iterators.cc:4369
void UnlockRow() override
Definition: composite_iterators.h:808
KEY * m_key
Definition: composite_iterators.h:818
unique_ptr_destroy_only< RowIterator > const m_source_outer
Definition: composite_iterators.h:814
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:798
const size_t m_key_len
Definition: composite_iterators.h:820
bool m_deduplicate_against_previous_row
Definition: composite_iterators.h:821
uchar * m_key_buf
Definition: composite_iterators.h:819
unique_ptr_destroy_only< RowIterator > const m_source_inner
Definition: composite_iterators.h:815
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:4346
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:803
const TABLE * m_table_outer
Definition: composite_iterators.h:817
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.cc:4361
An iterator that removes consecutive rows that are the same according to a set of items (typically th...
Definition: composite_iterators.h:695
void StartPSIBatchMode() override
Start performance schema batch mode, if supported (otherwise ignored).
Definition: composite_iterators.h:709
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:710
void UnlockRow() override
Definition: composite_iterators.h:713
int Read() override
Read a single row.
Definition: composite_iterators.cc:4280
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:705
bool m_first_row
Definition: composite_iterators.h:718
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.cc:4275
Bounds_checked_array< Cached_item * > m_caches
Definition: composite_iterators.h:717
RemoveDuplicatesIterator(THD *thd, unique_ptr_destroy_only< RowIterator > source, JOIN *join, Item **group_items, int group_items_size)
Definition: composite_iterators.cc:4263
unique_ptr_destroy_only< RowIterator > m_source
Definition: composite_iterators.h:716
Much like RemoveDuplicatesIterator, but works on the basis of a given index (or more accurately,...
Definition: composite_iterators.h:727
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.cc:4317
void UnlockRow() override
Definition: composite_iterators.h:744
uchar * m_key_buf
Definition: composite_iterators.h:750
bool m_first_row
Definition: composite_iterators.h:752
const TABLE * m_table
Definition: composite_iterators.h:748
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:751
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:4307
KEY * m_key
Definition: composite_iterators.h:749
int Read() override
Read a single row.
Definition: composite_iterators.cc:4322
unique_ptr_destroy_only< RowIterator > m_source
Definition: composite_iterators.h:747
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:561
JOIN *const m_join
Definition: composite_iterators.h:596
void UnlockRow() override
Definition: composite_iterators.h:590
void StartPSIBatchMode() override
Start performance schema batch mode, if supported (otherwise ignored).
Definition: composite_iterators.h:584
int Read() override
Read a single row.
Definition: composite_iterators.cc:3774
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:3722
Temp_table_param * m_temp_table_param
Definition: composite_iterators.h:594
const bool m_provide_rowid
Definition: composite_iterators.h:603
const int m_output_slice
Definition: composite_iterators.h:597
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:587
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.cc:3751
int m_input_slice
Definition: composite_iterators.h:598
unique_ptr_destroy_only< RowIterator > m_subquery_iterator
Definition: composite_iterators.h:593
ha_rows m_row_number
Definition: composite_iterators.h:595
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:662
unique_ptr_destroy_only< RowIterator > m_source
Definition: composite_iterators.h:680
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:674
WeedoutIterator(THD *thd, unique_ptr_destroy_only< RowIterator > source, SJ_TMP_TABLE *sj, table_map tables_to_get_rowid_for)
Definition: composite_iterators.cc:4202
int Read() override
Read a single row.
Definition: composite_iterators.cc:4232
const table_map m_tables_to_get_rowid_for
Definition: composite_iterators.h:682
SJ_TMP_TABLE * m_sj
Definition: composite_iterators.h:681
void UnlockRow() override
Definition: composite_iterators.h:677
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:670
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.cc:4215
A structure that contains a list of input tables for a hash join operation, BKA join operation or a s...
Definition: pack_rows.h:93
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:429
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:3699
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:523
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:4154
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:434
unique_ptr_destroy_only< RowIterator > subquery_iterator
The iterator to read the actual rows from.
Definition: composite_iterators.h:436
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:464
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:480
double m_estimated_output_rows
The estimated number of rows produced by this block.
Definition: composite_iterators.h:494
ulonglong m_operand_idx
The current operand (i.e.
Definition: composite_iterators.h:471
bool is_recursive_reference
Definition: composite_iterators.h:484
FollowTailIterator * recursive_reader
Definition: composite_iterators.h:491
int select_number
Used only for optimizer trace.
Definition: composite_iterators.h:439
ulonglong m_total_operands
The number of operands (i.e.
Definition: composite_iterators.h:468
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:476
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:459
JOIN * join
The JOIN that this query block represents.
Definition: composite_iterators.h:446