MySQL 8.0.40
Source Code Documentation
TableScanIterator Class Referencefinal

Scan a table from beginning to end. More...

#include <basic_row_iterators.h>

Inheritance diagram for TableScanIterator:
[legend]

Public Member Functions

 TableScanIterator (THD *thd, TABLE *table, double expected_rows, ha_rows *examined_rows)
 
 ~TableScanIterator () override
 
bool Init () override
 Initialize or reinitialize the iterator. More...
 
int Read () override
 Read a single row. 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 IteratorProfilerGetProfiler () const
 Get profiling data for this iterator (for 'EXPLAIN ANALYZE'). More...
 
virtual void SetOverrideProfiler (const IteratorProfiler *profiler)
 
virtual RowIteratorreal_iterator ()
 If this iterator is wrapping a different iterator (e.g. More...
 
virtual const RowIteratorreal_iterator () const
 

Private Attributes

uchar *const m_record
 
const double m_expected_rows
 
ha_rows *const m_examined_rows
 
ulonglong m_remaining_dups {0}
 Used to keep track of how many more duplicates of the last read row that remains to be written to the next stage: used for EXCEPT and INTERSECT computation: we only ever materialize one row even if there are duplicates of it, but with a counter, cf TABLE::m_set_counter. More...
 
const ha_rows m_limit_rows
 Used for EXCEPT and INTERSECT only: we cannot enforce limit during materialization as for UNION and single table, so we have to do it during the scan. More...
 
ha_rows m_stored_rows {0}
 Used for EXCEPT and INTERSECT only: rows scanned so far, see also m_limit_rows. More...
 

Additional Inherited Members

- Protected Member Functions inherited from TableRowIterator
int HandleError (int error)
 
void PrintError (int error)
 
TABLEtable () const
 
- Protected Member Functions inherited from RowIterator
THDthd () const
 

Detailed Description

Scan a table from beginning to end.

This is the most basic access method of a table using rnd_init, ha_rnd_next and rnd_end. No indexes are used.

Constructor & Destructor Documentation

◆ TableScanIterator()

TableScanIterator::TableScanIterator ( THD thd,
TABLE table,
double  expected_rows,
ha_rows examined_rows 
)
Parameters
thdsession context
tabletable to be scanned. Notice that table may be a temporary table that represents a set operation (UNION, INTERSECT or EXCEPT). For the latter two, the counter field must be interpreted by TableScanIterator::Read in order to give the correct result set, but this is invisible to the consumer.
expected_rowsis used for scaling the record buffer. If zero or less, no record buffer will be set up.
examined_rowsif not nullptr, is incremented for each successful Read().

◆ ~TableScanIterator()

TableScanIterator::~TableScanIterator ( )
override

Member Function Documentation

◆ Init()

bool TableScanIterator::Init ( )
overridevirtual

Initialize or reinitialize the iterator.

You must always call Init() before trying a Read() (but Init() does not imply Read()).

You can call Init() multiple times; subsequent calls will rewind the iterator (or reposition it, depending on whether the iterator takes in e.g. a Index_lookup) and allow you to read the records anew.

Implements RowIterator.

◆ Read()

int TableScanIterator::Read ( )
overridevirtual

Read a single row.

The row data is not actually returned from the function; it is put in the table's (or tables', in case of a join) record buffer, ie., table->records[0].

Return values
0OK
-1End of records
1Error

Implements RowIterator.

Member Data Documentation

◆ m_examined_rows

ha_rows* const TableScanIterator::m_examined_rows
private

◆ m_expected_rows

const double TableScanIterator::m_expected_rows
private

◆ m_limit_rows

const ha_rows TableScanIterator::m_limit_rows
private

Used for EXCEPT and INTERSECT only: we cannot enforce limit during materialization as for UNION and single table, so we have to do it during the scan.

◆ m_record

uchar* const TableScanIterator::m_record
private

◆ m_remaining_dups

ulonglong TableScanIterator::m_remaining_dups {0}
private

Used to keep track of how many more duplicates of the last read row that remains to be written to the next stage: used for EXCEPT and INTERSECT computation: we only ever materialize one row even if there are duplicates of it, but with a counter, cf TABLE::m_set_counter.

When we start scanning we must produce as many duplicates as ALL semantics mandate, so we initialize m_examined_rows based on TABLE::m_set_counter and decrement for each row we emit, so as to produce the correct number of duplicates for the next stage.

◆ m_stored_rows

ha_rows TableScanIterator::m_stored_rows {0}
private

Used for EXCEPT and INTERSECT only: rows scanned so far, see also m_limit_rows.


The documentation for this class was generated from the following files: