MySQL  8.0.27
Source Code Documentation
Query_expression Class Reference

This class represents a query expression (one query block or several query blocks combined with UNION). More...

#include <sql_lex.h>

Public Types

enum  enum_clean_state { UC_DIRTY , UC_PART_CLEAN , UC_CLEAN }
 Values for Query_expression::cleaned. More...
 

Public Member Functions

 Query_expression (enum_parsing_context parsing_context)
 Construct and initialize Query_expression object. More...
 
bool is_simple () const
 
Query_blockglobal_parameters () const
 Pointer to query block containing global parameters for query. More...
 
bool is_mergeable () const
 Return true if query expression can be merged into an outer query, based on technical constraints. More...
 
bool merge_heuristic (const LEX *lex) const
 True if heuristics suggest to merge this query expression. More...
 
Query_blockouter_query_block () const
 
Query_blockfirst_query_block () const
 
Query_expressionnext_query_expression () const
 
Query_resultquery_result () const
 
RowIteratorroot_iterator () const
 
unique_ptr_destroy_only< RowIteratorrelease_root_iterator ()
 
AccessPathroot_access_path () const
 
void change_to_access_path_without_in2exists (THD *thd)
 
void clear_root_access_path ()
 
bool force_create_iterators (THD *thd)
 Ensures that there are iterators created for the access paths created by optimize(), even if it was called with create_access_paths = false. More...
 
bool unfinished_materialization () const
 See optimize(). More...
 
Mem_root_array< MaterializePathParameters::QueryBlockrelease_query_blocks_to_materialize ()
 See optimize(). More...
 
void set_query_result (Query_result *res)
 Set new query result object for this query expression. More...
 
bool can_materialize_directly_into_result () const
 Whether there is a chance that optimize() is capable of materializing directly into a result table if given one. More...
 
bool prepare (THD *thd, Query_result *result, mem_root_deque< Item * > *insert_field_list, ulonglong added_options, ulonglong removed_options)
 Prepares all query blocks of a query expression, including fake_query_block. More...
 
bool optimize (THD *thd, TABLE *materialize_destination, bool create_iterators, bool finalize_access_paths)
 If and only if materialize_destination is non-nullptr, it means that the caller intends to materialize our result into the given table. More...
 
bool finalize (THD *thd)
 For any non-finalized query block, finalize it so that we are allowed to create iterators. More...
 
bool ClearForExecution (THD *thd)
 Do everything that would be needed before running Init() on the root iterator. More...
 
bool ExecuteIteratorQuery (THD *thd)
 
bool execute (THD *thd)
 Execute a query expression that may be a UNION and/or have an ordered result. More...
 
bool explain (THD *explain_thd, const THD *query_thd)
 Explain query starting from this unit. More...
 
void cleanup (THD *thd, bool full)
 Cleanup this query expression object after preparation or one round of execution. More...
 
void destroy ()
 Destroy contained objects, in particular temporary tables which may have their own mem_roots. More...
 
void print (const THD *thd, String *str, enum_query_type query_type)
 
bool accept (Select_lex_visitor *visitor)
 
bool add_fake_query_block (THD *thd)
 Create a fake Query_block for a unit. More...
 
bool prepare_fake_query_block (THD *thd)
 Prepare the fake_query_block query block. More...
 
void set_prepared ()
 
void set_optimized ()
 
void set_executed ()
 
void reset_executed ()
 Reset this query expression for repeated evaluation within same execution. More...
 
void clear_execution ()
 Clear execution state, needed before new execution of prepared statement. More...
 
bool is_prepared () const
 Check state of preparation of the contained query expression. More...
 
bool is_optimized () const
 Check state of optimization of the contained query expression. More...
 
bool is_executed () const
 Check state of execution of the contained query expression. More...
 
bool change_query_result (THD *thd, Query_result_interceptor *result, Query_result_interceptor *old_result)
 Change the query result object used to return the final result of the unit, replacing occurences of old_result with new_result. More...
 
bool set_limit (THD *thd, Query_block *provider)
 Set limit and offset for query expression object. More...
 
bool is_union () const
 
bool union_needs_tmp_table (LEX *lex)
 Decide if a temporary table is needed for the UNION. More...
 
bool mixed_union_operators () const
 
void include_down (LEX *lex, Query_block *outer)
 Include a query expression below a query block. More...
 
void exclude_level ()
 Exclude this unit and immediately contained query_block objects. More...
 
