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();
129 bool reject_multiple_rows,
ha_rows *skipped_rows)
137 if (count_all_rows) {
143 m_source->SetNullRowFlag(is_null_row);
148 m_source->EndPSIBatchModeIfStarted();
212 std::span<AccessPath *> single_row_index_lookups,
216 m_source->SetNullRowFlag(is_null_row);
221 m_source->EndPSIBatchModeIfStarted();
349 assert(!pfs_batch_mode);
404 const std::string &
name)
586 bool provide_rowid,
JOIN *
join,
int ref_slice);
675 m_source->SetNullRowFlag(is_null_row);
679 m_source->EndPSIBatchModeIfStarted();
705 JOIN *
join, std::span<Item *> group_items);
708 m_source->SetNullRowFlag(is_null_row);
713 m_source->EndPSIBatchModeIfStarted();
738 m_source->SetNullRowFlag(is_null_row);
743 m_source->EndPSIBatchModeIfStarted();
796 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:208
void UnlockRow() override
Definition: composite_iterators.h:223
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:219
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
int DoRead() override
Definition: composite_iterators.cc:287
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:223
bool DoInit() override
Definition: composite_iterators.cc:243
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
@ 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
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
enum AggregateIterator::@65 m_state
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:220
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
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:215
void SetRollupLevel(int level)
Definition: composite_iterators.cc:503
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:865
size_t m_current_iterator_index
Definition: composite_iterators.h:882
AppendIterator(THD *thd, std::vector< unique_ptr_destroy_only< RowIterator > > &&sub_iterators)
Definition: composite_iterators.cc:4526
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:4563
int DoRead() override
Definition: composite_iterators.cc:4538
bool DoInit() override
Definition: composite_iterators.cc:4532
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.cc:4573
void UnlockRow() override
Definition: composite_iterators.cc:4581
std::vector< unique_ptr_destroy_only< RowIterator > > m_sub_iterators
Definition: composite_iterators.h:881
bool m_pfs_batch_mode_enabled
Definition: composite_iterators.h:883
void StartPSIBatchMode() override
Start performance schema batch mode, if supported (otherwise ignored).
Definition: composite_iterators.cc:4568
A wrapper class which provides array bounds checking.
Definition: sql_array.h:48
An iterator that helps invalidating caches.
Definition: composite_iterators.h:400
CacheInvalidatorIterator(THD *thd, unique_ptr_destroy_only< RowIterator > source_iterator, const std::string &name)
Definition: composite_iterators.h:402
int DoRead() override
Definition: composite_iterators.h:415
std::string m_name
Definition: composite_iterators.h:434
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:421
unique_ptr_destroy_only< RowIterator > m_source_iterator
Definition: composite_iterators.h:432
void UnlockRow() override
Definition: composite_iterators.h:426
bool DoInit() override
Definition: composite_iterators.h:410
int64_t m_generation
Definition: composite_iterators.h:433
std::string name() const
Definition: composite_iterators.h:429
int64_t generation() const
Definition: composite_iterators.h:428
This is used for segregating rows in groups (e.g.
Definition: item.h:6649
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:120
unique_ptr_destroy_only< RowIterator > m_source
Definition: composite_iterators.h:102
bool m_no_rows
Definition: composite_iterators.h:104
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.cc:97
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:929
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:150
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
ha_rows m_seen_rows
Definition: composite_iterators.h:161
const bool m_count_all_rows
Definition: composite_iterators.h:169
ha_rows * m_skipped_rows
Definition: composite_iterators.h:171
int DoRead() override
Definition: composite_iterators.cc:161
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:147
const ha_rows m_limit
Definition: composite_iterators.h:168
const ha_rows m_offset
Definition: composite_iterators.h:168
bool m_needs_offset
Whether we have OFFSET rows that we still need to skip.
Definition: composite_iterators.h:166
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:142
unique_ptr_destroy_only< RowIterator > m_source
Definition: composite_iterators.h:156
const bool m_reject_multiple_rows
Definition: composite_iterators.h:170
bool DoInit() override
Definition: composite_iterators.cc:147
void StartPSIBatchMode() override
Start performance schema batch mode, if supported (otherwise ignored).
Definition: composite_iterators.h:146
An iterator that wraps a Table_function (e.g.
Definition: composite_iterators.h:622
Table_function * m_table_function
Definition: composite_iterators.h:647
unique_ptr_destroy_only< RowIterator > m_table_iterator
Definition: composite_iterators.h:645
int DoRead() override
Definition: composite_iterators.h:643
bool DoInit() override
Definition: composite_iterators.cc:4262
void StartPSIBatchMode() override
Start performance schema batch mode, if supported (otherwise ignored).
Definition: composite_iterators.h:632
void UnlockRow() override
Definition: composite_iterators.h:639
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:628
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:633
MaterializedTableFunctionIterator(THD *thd, Table_function *table_function, TABLE *table, unique_ptr_destroy_only< RowIterator > table_iterator)
Definition: composite_iterators.cc:4255
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
int DoRead() override
Definition: composite_iterators.cc:526
void UnlockRow() override
Definition: composite_iterators.h:364
@ END_OF_ROWS
Definition: composite_iterators.h:381
@ READING_INNER_ROWS
Definition: composite_iterators.h:380
@ NEEDS_OUTER_ROW
Definition: composite_iterators.h:378
@ READING_FIRST_INNER_ROW
Definition: composite_iterators.h:379
const bool m_pfs_batch_mode
Whether to use batch mode when scanning the inner iterator.
Definition: composite_iterators.h:389
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:385
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:359
const JoinType m_join_type
Definition: composite_iterators.h:386
bool DoInit() override
Definition: composite_iterators.cc:515
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:353
unique_ptr_destroy_only< RowIterator > const m_source_outer
Definition: composite_iterators.h:384
enum NestedLoopIterator::@66 m_state
An iterator that is semantically equivalent to a semijoin NestedLoopIterator immediately followed by ...
Definition: composite_iterators.h:791
void UnlockRow() override
Definition: composite_iterators.h:808
int DoRead() override
Definition: composite_iterators.cc:4444
KEY * m_key
Definition: composite_iterators.h:821
unique_ptr_destroy_only< RowIterator > const m_source_outer
Definition: composite_iterators.h:817
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:823
bool m_deduplicate_against_previous_row
Definition: composite_iterators.h:824
bool DoInit() override
Definition: composite_iterators.cc:4436
uchar * m_key_buf
Definition: composite_iterators.h:822
unique_ptr_destroy_only< RowIterator > const m_source_inner
Definition: composite_iterators.h:818
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:4421
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:803
const TABLE * m_table_outer
Definition: composite_iterators.h:820
An iterator that removes consecutive rows that are the same according to a set of items (typically th...
Definition: composite_iterators.h:701
void StartPSIBatchMode() override
Start performance schema batch mode, if supported (otherwise ignored).
Definition: composite_iterators.h:711
RemoveDuplicatesIterator(THD *thd, unique_ptr_destroy_only< RowIterator > source, JOIN *join, std::span< Item * > group_items)
Definition: composite_iterators.cc:4336
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:712
void UnlockRow() override
Definition: composite_iterators.h:715
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:707
bool m_first_row
Definition: composite_iterators.h:722
bool DoInit() override
Definition: composite_iterators.cc:4348
Bounds_checked_array< Cached_item * > m_caches
Definition: composite_iterators.h:721
int DoRead() override
Definition: composite_iterators.cc:4353
unique_ptr_destroy_only< RowIterator > m_source
Definition: composite_iterators.h:720
Much like RemoveDuplicatesIterator, but works on the basis of a given index (or more accurately,...
Definition: composite_iterators.h:731
int DoRead() override
Definition: composite_iterators.cc:4395
void UnlockRow() override
Definition: composite_iterators.h:745
uchar * m_key_buf
Definition: composite_iterators.h:754
bool m_first_row
Definition: composite_iterators.h:756
const TABLE * m_table
Definition: composite_iterators.h:752
void StartPSIBatchMode() override
Start performance schema batch mode, if supported (otherwise ignored).
Definition: composite_iterators.h:741
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:737
const size_t m_key_len
Definition: composite_iterators.h:755
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:742
RemoveDuplicatesOnIndexIterator(THD *thd, unique_ptr_destroy_only< RowIterator > source, const TABLE *table, KEY *key, size_t key_len)
Definition: composite_iterators.cc:4380
KEY * m_key
Definition: composite_iterators.h:753
unique_ptr_destroy_only< RowIterator > m_source
Definition: composite_iterators.h:751
bool DoInit() override
Definition: composite_iterators.cc:4390
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:569
bool DoInit() override
Definition: composite_iterators.cc:3821
JOIN *const m_join
Definition: composite_iterators.h:602
void UnlockRow() override
Definition: composite_iterators.h:594
int DoRead() override
Definition: composite_iterators.cc:3844
void StartPSIBatchMode() override
Start performance schema batch mode, if supported (otherwise ignored).
Definition: composite_iterators.h:588
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:3792
Temp_table_param * m_temp_table_param
Definition: composite_iterators.h:600
const bool m_provide_rowid
Definition: composite_iterators.h:609
const int m_output_slice
Definition: composite_iterators.h:603
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:591
int m_input_slice
Definition: composite_iterators.h:604
unique_ptr_destroy_only< RowIterator > m_subquery_iterator
Definition: composite_iterators.h:599
ha_rows m_row_number
Definition: composite_iterators.h:601
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:669
bool DoInit() override
Definition: composite_iterators.cc:4288
unique_ptr_destroy_only< RowIterator > m_source
Definition: composite_iterators.h:686
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:678
WeedoutIterator(THD *thd, unique_ptr_destroy_only< RowIterator > source, SJ_TMP_TABLE *sj, table_map tables_to_get_rowid_for)
Definition: composite_iterators.cc:4275
const table_map m_tables_to_get_rowid_for
Definition: composite_iterators.h:688
int DoRead() override
Definition: composite_iterators.cc:4305
SJ_TMP_TABLE * m_sj
Definition: composite_iterators.h:687
void UnlockRow() override
Definition: composite_iterators.h:681
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:674
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:1228
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:437
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:3769
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
Define std::hash<Gtid>.
Definition: gtid.h:355
Definition: composite_iterators.h:531
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:4227
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:184
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:442
unique_ptr_destroy_only< RowIterator > subquery_iterator
The iterator to read the actual rows from.
Definition: composite_iterators.h:444
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:472
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:488
double m_estimated_output_rows
The estimated number of rows produced by this block.
Definition: composite_iterators.h:502
ulonglong m_operand_idx
The current operand (i.e.
Definition: composite_iterators.h:479
bool is_recursive_reference
Definition: composite_iterators.h:492
FollowTailIterator * recursive_reader
Definition: composite_iterators.h:499
int select_number
Used only for optimizer trace.
Definition: composite_iterators.h:447
ulonglong m_total_operands
The number of operands (i.e.
Definition: composite_iterators.h:476
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:484
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:467
JOIN * join
The JOIN that this query block represents.
Definition: composite_iterators.h:454