1#ifndef SQL_ITERATORS_COMPOSITE_ITERATORS_H_
2#define SQL_ITERATORS_COMPOSITE_ITERATORS_H_
88 m_source->SetNullRowFlag(is_null_row);
93 m_source->EndPSIBatchModeIfStarted();
124 bool reject_multiple_rows,
ha_rows *skipped_rows)
132 if (count_all_rows) {
137 bool Init()
override;
142 m_source->SetNullRowFlag(is_null_row);
147 m_source->EndPSIBatchModeIfStarted();
209 bool Init()
override;
212 m_source->SetNullRowFlag(is_null_row);
217 m_source->EndPSIBatchModeIfStarted();
339 assert(!pfs_batch_mode);
343 bool Init()
override;
395 const std::string &
name)
512 query_blocks_to_materialize,
574 bool provide_rowid,
JOIN *
join,
int ref_slice);
576 bool Init()
override;
618 bool Init()
override;
663 bool Init()
override;
667 m_source->SetNullRowFlag(is_null_row);
671 m_source->EndPSIBatchModeIfStarted();
696 int group_items_size);
698 bool Init()
override;
702 m_source->SetNullRowFlag(is_null_row);
707 m_source->EndPSIBatchModeIfStarted();
729 bool Init()
override;
733 m_source->SetNullRowFlag(is_null_row);
738 m_source->EndPSIBatchModeIfStarted();
788 KEY *
key,
size_t key_len);
790 bool Init()
override;
830 bool Init()
override;
864 bool Init()
override;
Handles aggregation (typically used for GROUP BY) for the case where the rows are already properly gr...
Definition: composite_iterators.h:204
void UnlockRow() override
Definition: composite_iterators.h:219
int m_current_rollup_position
If we are in state OUTPUTTING_ROLLUP_ROWS, where we are in the iteration.
Definition: composite_iterators.h:275
void StartPSIBatchMode() override
Start performance schema batch mode, if supported (otherwise ignored).
Definition: composite_iterators.h:215
int Read() override
Read a single row.
Definition: composite_iterators.cc:236
JOIN * m_join
The join we are part of.
Definition: composite_iterators.h:242
bool m_seen_eof
Whether we have seen the last input row.
Definition: composite_iterators.h:245
enum AggregateIterator::@56 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:281
String m_first_row_this_group
Packed version of the first row in the group we are currently processing.
Definition: composite_iterators.h:284
String m_first_row_next_group
If applicable, packed version of the first row in the next group.
Definition: composite_iterators.h:297
table_map m_save_nullinfo
Used to save NULL information in the specific case where we have zero input rows.
Definition: composite_iterators.h:251
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.cc:188
unique_ptr_destroy_only< RowIterator > m_source
Definition: composite_iterators.h:234
int m_output_slice
The slice we're setting when returning rows.
Definition: composite_iterators.h:303
AggregateIterator(THD *thd, unique_ptr_destroy_only< RowIterator > source, JOIN *join, pack_rows::TableCollection tables, bool rollup)
Definition: composite_iterators.cc:175
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:216
const bool m_rollup
Whether this is a rollup query.
Definition: composite_iterators.h:254
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:211
@ LAST_ROW_STARTED_NEW_GROUP
Definition: composite_iterators.h:229
@ READING_FIRST_ROW
Definition: composite_iterators.h:228
@ OUTPUTTING_ROLLUP_ROWS
Definition: composite_iterators.h:230
@ DONE_OUTPUTTING_ROWS
Definition: composite_iterators.h:231
void SetRollupLevel(int level)
Definition: composite_iterators.cc:441
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:266
Takes in two or more iterators and output rows from them sequentially (first all rows from the first ...
Definition: composite_iterators.h:858
size_t m_current_iterator_index
Definition: composite_iterators.h:875
AppendIterator(THD *thd, std::vector< unique_ptr_destroy_only< RowIterator > > &&sub_iterators)
Definition: composite_iterators.cc:2214
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:2251
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.cc:2220
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.cc:2261
void UnlockRow() override
Definition: composite_iterators.cc:2269
std::vector< unique_ptr_destroy_only< RowIterator > > m_sub_iterators
Definition: composite_iterators.h:874
int Read() override
Read a single row.
Definition: composite_iterators.cc:2226
bool m_pfs_batch_mode_enabled
Definition: composite_iterators.h:876
void StartPSIBatchMode() override
Start performance schema batch mode, if supported (otherwise ignored).
Definition: composite_iterators.cc:2256
A wrapper class which provides array bounds checking.
Definition: sql_array.h:46
An iterator that helps invalidating caches.
Definition: composite_iterators.h:391
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.h:400
CacheInvalidatorIterator(THD *thd, unique_ptr_destroy_only< RowIterator > source_iterator, const std::string &name)
Definition: composite_iterators.h:393
std::string m_name
Definition: composite_iterators.h:423
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:410
unique_ptr_destroy_only< RowIterator > m_source_iterator
Definition: composite_iterators.h:421
void UnlockRow() override
Definition: composite_iterators.h:415
int64_t m_generation
Definition: composite_iterators.h:422
int Read() override
Read a single row.
Definition: composite_iterators.h:405
std::string name() const
Definition: composite_iterators.h:418
int64_t generation() const
Definition: composite_iterators.h:417
This is used for segregating rows in groups (e.g.
Definition: item.h:6408
An iterator that takes in a stream of rows and passes through only those that meet some criteria (i....
Definition: composite_iterators.h:77
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:92
int Read() override
Read a single row.
Definition: composite_iterators.cc:74
void UnlockRow() override
Definition: composite_iterators.h:95
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.h:83
unique_ptr_destroy_only< RowIterator > m_source
Definition: composite_iterators.h:98
FilterIterator(THD *thd, unique_ptr_destroy_only< RowIterator > source, Item *condition)
Definition: composite_iterators.h:79
void StartPSIBatchMode() override
Start performance schema batch mode, if supported (otherwise ignored).
Definition: composite_iterators.h:91
Item * m_condition
Definition: composite_iterators.h:99
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:87
FollowTailIterator is a special version of TableScanIterator that is used as part of WITH RECURSIVE q...
Definition: basic_row_iterators.h:438
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:853
Definition: sql_optimizer.h:132
Handles LIMIT and/or OFFSET; Init() eats the first "offset" rows, and Read() stops as soon as it's se...
Definition: composite_iterators.h:106
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:122
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.cc:99
ha_rows m_seen_rows
Definition: composite_iterators.h:157
const bool m_count_all_rows
Definition: composite_iterators.h:165
ha_rows * m_skipped_rows
Definition: composite_iterators.h:167
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:146
const ha_rows m_limit
Definition: composite_iterators.h:164
const ha_rows m_offset
Definition: composite_iterators.h:164
bool m_needs_offset
Whether we have OFFSET rows that we still need to skip.
Definition: composite_iterators.h:162
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:152
int Read() override
Read a single row.
Definition: composite_iterators.cc:113
const bool m_reject_multiple_rows
Definition: composite_iterators.h:166
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:612
Table_function * m_table_function
Definition: composite_iterators.h:636
unique_ptr_destroy_only< RowIterator > m_table_iterator
Definition: composite_iterators.h:634
void StartPSIBatchMode() override
Start performance schema batch mode, if supported (otherwise ignored).
Definition: composite_iterators.h:624
void UnlockRow() override
Definition: composite_iterators.h:631
int Read() override
Read a single row.
Definition: composite_iterators.h:619
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:620
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:625
MaterializedTableFunctionIterator(THD *thd, Table_function *table_function, TABLE *table, unique_ptr_destroy_only< RowIterator > table_iterator)
Definition: composite_iterators.cc:1946
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.cc:1953
A typesafe replacement for DYNAMIC_ARRAY.
Definition: mem_root_array.h:425
A simple nested loop join, taking in two iterators (left/outer and right/inner) and joining them toge...
Definition: composite_iterators.h:322
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.cc:453
int Read() override
Read a single row.
Definition: composite_iterators.cc:464
void UnlockRow() override
Definition: composite_iterators.h:358
const bool m_pfs_batch_mode
Whether to use batch mode when scanning the inner iterator.
Definition: composite_iterators.h:380
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:324
unique_ptr_destroy_only< RowIterator > const m_source_inner
Definition: composite_iterators.h:376
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:353
const JoinType m_join_type
Definition: composite_iterators.h:377
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:347
unique_ptr_destroy_only< RowIterator > const m_source_outer
Definition: composite_iterators.h:375
enum NestedLoopIterator::@57 m_state
@ END_OF_ROWS
Definition: composite_iterators.h:372
@ READING_INNER_ROWS
Definition: composite_iterators.h:371
@ NEEDS_OUTER_ROW
Definition: composite_iterators.h:369
@ READING_FIRST_INNER_ROW
Definition: composite_iterators.h:370
An iterator that is semantically equivalent to a semijoin NestedLoopIterator immediately followed by ...
Definition: composite_iterators.h:783
int Read() override
Read a single row.
Definition: composite_iterators.cc:2133
void UnlockRow() override
Definition: composite_iterators.h:804
KEY * m_key
Definition: composite_iterators.h:814
unique_ptr_destroy_only< RowIterator > const m_source_outer
Definition: composite_iterators.h:810
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:794
const size_t m_key_len
Definition: composite_iterators.h:816
bool m_deduplicate_against_previous_row
Definition: composite_iterators.h:817
uchar * m_key_buf
Definition: composite_iterators.h:815
unique_ptr_destroy_only< RowIterator > const m_source_inner
Definition: composite_iterators.h:811
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:2110
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:799
const TABLE * m_table_outer
Definition: composite_iterators.h:813
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.cc:2125
This class represents a query expression (one query block or several query blocks combined with UNION...
Definition: sql_lex.h:623
An iterator that removes consecutive rows that are the same according to a set of items (typically th...
Definition: composite_iterators.h:691
void StartPSIBatchMode() override
Start performance schema batch mode, if supported (otherwise ignored).
Definition: composite_iterators.h:705
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:706
void UnlockRow() override
Definition: composite_iterators.h:709
int Read() override
Read a single row.
Definition: composite_iterators.cc:2044
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:701
bool m_first_row
Definition: composite_iterators.h:714
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.cc:2039
Bounds_checked_array< Cached_item * > m_caches
Definition: composite_iterators.h:713
RemoveDuplicatesIterator(THD *thd, unique_ptr_destroy_only< RowIterator > source, JOIN *join, Item **group_items, int group_items_size)
Definition: composite_iterators.cc:2027
unique_ptr_destroy_only< RowIterator > m_source
Definition: composite_iterators.h:712
Much like RemoveDuplicatesIterator, but works on the basis of a given index (or more accurately,...
Definition: composite_iterators.h:723
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.cc:2081
void UnlockRow() override
Definition: composite_iterators.h:740
uchar * m_key_buf
Definition: composite_iterators.h:746
bool m_first_row
Definition: composite_iterators.h:748
const TABLE * m_table
Definition: composite_iterators.h:744
void StartPSIBatchMode() override
Start performance schema batch mode, if supported (otherwise ignored).
Definition: composite_iterators.h:736
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:732
const size_t m_key_len
Definition: composite_iterators.h:747
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:737
RemoveDuplicatesOnIndexIterator(THD *thd, unique_ptr_destroy_only< RowIterator > source, const TABLE *table, KEY *key, size_t key_len)
Definition: composite_iterators.cc:2071
KEY * m_key
Definition: composite_iterators.h:745
int Read() override
Read a single row.
Definition: composite_iterators.cc:2086
unique_ptr_destroy_only< RowIterator > m_source
Definition: composite_iterators.h:743
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
Definition: sql_executor.h:103
StreamingIterator is a minimal version of MaterializeIterator that does not actually materialize; ins...
Definition: composite_iterators.h:557
JOIN *const m_join
Definition: composite_iterators.h:592
void UnlockRow() override
Definition: composite_iterators.h:586
void StartPSIBatchMode() override
Start performance schema batch mode, if supported (otherwise ignored).
Definition: composite_iterators.h:580
int Read() override
Read a single row.
Definition: composite_iterators.cc:1538
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:1486
Temp_table_param * m_temp_table_param
Definition: composite_iterators.h:590
const bool m_provide_rowid
Definition: composite_iterators.h:599
const int m_output_slice
Definition: composite_iterators.h:593
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:583
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.cc:1515
int m_input_slice
Definition: composite_iterators.h:594
unique_ptr_destroy_only< RowIterator > m_subquery_iterator
Definition: composite_iterators.h:589
ha_rows m_row_number
Definition: composite_iterators.h:591
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:166
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:33
Definition: row_iterator.h:233
TABLE * table() const
Definition: row_iterator.h:245
Class representing a table function.
Definition: table_function.h:52
Object containing parameters used when creating and using temporary tables.
Definition: temp_table_param.h:94
Like semijoin materialization, weedout works on the basic idea that a semijoin is just like an inner ...
Definition: composite_iterators.h:658
unique_ptr_destroy_only< RowIterator > m_source
Definition: composite_iterators.h:676
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:670
WeedoutIterator(THD *thd, unique_ptr_destroy_only< RowIterator > source, SJ_TMP_TABLE *sj, table_map tables_to_get_rowid_for)
Definition: composite_iterators.cc:1966
int Read() override
Read a single row.
Definition: composite_iterators.cc:1996
const table_map m_tables_to_get_rowid_for
Definition: composite_iterators.h:678
SJ_TMP_TABLE * m_sj
Definition: composite_iterators.h:677
void UnlockRow() override
Definition: composite_iterators.h:673
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:666
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.cc:1979
A structure that contains a list of input tables for a hash join operation, BKA join operation or a s...
Definition: pack_rows.h:92
JoinType
Definition: join_type.h:27
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:488
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
uint64_t table_map
Definition: my_table_map.h:29
static PFS_engine_table_share_proxy table
Definition: pfs.cc:60
Definition: composite_iterators.h:426
RowIterator * CreateIterator(THD *thd, Mem_root_array< materialize_iterator::QueryBlock > query_blocks_to_materialize, 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:1459
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: varlen_sort.h:183
Definition: composite_iterators.h:519
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:1918
std::vector< T, ut::allocator< T > > vector
Specialization of vector which uses allocator.
Definition: ut0new.h:2873
Generic routines for packing rows (possibly from multiple tables at the same time) into strings,...
required string key
Definition: replication_asynchronous_connection_failover.proto:59
repeated Source source
Definition: replication_asynchronous_connection_failover.proto:41
join_type
Definition: sql_opt_exec_shared.h:185
Our own string classes, used pervasively throughout the executor.
Definition: materialize_path_parameters.h:39
A query block to be materialized by MaterializeIterator.
Definition: composite_iterators.h:431
int select_number
Used only for optimizer trace.
Definition: composite_iterators.h:436
ulonglong m_total_operands
The number of operands (i.e.
Definition: composite_iterators.h:465
JOIN * join
The JOIN that this query block represents.
Definition: composite_iterators.h:443
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:477
ulonglong m_operand_idx
The current operand (i.e.
Definition: composite_iterators.h:468
unique_ptr_destroy_only< RowIterator > subquery_iterator
The iterator to read the actual rows from.
Definition: composite_iterators.h:433
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:473
FollowTailIterator * recursive_reader
Definition: composite_iterators.h:488
bool is_recursive_reference
Definition: composite_iterators.h:481
bool disable_deduplication_by_hash_field
If true, unique constraint checking via hash key is disabled when materializing this query block (ie....
Definition: composite_iterators.h:456
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:461