void exclude_tree (THD *thd)
 Exclude subtree of current unit from tree of SELECTs. More...
 
void renumber_selects (LEX *lex)
 Renumber query blocks of a query expression according to supplied LEX. More...
 
void restore_cmd_properties ()
 Loop over all query blocks and restore information needed for optimization, including binding data for all associated tables. More...
 
bool save_cmd_properties (THD *thd)
 Save prepared statement properties for a query expression and underlying query blocks. More...
 
mem_root_deque< Item * > * get_unit_column_types ()
 Get column type information for this query expression. More...
 
mem_root_deque< Item * > * get_field_list ()
 Get field list for this query expression. More...
 
size_t num_visible_fields () const
 
enum_parsing_context get_explain_marker (const THD *thd) const
 
void set_explain_marker (THD *thd, enum_parsing_context m)
 
void set_explain_marker_from (THD *thd, const Query_expression *u)
 
void assert_not_fully_clean ()
 Asserts that none of {this unit and its children units} is fully cleaned up. More...
 
void invalidate ()
 Invalidate by nulling out pointers to other Query_expressions and Query_blockes. More...
 
bool is_recursive () const
 
bool check_materialized_derived_query_blocks (THD *thd)
 Sets up query blocks belonging to the query expression of a materialized derived table. More...
 
bool clear_correlated_query_blocks ()
 Empties all correlated query blocks defined within the query expression; that is, correlated CTEs defined in the expression's WITH clause, and correlated derived tables. More...
 
void fix_after_pullout (Query_block *parent_query_block, Query_block *removed_query_block)
 Fix used tables information for a subquery after query transformations. More...
 
void accumulate_used_tables (table_map map)
 If unit is a subquery, which forms an object of the upper level (an Item_subselect, a derived TABLE_LIST), adds to this object a map of tables of the upper level which the unit references. More...
 
enum_parsing_context place () const
 If unit is a subquery, which forms an object of the upper level (an Item_subselect, a derived TABLE_LIST), returns the place of this object in the upper level query block. More...
 
bool walk (Item_processor processor, enum_walk walk, uchar *arg)
 

Public Attributes

uint8 uncacheable
 result of this query can't be cached, bit field, can be : UNCACHEABLE_DEPENDENT UNCACHEABLE_RAND UNCACHEABLE_SIDEEFFECT More...
 
enum_clean_state cleaned
 cleanliness state More...
 
mem_root_deque< Item * > item_list
 
ha_rows select_limit_cnt
 
ha_rows offset_limit_cnt
 
Item_subselectitem
 Points to subquery if this query expression is used in one, otherwise NULL. More...
 
Query_blockfake_query_block
 Helper query block for query expression with UNION or multi-level ORDER BY/LIMIT. More...
 
Query_blocksaved_fake_query_block
 Query_block that stores LIMIT and OFFSET for UNION ALL when no fake_query_block is used. More...
 
Query_blockunion_distinct
 Points to last query block which has UNION DISTINCT on its left. More...
 
PT_with_clausem_with_clause
 The WITH clause which is the first part of this query expression. More...
 
TABLE_LISTderived_table
 If this query expression is underlying of a derived table, the derived table. More...
 
Query_blockfirst_recursive
 First query block (in this UNION) which references the CTE. More...
 
table_map m_lateral_deps
 If 'this' is body of lateral derived table: map of tables in the same FROM clause as this derived table, and to which the derived table's body makes references. More...
 
bool got_all_recursive_rows
 True if the with-recursive algorithm has produced the complete result. More...
 
bool m_union_needs_tmp_table
 
bool m_reject_multiple_rows {false}
 This query expression represents a scalar subquery and we need a run-time check that the cardinality doesn't exceed 1. More...
 
ha_rows send_records
 

Private Member Functions

Mem_root_array< MaterializePathParameters::QueryBlocksetup_materialization (THD *thd, TABLE *dst_table, bool union_distinct_only)
 Sets up each query block in this query expression for materialization into the given table. More...
 
void create_access_paths (THD *thd)
 Convert the executor structures to a set of access paths, storing the result in m_root_access_path. More...
 

Private Attributes

Query_expressionnext
 Intrusive double-linked list of all query expressions immediately contained within the same query block. More...
 
Query_expression ** prev
 
Query_blockmaster
 The query block wherein this query expression is contained, NULL if the query block is the outer-most one. More...
 
