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();
125 bool reject_multiple_rows,
ha_rows *skipped_rows)
133 if (count_all_rows) {
138 bool Init()
override;
143 m_source->SetNullRowFlag(is_null_row);
148 m_source->EndPSIBatchModeIfStarted();
210 bool Init()
override;
213 m_source->SetNullRowFlag(is_null_row);
218 m_source->EndPSIBatchModeIfStarted();
340 assert(!pfs_batch_mode);
344 bool Init()
override;
396 const std::string &
name)
513 query_blocks_to_materialize,
575 bool provide_rowid,
JOIN *
join,
int ref_slice);
577 bool Init()
override;
619 bool Init()
override;
664 bool Init()
override;
668 m_source->SetNullRowFlag(is_null_row);
672 m_source->EndPSIBatchModeIfStarted();
697 int group_items_size);
699 bool Init()
override;
703 m_source->SetNullRowFlag(is_null_row);
708 m_source->EndPSIBatchModeIfStarted();
730 bool Init()
override;
734 m_source->SetNullRowFlag(is_null_row);
739 m_source->EndPSIBatchModeIfStarted();
789 KEY *
key,
size_t key_len);
791 bool Init()
override;
831 bool Init()
override;
865 bool Init()
override;
Handles aggregation (typically used for GROUP BY) for the case where the rows are already properly gr...
Definition: composite_iterators.h:205
void UnlockRow() override
Definition: composite_iterators.h:220
int m_current_rollup_position
If we are in state OUTPUTTING_ROLLUP_ROWS, where we are in the iteration.
Definition: composite_iterators.h:276
void StartPSIBatchMode() override
Start performance schema batch mode, if supported (otherwise ignored).
Definition: composite_iterators.h:216
int Read() override
Read a single row.
Definition: composite_iterators.cc:238
JOIN * m_join
The join we are part of.
Definition: composite_iterators.h:243
bool m_seen_eof
Whether we have seen the last input row.
Definition: composite_iterators.h:246
@ LAST_ROW_STARTED_NEW_GROUP
Definition: composite_iterators.h:230
@ READING_FIRST_ROW
Definition: composite_iterators.h:229
@ OUTPUTTING_ROLLUP_ROWS
Definition: composite_iterators.h:231
@ DONE_OUTPUTTING_ROWS
Definition: composite_iterators.h:232
enum AggregateIterator::@54 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:282
String m_first_row_this_group
Packed version of the first row in the group we are currently processing.
Definition: composite_iterators.h:285
String m_first_row_next_group
If applicable, packed version of the first row in the next group.
Definition: composite_iterators.h:298
table_map m_save_nullinfo
Used to save NULL information in the specific case where we have zero input rows.
Definition: composite_iterators.h:252
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.cc:190
unique_ptr_destroy_only< RowIterator > m_source
Definition: composite_iterators.h:235
int m_output_slice
The slice we're setting when returning rows.
Definition: composite_iterators.h:304
AggregateIterator(THD *thd, unique_ptr_destroy_only< RowIterator > source, JOIN *join, pack_rows::TableCollection tables, bool rollup)
Definition: composite_iterators.cc:177
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:217
const bool m_rollup
Whether this is a rollup query.
Definition: composite_iterators.h:255
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:212
void SetRollupLevel(int level)
Definition: composite_iterators.cc:443
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:267
Takes in two or more iterators and output rows from them sequentially (first all rows from the first ...
Definition: composite_iterators.h:859
size_t m_current_iterator_index
Definition: composite_iterators.h:876
AppendIterator(THD *thd, std::vector< unique_ptr_destroy_only< RowIterator > > &&sub_iterators)
Definition: composite_iterators.cc:2226
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:2263
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.cc:2232
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.cc:2273
void UnlockRow() override
Definition: composite_iterators.cc:2281
std::vector< unique_ptr_destroy_only< RowIterator > > m_sub_iterators
Definition: composite_iterators.h:875
int Read() override
Read a single row.
Definition: composite_iterators.cc:2238
bool m_pfs_batch_mode_enabled
Definition: composite_iterators.h:877
void StartPSIBatchMode() override
Start performance schema batch mode, if supported (otherwise ignored).
Definition: composite_iterators.cc:2268
A wrapper class which provides array bounds checking.
Definition: sql_array.h:47
An iterator that helps invalidating caches.
Definition: composite_iterators.h:392
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.h:401
CacheInvalidatorIterator(THD *thd, unique_ptr_destroy_only< RowIterator > source_iterator, const std::string &name)
Definition: composite_iterators.h:394
std::string m_name
Definition: composite_iterators.h:424
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:411
unique_ptr_destroy_only< RowIterator > m_source_iterator
Definition: composite_iterators.h:422
void UnlockRow() override
Definition: composite_iterators.h:416
int64_t m_generation
Definition: composite_iterators.h:423
int Read() override
Read a single row.
Definition: composite_iterators.h:406
std::string name() const
Definition: composite_iterators.h:419
int64_t generation() const
Definition: composite_iterators.h:418
This is used for segregating rows in groups (e.g.
Definition: item.h:6333
An iterator that takes in a stream of rows and passes through only those that meet some criteria (i....
Definition: composite_iterators.h:78
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:93
int Read() override
Read a single row.
Definition: composite_iterators.cc:76
void UnlockRow() override
Definition: composite_iterators.h:96
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.h:84
unique_ptr_destroy_only< RowIterator > m_source
Definition: composite_iterators.h:99
FilterIterator(THD *thd, unique_ptr_destroy_only< RowIterator > source, Item *condition)
Definition: composite_iterators.h:80
void StartPSIBatchMode() override
Start performance schema batch mode, if supported (otherwise ignored).
Definition: composite_iterators.h:92
Item * m_condition
Definition: composite_iterators.h:100
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
FollowTailIterator is a special version of TableScanIterator that is used as part of WITH RECURSIVE q...
Definition: basic_row_iterators.h:439
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:853
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:107
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:123
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.cc:101
ha_rows m_seen_rows
Definition: composite_iterators.h:158
const bool m_count_all_rows
Definition: composite_iterators.h:166
ha_rows * m_skipped_rows
Definition: composite_iterators.h:168
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:147
const ha_rows m_limit
Definition: composite_iterators.h:165
const ha_rows m_offset
Definition: composite_iterators.h:165
bool m_needs_offset
Whether we have OFFSET rows that we still need to skip.
Definition: composite_iterators.h:163
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:153
int Read() override
Read a single row.
Definition: composite_iterators.cc:115
const bool m_reject_multiple_rows
Definition: composite_iterators.h:167
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:613
Table_function * m_table_function
Definition: composite_iterators.h:637
unique_ptr_destroy_only< RowIterator > m_table_iterator
Definition: composite_iterators.h:635
void StartPSIBatchMode() override
Start performance schema batch mode, if supported (otherwise ignored).
Definition: composite_iterators.h:625
void UnlockRow() override
Definition: composite_iterators.h:632
int Read() override
Read a single row.
Definition: composite_iterators.h:620
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:621
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:626
MaterializedTableFunctionIterator(THD *thd, Table_function *table_function, TABLE *table, unique_ptr_destroy_only< RowIterator > table_iterator)
Definition: composite_iterators.cc:1958
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.cc:1965
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:323
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.cc:455
int Read() override
Read a single row.
Definition: composite_iterators.cc:466
void UnlockRow() override
Definition: composite_iterators.h:359
enum NestedLoopIterator::@55 m_state
@ END_OF_ROWS
Definition: composite_iterators.h:373
@ READING_INNER_ROWS
Definition: composite_iterators.h:372
@ NEEDS_OUTER_ROW
Definition: composite_iterators.h:370
@ READING_FIRST_INNER_ROW
Definition: composite_iterators.h:371
const bool m_pfs_batch_mode
Whether to use batch mode when scanning the inner iterator.
Definition: composite_iterators.h:381
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:325
unique_ptr_destroy_only< RowIterator > const m_source_inner
Definition: composite_iterators.h:377
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:354
const JoinType m_join_type
Definition: composite_iterators.h:378
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:348
unique_ptr_destroy_only< RowIterator > const m_source_outer
Definition: composite_iterators.h:376
An iterator that is semantically equivalent to a semijoin NestedLoopIterator immediately followed by ...
Definition: composite_iterators.h:784
int Read() override
Read a single row.
Definition: composite_iterators.cc:2145
void UnlockRow() override
Definition: composite_iterators.h:805
KEY * m_key
Definition: composite_iterators.h:815
unique_ptr_destroy_only< RowIterator > const m_source_outer
Definition: composite_iterators.h:811
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:795
const size_t m_key_len
Definition: composite_iterators.h:817
bool m_deduplicate_against_previous_row
Definition: composite_iterators.h:818
uchar * m_key_buf
Definition: composite_iterators.h:816
unique_ptr_destroy_only< RowIterator > const m_source_inner
Definition: composite_iterators.h:812
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:2122
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:800
const TABLE * m_table_outer
Definition: composite_iterators.h:814
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.cc:2137
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:692
void StartPSIBatchMode() override
Start performance schema batch mode, if supported (otherwise ignored).
Definition: composite_iterators.h:706
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:707
void UnlockRow() override
Definition: composite_iterators.h:710
int Read() override
Read a single row.
Definition: composite_iterators.cc:2056
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:702
bool m_first_row
Definition: composite_iterators.h:715
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.cc:2051
Bounds_checked_array< Cached_item * > m_caches
Definition: composite_iterators.h:714
RemoveDuplicatesIterator(THD *thd, unique_ptr_destroy_only< RowIterator > source, JOIN *join, Item **group_items, int group_items_size)
Definition: composite_iterators.cc:2039
unique_ptr_destroy_only< RowIterator > m_source
Definition: composite_iterators.h:713
Much like RemoveDuplicatesIterator, but works on the basis of a given index (or more accurately,...
Definition: composite_iterators.h:724
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.cc:2093
void UnlockRow() override
Definition: composite_iterators.h:741
uchar * m_key_buf
Definition: composite_iterators.h:747
bool m_first_row
Definition: composite_iterators.h:749
const TABLE * m_table
Definition: composite_iterators.h:745
void StartPSIBatchMode() override
Start performance schema batch mode, if supported (otherwise ignored).
Definition: composite_iterators.h:737
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:733
const size_t m_key_len
Definition: composite_iterators.h:748
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:738
RemoveDuplicatesOnIndexIterator(THD *thd, unique_ptr_destroy_only< RowIterator > source, const TABLE *table, KEY *key, size_t key_len)
Definition: composite_iterators.cc:2083
KEY * m_key
Definition: composite_iterators.h:746
int Read() override
Read a single row.
Definition: composite_iterators.cc:2098
unique_ptr_destroy_only< RowIterator > m_source
Definition: composite_iterators.h:744
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:104
StreamingIterator is a minimal version of MaterializeIterator that does not actually materialize; ins...
Definition: composite_iterators.h:558
JOIN *const m_join
Definition: composite_iterators.h:593
void UnlockRow() override
Definition: composite_iterators.h:587
void StartPSIBatchMode() override
Start performance schema batch mode, if supported (otherwise ignored).
Definition: composite_iterators.h:581
int Read() override
Read a single row.
Definition: composite_iterators.cc:1551
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:1499
Temp_table_param * m_temp_table_param
Definition: composite_iterators.h:591
const bool m_provide_rowid
Definition: composite_iterators.h:600
const int m_output_slice
Definition: composite_iterators.h:594
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:584
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.cc:1528
int m_input_slice
Definition: composite_iterators.h:595
unique_ptr_destroy_only< RowIterator > m_subquery_iterator
Definition: composite_iterators.h:590
ha_rows m_row_number
Definition: composite_iterators.h:592
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:168
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:34
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:95
Like semijoin materialization, weedout works on the basic idea that a semijoin is just like an inner ...
Definition: composite_iterators.h:659
unique_ptr_destroy_only< RowIterator > m_source
Definition: composite_iterators.h:677
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: composite_iterators.h:671
WeedoutIterator(THD *thd, unique_ptr_destroy_only< RowIterator > source, SJ_TMP_TABLE *sj, table_map tables_to_get_rowid_for)
Definition: composite_iterators.cc:1978
int Read() override
Read a single row.
Definition: composite_iterators.cc:2008
const table_map m_tables_to_get_rowid_for
Definition: composite_iterators.h:679
SJ_TMP_TABLE * m_sj
Definition: composite_iterators.h:678
void UnlockRow() override
Definition: composite_iterators.h:674
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:667
bool Init() override
Initialize or reinitialize the iterator.
Definition: composite_iterators.cc:1991
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
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:489
This file includes constants used by all storage engines.
my_off_t ha_rows
Definition: my_base.h:1140
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
Definition: composite_iterators.h:427
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:1472
std::string join(Container cont, const std::string &delim)
join elements of an container into a string separated by a delimiter.
Definition: string.h:151
Definition: gcs_xcom_synode.h:64
Definition: composite_iterators.h:520
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:1930
std::vector< T, ut::allocator< T > > vector
Specialization of vector which uses allocator.
Definition: ut0new.h:2874
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
A query block to be materialized by MaterializeIterator.
Definition: composite_iterators.h:432
int select_number
Used only for optimizer trace.
Definition: composite_iterators.h:437
ulonglong m_total_operands
The number of operands (i.e.
Definition: composite_iterators.h:466
JOIN * join
The JOIN that this query block represents.
Definition: composite_iterators.h:444
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:478
ulonglong m_operand_idx
The current operand (i.e.
Definition: composite_iterators.h:469
unique_ptr_destroy_only< RowIterator > subquery_iterator
The iterator to read the actual rows from.
Definition: composite_iterators.h:434
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:474
FollowTailIterator * recursive_reader
Definition: composite_iterators.h:489
bool is_recursive_reference
Definition: composite_iterators.h:482
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:457
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:462
unsigned int uint
Definition: uca9-dump.cc:75