MySQL 8.0.39
Source Code Documentation
|
The iterator actually doing the reads from the inner table during BKA. More...
#include <bka_iterator.h>
Public Member Functions | |
MultiRangeRowIterator (THD *thd, TABLE *table, Index_lookup *ref, int mrr_flags, JoinType join_type, const Prealloced_array< TABLE *, 4 > &outer_input_tables, bool store_rowids, table_map tables_to_get_rowid_for) | |
void | set_rows (const hash_join_buffer::BufferRow *begin, const hash_join_buffer::BufferRow *end) |
Specify which outer rows to read inner rows for. More... | |
void | set_mrr_buffer (uchar *ptr, size_t size) |
Specify an unused chunk of memory MRR can use for the returned inner rows. More... | |
void | set_match_flag_buffer (uchar *ptr) |
Specify an unused chunk of memory that we can use to mark which inner rows have been read (by the parent BKA iterator) or not. More... | |
void | MarkLastRowAsRead () |
Mark that the BKA iterator has seen the last row we returned from Read(). More... | |
bool | RowHasBeenRead (const hash_join_buffer::BufferRow *row) const |
Check whether the given row has been marked as read (using MarkLastRowAsRead()) or not. More... | |
bool | Init () override |
Do the actual multi-range read with the rows given by set_rows() and using the temporary buffer given in set_mrr_buffer(). More... | |
int | Read () override |
Read another inner row (if any) and load the appropriate outer row(s) into the associated table buffers. More... | |
Public Member Functions inherited from TableRowIterator | |
TableRowIterator (THD *thd, TABLE *table) | |
void | UnlockRow () override |
The default implementation of unlock-row method of RowIterator, used in all access methods except EQRefIterator. More... | |
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 is true, you'll get only NULLs no matter what is actually in the buffer (typically some old leftover row). More... | |
void | StartPSIBatchMode () override |
Start performance schema batch mode, if supported (otherwise ignored). More... | |
void | EndPSIBatchModeIfStarted () override |
Ends performance schema batch mode, if started. More... | |
Public Member Functions inherited from RowIterator | |
RowIterator (THD *thd) | |
virtual | ~RowIterator ()=default |
RowIterator (const RowIterator &)=delete | |
RowIterator (RowIterator &&)=default | |
virtual const IteratorProfiler * | GetProfiler () const |
Get profiling data for this iterator (for 'EXPLAIN ANALYZE'). More... | |
virtual void | SetOverrideProfiler ([[maybe_unused]] const IteratorProfiler *profiler) |
virtual RowIterator * | real_iterator () |
If this iterator is wrapping a different iterator (e.g. More... | |
virtual const RowIterator * | real_iterator () const |
Private Member Functions | |
range_seq_t | MrrInitCallback (uint n_ranges, uint flags) |
uint | MrrNextCallback (KEY_MULTI_RANGE *range) |
bool | MrrSkipIndexTuple (char *range_info) |
bool | MrrSkipRecord (char *range_info) |
Static Private Member Functions | |
static range_seq_t | MrrInitCallbackThunk (void *init_params, uint n_ranges, uint flags) |
static uint | MrrNextCallbackThunk (void *init_params, KEY_MULTI_RANGE *range) |
static bool | MrrSkipRecordCallbackThunk (range_seq_t seq, char *range_info, uchar *) |
Private Attributes | |
handler *const | m_file |
Handler for the table we are reading from. More... | |
Index_lookup *const | m_ref |
The index condition. More... | |
const int | m_mrr_flags |
Flags passed on to MRR. More... | |
const hash_join_buffer::BufferRow * | m_begin |
Current outer rows to read inner rows for. Set by set_rows(). More... | |
const hash_join_buffer::BufferRow * | m_end |
const hash_join_buffer::BufferRow * | m_current_pos |
Which row we are at in the [m_begin, m_end) range. More... | |
const hash_join_buffer::BufferRow * | m_last_row_returned |
What row we last returned from Read() (used for MarkLastRowAsRead()). More... | |
HANDLER_BUFFER | m_mrr_buffer |
Temporary space for storing inner rows, used by MRR. More... | |
uchar * | m_match_flag_buffer = nullptr |
See set_match_flag_buffer(). More... | |
pack_rows::TableCollection | m_outer_input_tables |
Tables and columns needed for each outer row. More... | |
const JoinType | m_join_type |
The join type of the BKA join we are part of. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from TableRowIterator | |
int | HandleError (int error) |
void | PrintError (int error) |
TABLE * | table () const |
Protected Member Functions inherited from RowIterator | |
THD * | thd () const |
The iterator actually doing the reads from the inner table during BKA.
See file comment.
MultiRangeRowIterator::MultiRangeRowIterator | ( | THD * | thd, |
TABLE * | table, | ||
Index_lookup * | ref, | ||
int | mrr_flags, | ||
JoinType | join_type, | ||
const Prealloced_array< TABLE *, 4 > & | outer_input_tables, | ||
bool | store_rowids, | ||
table_map | tables_to_get_rowid_for | ||
) |
thd | Thread handle. |
table | The inner table to scan. |
ref | The index condition we are looking up on. |
mrr_flags | Flags passed on to MRR. |
join_type | What kind of BKA join this MRR iterator is part of. |
outer_input_tables | Which tables are on the left side of the BKA join (the MRR iterator is always alone on the right side). This is needed so that it can unpack the rows into the right tables, with the right format. |
store_rowids | Whether we need to keep row IDs. |
tables_to_get_rowid_for | Tables we need to call table->file->position() for; if a table is present in outer_input_tables but not this, some other iterator will make sure that table has the correct row ID already present after Read(). |
|
overridevirtual |
Do the actual multi-range read with the rows given by set_rows() and using the temporary buffer given in set_mrr_buffer().
We don't send a set of rows directly to MRR; instead, we give it a set of function pointers to iterate over the rows, and a pointer to ourselves. The handler will call our callbacks as follows:
Implements RowIterator.
|
inline |
Mark that the BKA iterator has seen the last row we returned from Read().
(It could have been discarded by a FilterIterator before it reached them.) Will be a no-op for inner joins; see set_match_flag_buffer()..
|
private |
|
inlinestaticprivate |
|
private |
|
inlinestaticprivate |
|
private |
|
private |
|
inlinestaticprivate |
|
overridevirtual |
Read another inner row (if any) and load the appropriate outer row(s) into the associated table buffers.
Implements RowIterator.
|
inline |
Check whether the given row has been marked as read (using MarkLastRowAsRead()) or not.
Used internally when doing semijoins, and also by the BKAIterator when synthesizing NULL-complemented rows for outer joins or antijoins.
|
inline |
Specify an unused chunk of memory that we can use to mark which inner rows have been read (by the parent BKA iterator) or not.
This is used for outer joins to know which rows need NULL-complemented versions, and for semijoins and antijoins to avoid matching the same inner row more than once.
Must be called before Init() for semijoins, outer joins and antijoins, and never called otherwise. There must be room at least for one bit per row given in set_rows().
|
inline |
Specify an unused chunk of memory MRR can use for the returned inner rows.
Must be called before Init(), and must be at least big enough to hold one inner row.
|
inline |
Specify which outer rows to read inner rows for.
Must be called before Init(), and be valid until the last Read().
|
private |
Current outer rows to read inner rows for. Set by set_rows().
|
private |
Which row we are at in the [m_begin, m_end) range.
Used during the MRR callbacks.
|
private |
|
private |
Handler for the table we are reading from.
|
private |
The join type of the BKA join we are part of.
Same as m_join_type in the corresponding BKAIterator.
|
private |
What row we last returned from Read() (used for MarkLastRowAsRead()).
|
private |
Temporary space for storing inner rows, used by MRR.
Set by set_mrr_buffer().
|
private |
Flags passed on to MRR.
|
private |
Tables and columns needed for each outer row.
Same as m_outer_input_tables in the corresponding BKAIterator.
|
private |
The index condition.