Query_blockslave
 The first query block in this query expression. More...
 
enum_parsing_context explain_marker
 Marker for subqueries in WHERE, HAVING, ORDER BY, GROUP BY and SELECT item lists. More...
 
bool prepared
 All query blocks in query expression are prepared. More...
 
bool optimized
 All query blocks in query expression are optimized. More...
 
bool executed
 Query expression has been executed. More...
 
TABLE_LIST result_table_list {}
 
Query_result_unionunion_result
 
TABLEtable
 Temporary table using for appending UNION results. More...
 
Query_resultm_query_result
 Object to which the result for this query expression is sent. More...
 
unique_ptr_destroy_only< RowIteratorm_root_iterator
 An iterator you can read from to get all records for this query. More...
 
AccessPathm_root_access_path = nullptr
 
Mem_root_array< MaterializePathParameters::QueryBlockm_query_blocks_to_materialize
 If there is an unfinished materialization (see optimize()), contains one element for each query block in this query expression. More...
 
mem_root_deque< Item * > types
 

Friends

class Query_block
 
bool parse_view_definition (THD *thd, TABLE_LIST *view_ref)
 Parse a view definition. More...
 

Detailed Description

This class represents a query expression (one query block or several query blocks combined with UNION).

Member Enumeration Documentation

◆ enum_clean_state

Values for Query_expression::cleaned.

Enumerator
UC_DIRTY 

Unit isn't cleaned.

UC_PART_CLEAN 

Unit were cleaned, except JOIN and JOIN_TABs were kept for possible EXPLAIN.

UC_CLEAN 

Unit completely cleaned, all underlying JOINs were freed.

Constructor & Destructor Documentation

◆ Query_expression()

Query_expression::Query_expression ( enum_parsing_context  parsing_context)
explicit

Construct and initialize Query_expression object.

Member Function Documentation

◆ accept()

bool Query_expression::accept ( Select_lex_visitor visitor)

◆ accumulate_used_tables()

void Query_expression::accumulate_used_tables ( table_map  map)

If unit is a subquery, which forms an object of the upper level (an Item_subselect, a derived TABLE_LIST), adds to this object a map of tables of the upper level which the unit references.

◆ assert_not_fully_clean()

void Query_expression::assert_not_fully_clean ( )

Asserts that none of {this unit and its children units} is fully cleaned up.

◆ can_materialize_directly_into_result()

bool Query_expression::can_materialize_directly_into_result ( ) const

Whether there is a chance that optimize() is capable of materializing directly into a result table if given one.

Note that even if this function returns true, optimize() can choose later not to do so, since it depends on information (in particular, whether the query blocks can run under the iterator executor or not) that is not available before optimize time.

TODO(sgunders): Now that all query blocks can run under the iterator executor, the above may no longer be true. This needs investigation.

◆ change_query_result()

bool Query_expression::change_query_result ( THD thd,
Query_result_interceptor new_result,
Query_result_interceptor old_result 
)

Change the query result object used to return the final result of the unit, replacing occurences of old_result with new_result.

Parameters
thdThread handle
new_resultNew query result object
old_resultOld query result object
Return values
falseSuccess
trueError

◆ change_to_access_path_without_in2exists()

void Query_expression::change_to_access_path_without_in2exists ( THD thd)

◆ check_materialized_derived_query_blocks()

bool Query_expression::check_materialized_derived_query_blocks ( THD thd_arg)

Sets up query blocks belonging to the query expression of a materialized derived table.

Parameters
thd_argTHD pointer
Returns
false if successful, true if error

◆ cleanup()

void Query_expression::cleanup ( THD thd,
bool  full 
)

Cleanup this query expression object after preparation or one round of execution.

After the cleanup, the object can be reused for a new round of execution, but a new optimization will be needed before the execution.

◆ clear_correlated_query_blocks()

bool Query_expression::clear_correlated_query_blocks ( )

Empties all correlated query blocks defined within the query expression; that is, correlated CTEs defined in the expression's WITH clause, and correlated derived tables.

◆ clear_execution()

void Query_expression::clear_execution ( )
inline

Clear execution state, needed before new execution of prepared statement.

◆ clear_root_access_path()

void Query_expression::clear_root_access_path ( )
inline

◆ ClearForExecution()

bool Query_expression::ClearForExecution ( THD thd)

Do everything that would be needed before running Init() on the root iterator.

In particular, clear out data from previous execution iterations, if needed.

