MySQL 8.4.2
Source Code Documentation
subselect_hash_sj_engine Class Referencefinal

Compute an IN predicate via a hash semi-join. More...

#include <item_subselect.h>

Inheritance diagram for subselect_hash_sj_engine:
[legend]

Public Member Functions

 subselect_hash_sj_engine (Item_in_subselect *in_predicate, Query_expression *query_expr)
 
 ~subselect_hash_sj_engine () override
 
bool setup (THD *thd, const mem_root_deque< Item * > &tmp_columns)
 Create all structures needed for subquery execution using hash semijoin. More...
 
void cleanup () override
 Cleanup performed after each execution. More...
 
bool exec (THD *thd) override
 Execute a subquery IN predicate via materialization. More...
 
void print (const THD *thd, String *str, enum_query_type query_type) override
 Print the state of this engine into a string for debugging and views. More...
 
enum_engine_type engine_type () const override
 
TABLEget_table () const
 
const Index_lookupindex_lookup () const
 
enum join_type get_join_type () const
 
AccessPathroot_access_path () const
 
void create_iterators (THD *thd) override
 
- Public Member Functions inherited from subselect_indexsubquery_engine
 subselect_indexsubquery_engine (TABLE *table, Table_ref *table_ref, const Index_lookup &ref, enum join_type join_type, Item_in_subselect *subs, Item *where, Item *having)
 
virtual ~subselect_indexsubquery_engine ()=default
 

Private Types

enum  nulls_exist { NEX_IRRELEVANT_OR_FALSE = 0 , NEX_UNKNOWN = 1 , NEX_TRUE = 2 }
 Existence of inner NULLs in materialized table: By design, other values than IRRELEVANT_OR_FALSE are possible only if the subquery has only one inner expression. More...
 

Private Attributes

bool is_materialized
 
bool has_zero_rows = false
 
enum nulls_exist mat_table_has_nulls
 
Query_expression *const m_query_expr
 
unique_ptr_destroy_only< RowIteratorm_iterator
 
AccessPathm_root_access_path
 
Query_result_interceptorsaved_result {nullptr}
 Saved result object, must be restored after use. More...
 

Additional Inherited Members

- Public Types inherited from subselect_indexsubquery_engine
enum  enum_engine_type { INDEXSUBQUERY_ENGINE , HASH_SJ_ENGINE }
 
- Protected Attributes inherited from subselect_indexsubquery_engine
Query_result_unionresult = nullptr
 
TABLEtable {nullptr}
 Table which is read, using one of eq_ref, ref, ref_or_null. More...
 
Table_reftable_ref {nullptr}
 
Index_lookup ref
 
join_type type {JT_UNKNOWN}
 
Itemm_cond
 The WHERE condition of the subquery. More...
 
ulonglong m_hash
 Hash value calculated by RefIterator, when needed. More...
 
Itemm_having
 
Item_in_subselectitem
 

Detailed Description

Compute an IN predicate via a hash semi-join.

The subquery is materialized during the first evaluation of the IN predicate. The IN predicate is executed via the functionality inherited from subselect_indexsubquery_engine.

Member Enumeration Documentation

◆ nulls_exist

Existence of inner NULLs in materialized table: By design, other values than IRRELEVANT_OR_FALSE are possible only if the subquery has only one inner expression.

Enumerator
NEX_IRRELEVANT_OR_FALSE 

none, or they don't matter

NEX_UNKNOWN 

they matter, and we don't know yet if they exists

NEX_TRUE 

they matter, and we know there exists at least one.

Constructor & Destructor Documentation

◆ subselect_hash_sj_engine()

subselect_hash_sj_engine::subselect_hash_sj_engine ( Item_in_subselect in_predicate,
Query_expression query_expr 
)
inline

◆ ~subselect_hash_sj_engine()

subselect_hash_sj_engine::~subselect_hash_sj_engine ( )
override

Member Function Documentation

◆ cleanup()

void subselect_hash_sj_engine::cleanup ( )
overridevirtual

Cleanup performed after each execution.

Reimplemented from subselect_indexsubquery_engine.

◆ create_iterators()

void subselect_hash_sj_engine::create_iterators ( THD thd)
overridevirtual

Reimplemented from subselect_indexsubquery_engine.

◆ engine_type()

enum_engine_type subselect_hash_sj_engine::engine_type ( ) const
inlineoverridevirtual

Reimplemented from subselect_indexsubquery_engine.

◆ exec()

bool subselect_hash_sj_engine::exec ( THD thd)
overridevirtual

Execute a subquery IN predicate via materialization.

If needed materialize the subquery into a temporary table, then compute the predicate via a lookup into this table.

Returns
false if success, true if error

Reimplemented from subselect_indexsubquery_engine.

◆ get_join_type()

enum join_type subselect_hash_sj_engine::get_join_type ( ) const
inline

◆ get_table()

TABLE * subselect_hash_sj_engine::get_table ( ) const
inline

◆ index_lookup()

const Index_lookup & subselect_hash_sj_engine::index_lookup ( ) const
inline

◆ print()

void subselect_hash_sj_engine::print ( const THD thd,
String str,
enum_query_type  query_type 
)
overridevirtual

Print the state of this engine into a string for debugging and views.

Reimplemented from subselect_indexsubquery_engine.

◆ root_access_path()

AccessPath * subselect_hash_sj_engine::root_access_path ( ) const
inline

◆ setup()

bool subselect_hash_sj_engine::setup ( THD thd,
const mem_root_deque< Item * > &  tmp_columns 
)

Create all structures needed for subquery execution using hash semijoin.

  • Create a temporary table to store the result of the IN subquery. The temporary table has one hash index on all its columns. If single-column, the index allows at most one NULL row.
  • Create a new result sink that sends the result stream of the subquery to the temporary table,
  • Create and initialize Index_lookup objects to perform lookups into the indexed temporary table.
Parameters
thdthread handle
tmp_columnscolumns of temporary table
Note
Currently Item_subselect::init() already chooses and creates at parse time an engine with a corresponding JOIN to execute the subquery.
Returns
false if success, true if error

Member Data Documentation

◆ has_zero_rows

bool subselect_hash_sj_engine::has_zero_rows = false
private

◆ is_materialized

bool subselect_hash_sj_engine::is_materialized
private

◆ m_iterator

unique_ptr_destroy_only<RowIterator> subselect_hash_sj_engine::m_iterator
private

◆ m_query_expr

Query_expression* const subselect_hash_sj_engine::m_query_expr
private

◆ m_root_access_path

AccessPath* subselect_hash_sj_engine::m_root_access_path
private

◆ mat_table_has_nulls

enum nulls_exist subselect_hash_sj_engine::mat_table_has_nulls
private

◆ saved_result

Query_result_interceptor* subselect_hash_sj_engine::saved_result {nullptr}
private

Saved result object, must be restored after use.


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