MySQL 9.0.0
Source Code Documentation
item_subselect.h File Reference
#include <assert.h>
#include <sys/types.h>
#include <cstddef>
#include <memory>
#include <vector>
#include "field_types.h"
#include "my_alloc.h"
#include "my_inttypes.h"
#include "my_table_map.h"
#include "my_time.h"
#include "mysql/udf_registration_types.h"
#include "mysql_time.h"
#include "sql/comp_creator.h"
#include "sql/enum_query_type.h"
#include "sql/item.h"
#include "sql/iterators/row_iterator.h"
#include "sql/parse_location.h"
#include "sql/parse_tree_node_base.h"
#include "sql/sql_const.h"
#include "sql/sql_opt_exec_shared.h"
#include "template_utils.h"

Go to the source code of this file.

Classes

class  Item_subselect
 Base class that is common to all subqueries and subquery predicates. More...
 
struct  Item_subselect::Collect_subq_info
 argument used by walk method collect_scalar_subqueries ("css") More...
 
class  Item_singlerow_subselect
 Class that represents scalar subquery and row subquery. More...
 
struct  Item_singlerow_subselect::Scalar_subquery_replacement
 Argument for walk method replace_scalar_subquery. More...
 
class  Item_maxmin_subselect
 
class  Item_exists_subselect
 
class  Item_in_subselect
 Representation of IN subquery predicates of the form "left_expr IN (SELECT ...)". More...
 
struct  Item_in_subselect::In2exists_info
 This bundles several pieces of information useful when doing the IN->EXISTS transform. More...
 
class  Item_allany_subselect
 Class that represents a quantified comparison predicate. More...
 
class  subselect_indexsubquery_engine
 A subquery execution engine that evaluates the subquery by doing index lookups in a single table's index. More...
 
class  subselect_hash_sj_engine
 Compute an IN predicate via a hash semi-join. More...
 

Enumerations

enum class  Subquery_strategy : int {
  UNSPECIFIED , CANDIDATE_FOR_IN2EXISTS_OR_MAT , CANDIDATE_FOR_SEMIJOIN , CANDIDATE_FOR_DERIVED_TABLE ,
  SEMIJOIN , DERIVED_TABLE , SUBQ_EXISTS , SUBQ_MATERIALIZATION ,
  DELETED
}
 Classes that represent predicates over table subqueries: [NOT] EXISTS, [NOT] IN, ANY/SOME and ALL. More...
 

Functions

Itemall_any_subquery_creator (Item *left_expr, chooser_compare_func_creator cmp, bool all, Query_block *select)
 Construct ALL/ANY/SOME subquery Item. More...
 
Itemremove_in2exists_conds (Item *conds)
 Removes every predicate injected by IN->EXISTS. More...
 
bool is_quantified_comp_predicate (Item *item)
 

Enumeration Type Documentation

◆ Subquery_strategy

enum class Subquery_strategy : int
strong

Classes that represent predicates over table subqueries: [NOT] EXISTS, [NOT] IN, ANY/SOME and ALL.

Strategy which will be used to handle this subquery: flattening to a semi-join, conversion to a derived table, rewrite of IN to EXISTS... Sometimes the strategy is first only a candidate, then the real decision happens in a second phase. Other times the first decision is final.

Enumerator
UNSPECIFIED 

Nothing decided yet.

CANDIDATE_FOR_IN2EXISTS_OR_MAT 

Candidate for rewriting IN(subquery) to EXISTS, or subquery materialization.

CANDIDATE_FOR_SEMIJOIN 

Candidate for semi-join flattening.

CANDIDATE_FOR_DERIVED_TABLE 

Candidate for rewriting to joined derived table.

SEMIJOIN 

Semi-join flattening.

DERIVED_TABLE 

Rewrite to joined derived table.

SUBQ_EXISTS 

Evaluate as EXISTS subquery (possibly after rewriting from another type)

SUBQ_MATERIALIZATION 

Subquery materialization (HASH_SJ_ENGINE)

DELETED 

Subquery has been deleted, probably because it was always false.

Function Documentation

◆ is_quantified_comp_predicate()

bool is_quantified_comp_predicate ( Item item)
Returns
whether the item is a quantified comparison predicate

◆ remove_in2exists_conds()

Item * remove_in2exists_conds ( Item conds)

Removes every predicate injected by IN->EXISTS.

This function is different from others:

  • it wants to remove all traces of IN->EXISTS (for materialization)
  • remove_subq_pushed_predicates() and remove_additional_cond() want to remove only the conditions of IN->EXISTS which index lookup already satisfies (they are just an optimization).

If there are no in2exists conditions, it will return the exact same pointer. If it returns a new Item, the old Item is left alone, so it can be reused in other settings.

Parameters
condsCondition; may be nullptr.
Returns
new condition