◆ create_access_paths()

void Query_expression::create_access_paths ( THD thd)
private

Convert the executor structures to a set of access paths, storing the result in m_root_access_path.

◆ destroy()

void Query_expression::destroy ( )

Destroy contained objects, in particular temporary tables which may have their own mem_roots.

◆ exclude_level()

void Query_expression::exclude_level ( )

Exclude this unit and immediately contained query_block objects.

Exclude this unit and its immediately contained query_block objects from query expression / query block chain.

Note
Units that belong to the query_block objects of the current unit will be brought up one level and will replace the current unit in the list of units.

◆ exclude_tree()

void Query_expression::exclude_tree ( THD thd)

Exclude subtree of current unit from tree of SELECTs.

◆ execute()

bool Query_expression::execute ( THD thd)

Execute a query expression that may be a UNION and/or have an ordered result.

Parameters
thdthread handle
Returns
false if success, true if error

◆ ExecuteIteratorQuery()

bool Query_expression::ExecuteIteratorQuery ( THD thd)

◆ explain()

bool Query_expression::explain ( THD explain_thd,
const THD query_thd 
)

Explain query starting from this unit.

Parameters
explain_thdthread handle for the connection doing explain
query_thdthread handle for the connection being explained
Returns
false if success, true if error

◆ finalize()

bool Query_expression::finalize ( THD thd)

For any non-finalized query block, finalize it so that we are allowed to create iterators.

Must be called after the final access path is chosen (ie., after any calls to change_to_access_path_without_in2exists()).

◆ first_query_block()

Query_block* Query_expression::first_query_block ( ) const
inline
Returns
the first query block inside this query expression

◆ force_create_iterators()

bool Query_expression::force_create_iterators ( THD thd)

Ensures that there are iterators created for the access paths created by optimize(), even if it was called with create_access_paths = false.

If there are already iterators, it is a no-op. optimize() must have been called earlier.

The use case for this is if we have a query block that's not top-level, but we figure out after the fact that we wanted to run it anyway. The typical case would be that we notice that the query block can return at most one row (a so-called const table), and want to run it during optimization.

◆ get_explain_marker()

enum_parsing_context Query_expression::get_explain_marker ( const THD thd) const

◆ get_field_list()

mem_root_deque< Item * > * Query_expression::get_field_list ( )

Get field list for this query expression.

For a UNION of query blocks, return the field list generated during prepare. For a single query block, return the field list after all possible intermediate query processing steps are done (optimization is complete).

Returns
List containing fields of the query expression.

◆ get_unit_column_types()

mem_root_deque< Item * > * Query_expression::get_unit_column_types ( )

Get column type information for this query expression.

For a single query block the column types are taken from the list of selected items of this block.

For a union this function assumes that the type holders were created for unioned column types of all query blocks, by Query_expression::prepare().

Note
The implementation of this function should be in sync with Query_expression::prepare()
Returns
List of items as specified in function description. May contain hidden fields (item->hidden = true), so the caller needs to be able to filter them out.

◆ global_parameters()

Query_block* Query_expression::global_parameters ( ) const
inline

Pointer to query block containing global parameters for query.

Global parameters may include ORDER BY, LIMIT and OFFSET.

If this is a union of multiple query blocks, the global parameters are stored in fake_query_block. If the union doesn't use a temporary table, Query_expression::prepare() nulls out fake_query_block, but saves a copy in saved_fake_query_block in order to preserve the global parameters.

If this is not a union, and the query expression has no multi-level ORDER BY/LIMIT, global parameters are in the single query block.

Returns
query block containing the global parameters

◆ include_down()

void Query_expression::include_down ( LEX lex,
Query_block outer 
)

Include a query expression below a query block.

Parameters
lexContaining LEX object
outerThe query block that this query expression is included below.

◆ invalidate()

void Query_expression::invalidate ( )

Invalidate by nulling out pointers to other Query_expressions and Query_blockes.

◆ is_executed()

bool Query_expression::is_executed ( ) const
inline

Check state of execution of the contained query expression.

Should not be used to check the state of a complete statement, use LEX::is_exec_completed() instead.

◆ is_mergeable()

bool Query_expression::is_mergeable ( ) const

Return true if query expression can be merged into an outer query, based on technical constraints.

Returns
true if query expression can be merged into an outer query

Being mergeable also means that derived table/view is updatable.

A view/derived table is not mergeable if it is one of the following:

  • A union (implementation restriction).
  • An aggregated query, or has HAVING, or has DISTINCT (A general aggregated query cannot be merged with a non-aggregated one).
  • A table-less query (unimportant special case).
  • A query with a LIMIT (limit applies to subquery, so the implementation strategy is to materialize this subquery, including row count constraint).
  • It has windows

◆ is_optimized()

bool Query_expression::is_optimized ( ) const
inline

Check state of optimization of the contained query expression.

◆ is_prepared()

bool Query_expression::is_prepared ( ) const
inline

Check state of preparation of the contained query expression.

◆ is_recursive()

bool Query_expression::is_recursive ( ) const
inline

◆ is_simple()

bool Query_expression::is_simple ( ) const
inline
Returns
true for a query expression without UNION or multi-level ORDER

◆ merge_heuristic()

bool Query_expression::merge_heuristic ( const LEX lex) const

True if heuristics suggest to merge this query expression.

Returns
true if query expression is recommended to be merged

A view/derived table is not suggested for merging if it contains subqueries in the SELECT list that depend on columns from itself. Merging such objects is possible, but we assume they are made derived tables because the user wants them to be materialized, for performance reasons.

One possible case is a derived table with dependent subqueries in the select list, used as the inner table of a left outer join. Such tables will always be read as many times as there are qualifying rows in the outer table, and the select list subqueries are evaluated for each row combination. The select list subqueries are evaluated the same number of times also with join buffering enabled, even though the table then only will be read once.

Another case is, a query that modifies variables: then try to preserve the original structure of the query. This is less likely to cause changes in variable assignment order.

◆ mixed_union_operators()

bool Query_expression::mixed_union_operators ( ) const
Returns
true if mixes UNION DISTINCT and UNION ALL

◆ next_query_expression()

Query_expression* Query_expression::next_query_expression ( ) const
inline
Returns
the next query expression within same query block (next subquery)

◆ num_visible_fields()

size_t Query_expression::num_visible_fields ( ) const

◆ optimize()

bool Query_expression::optimize ( THD thd,
TABLE materialize_destination,
bool  create_iterators,
bool  finalize_access_paths 
)

If and only if materialize_destination is non-nullptr, it means that the caller intends to materialize our result into the given table.

If it is advantageous (in particular, if this query expression is a UNION DISTINCT), optimize() will not create an iterator by itself, but rather do an unfinished materialize. This means that it will collect iterators for all the query blocks and prepare them for materializing into the given table, but not actually create a root iterator for this query expression; the caller is responsible for calling release_query_blocks_to_materialize() and creating the iterator itself.

Even if materialize_destination is non-nullptr, this function may choose to make a regular iterator. The caller is responsible for checking unfinished_materialization() if it has given a non-nullptr table.

Parameters
thdThread handle.
materialize_destinationWhat table to try to materialize into, or nullptr if the caller does not intend to materialize the result.
create_iteratorsIf false, only access paths are created, not iterators. Only top level query blocks (these that we are to call exec() on) should have iterators. See also force_create_iterators().
finalize_access_pathsRelevant for the hypergraph optimizer only. If false, the given access paths will not be finalized, so you cannot create iterators from it before finalize() is called (see FinalizePlanForQueryBlock()), and create_iterators must also be false. This is relevant only if you are potentially optimizing multiple times (see change_to_access_path_without_in2exists()), since you are only allowed to finalize a query block once. The fake_query_block, if any, is always finalized.

◆ outer_query_block()

Query_block* Query_expression::outer_query_block ( ) const
inline
Returns
the query block this query expression belongs to as subquery

◆ place()

enum_parsing_context Query_expression::place ( ) const

If unit is a subquery, which forms an object of the upper level (an Item_subselect, a derived TABLE_LIST), returns the place of this object in the upper level query block.

◆ prepare()

bool Query_expression::prepare ( THD thd,
Query_result sel_result,
mem_root_deque< Item * > *  insert_field_list,
ulonglong  added_options,
ulonglong  removed_options 
)

Prepares all query blocks of a query expression, including fake_query_block.

If a recursive query expression, this also creates the materialized temporary table.

Parameters
thdThread handler
sel_resultResult object where the unit's output should go.
insert_field_listPointer to field list if INSERT op, NULL otherwise.
added_optionsThese options will be added to the query blocks.
removed_optionsOptions that cannot be used for this query
Returns
false if success, true if error

◆ prepare_fake_query_block()

bool Query_expression::prepare_fake_query_block ( THD thd_arg)

Prepare the fake_query_block query block.

Parameters
thd_argThread handler
Returns
false if success, true if error

◆ print()

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

◆ query_result()

Query_result* Query_expression::query_result ( ) const
inline
Returns
the query result object in use for this query expression

◆ release_query_blocks_to_materialize()

Mem_root_array<MaterializePathParameters::QueryBlock> Query_expression::release_query_blocks_to_materialize ( )
inline

See optimize().

◆ release_root_iterator()

unique_ptr_destroy_only<RowIterator> Query_expression::release_root_iterator ( )
inline

◆ renumber_selects()

void Query_expression::renumber_selects ( LEX lex)

Renumber query blocks of a query expression according to supplied LEX.

Renumber contained query_block objects.

Parameters
lexContaining LEX object

◆ reset_executed()

void Query_expression::reset_executed ( )
inline

Reset this query expression for repeated evaluation within same execution.

◆ restore_cmd_properties()

void Query_expression::restore_cmd_properties ( )

Loop over all query blocks and restore information needed for optimization, including binding data for all associated tables.

◆ root_access_path()

AccessPath* Query_expression::root_access_path ( ) const
inline

◆ root_iterator()

RowIterator* Query_expression::root_iterator ( ) const
inline

◆ save_cmd_properties()

bool Query_expression::save_cmd_properties ( THD thd)

Save prepared statement properties for a query expression and underlying query blocks.

Required for repeated optimizations of the command.

Parameters
thdthread handler
Returns
false if success, true if error (out of memory)

◆ set_executed()

void Query_expression::set_executed ( )
inline

◆ set_explain_marker()

void Query_expression::set_explain_marker ( THD thd,
enum_parsing_context  m 
)

◆ set_explain_marker_from()

void Query_expression::set_explain_marker_from ( THD thd,
const Query_expression u 
)

◆ set_limit()

bool Query_expression::set_limit ( THD thd,
Query_block provider 
)

Set limit and offset for query expression object.

Parameters
thdthread handler
providerQuery_block to get offset and limit from.
Returns
false if success, true if error

◆ set_optimized()

void Query_expression::set_optimized ( )
inline

◆ set_prepared()

void Query_expression::set_prepared ( )
inline

◆ set_query_result()

void Query_expression::set_query_result ( Query_result res)
inline

Set new query result object for this query expression.

◆ setup_materialization()

Mem_root_array< MaterializePathParameters::QueryBlock > Query_expression::setup_materialization ( THD thd,
TABLE dst_table,
bool  union_distinct_only 
)
private

Sets up each query block in this query expression for materialization into the given table.

Parameters
thdthread handle
dst_tablethe table to materialize into
union_distinct_onlyif true, keep only UNION DISTINCT query blocks (any UNION ALL blocks are presumed handled higher up, by AppendIterator)

◆ unfinished_materialization()

bool Query_expression::unfinished_materialization ( ) const
inline

See optimize().

◆ union_needs_tmp_table()

bool Query_expression::union_needs_tmp_table ( LEX lex)

Decide if a temporary table is needed for the UNION.

Return values
trueA temporary table is needed.
falseA temporary table is not needed.

◆ walk()

bool Query_expression::walk ( Item_processor  processor,
enum_walk  walk,
uchar arg 
)

Friends And Related Function Documentation

◆ parse_view_definition

bool parse_view_definition ( THD thd,
TABLE_LIST view_ref 
)
friend

Parse a view definition.

Among other effects, it adds underlying tables to the global list of tables, so the next iteration in open_tables() will open them.

Parameters
[in]thdThread handler
[in,out]view_refTABLE_LIST structure for view reference
Returns
false-in case of success, true-in case of error.
Note
In case true value returned an error has been already set in DA.

◆ Query_block

friend class Query_block
friend

Member Data Documentation

◆ cleaned

enum_clean_state Query_expression::cleaned

cleanliness state

◆ derived_table

TABLE_LIST* Query_expression::derived_table

If this query expression is underlying of a derived table, the derived table.

NULL if none.

◆ executed

bool Query_expression::executed
private

Query expression has been executed.

◆ explain_marker

enum_parsing_context Query_expression::explain_marker
private

Marker for subqueries in WHERE, HAVING, ORDER BY, GROUP BY and SELECT item lists.

Must be read/written when holding LOCK_query_plan.

See Item_subselect::explain_subquery_checker

◆ fake_query_block

Query_block* Query_expression::fake_query_block

Helper query block for query expression with UNION or multi-level ORDER BY/LIMIT.

◆ first_recursive

Query_block* Query_expression::first_recursive

First query block (in this UNION) which references the CTE.

NULL if not the query expression of a recursive CTE.

◆ got_all_recursive_rows

bool Query_expression::got_all_recursive_rows

True if the with-recursive algorithm has produced the complete result.

In a recursive CTE, a JOIN is executed several times in a loop, and should not be cleaned up (e.g. by join_free()) before all iterations of the loop are done (i.e. before the CTE's result is complete).

◆ item

Item_subselect* Query_expression::item

Points to subquery if this query expression is used in one, otherwise NULL.

◆ item_list

mem_root_deque<Item *> Query_expression::item_list

◆ m_lateral_deps

table_map Query_expression::m_lateral_deps

If 'this' is body of lateral derived table: map of tables in the same FROM clause as this derived table, and to which the derived table's body makes references.

In pre-resolution stages, this is OUTER_REF_TABLE_BIT, just to indicate that this has LATERAL; after resolution, which has found references in the body, this is the proper map (with no PSEUDO_TABLE_BITS anymore).

◆ m_query_blocks_to_materialize

Mem_root_array<MaterializePathParameters::QueryBlock> Query_expression::m_query_blocks_to_materialize
private

If there is an unfinished materialization (see optimize()), contains one element for each query block in this query expression.

◆ m_query_result

Query_result* Query_expression::m_query_result
private

Object to which the result for this query expression is sent.

Not used if we materialize directly into a parent query expression's result table (see optimize()).

◆ m_reject_multiple_rows

bool Query_expression::m_reject_multiple_rows {false}

This query expression represents a scalar subquery and we need a run-time check that the cardinality doesn't exceed 1.

◆ m_root_access_path

AccessPath* Query_expression::m_root_access_path = nullptr
private

◆ m_root_iterator

unique_ptr_destroy_only<RowIterator> Query_expression::m_root_iterator
private

An iterator you can read from to get all records for this query.

May be nullptr even after create_access_paths(), or in the case of an unfinished materialization (see optimize()).

◆ m_union_needs_tmp_table

bool Query_expression::m_union_needs_tmp_table

◆ m_with_clause

PT_with_clause* Query_expression::m_with_clause

The WITH clause which is the first part of this query expression.

NULL if none.

◆ master

Query_block* Query_expression::master
private

The query block wherein this query expression is contained, NULL if the query block is the outer-most one.

◆ next

Query_expression* Query_expression::next
private

Intrusive double-linked list of all query expressions immediately contained within the same query block.

◆ offset_limit_cnt

ha_rows Query_expression::offset_limit_cnt

◆ optimized

bool Query_expression::optimized
private

All query blocks in query expression are optimized.

◆ prepared

bool Query_expression::prepared
private

All query blocks in query expression are prepared.

◆ prev

Query_expression** Query_expression::prev
private

◆ result_table_list

TABLE_LIST Query_expression::result_table_list {}
private

◆ saved_fake_query_block

Query_block* Query_expression::saved_fake_query_block

Query_block that stores LIMIT and OFFSET for UNION ALL when no fake_query_block is used.

◆ select_limit_cnt

ha_rows Query_expression::select_limit_cnt

◆ send_records

ha_rows Query_expression::send_records

◆ slave

Query_block* Query_expression::slave
private

The first query block in this query expression.

◆ table

TABLE* Query_expression::table
private

Temporary table using for appending UNION results.

Not used if we materialize directly into a parent query expression's result table (see optimize()).

◆ types

mem_root_deque<Item *> Query_expression::types
private

◆ uncacheable

uint8 Query_expression::uncacheable

result of this query can't be cached, bit field, can be : UNCACHEABLE_DEPENDENT UNCACHEABLE_RAND UNCACHEABLE_SIDEEFFECT

◆ union_distinct

Query_block* Query_expression::union_distinct

Points to last query block which has UNION DISTINCT on its left.

In a list of UNIONed blocks, UNION is left-associative; so UNION DISTINCT eliminates duplicates in all blocks up to the first one on its right included. Which is why we only need to remember that query block.

◆ union_result

Query_result_union* Query_expression::union_result
private

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