MySQL 8.0.32
Source Code Documentation
Query_term_set_op Class Reference

Common base class for n-ary set operations, including unary. More...

#include <query_term.h>

Inheritance diagram for Query_term_set_op:
[legend]

Public Member Functions

Query_blockquery_block () const override
 Getter for m_block, q.v. More...
 
bool set_block (Query_block *b)
 Setter for m_block, q.v. More...
 
size_t child_count () const override
 Get the number of children this node has. More...
 
bool open_result_tables (THD *thd, int level) override
 Open tmp tables for the tree of set operation query results, by recursing. More...
 
void cleanup (bool full) override
 Reset resources used. More...
 
void destroy_tree () override
 Destroy the query term tree structure. More...
 
bool has_mixed_distinct_operators ()
 Check if this set operation has a mix of DISTINCT and ALL. More...
 
bool is_unary () const
 Check if this term is a unary set operation. More...
 
Mem_root_array< MaterializePathParameters::QueryBlocksetup_materialize_set_op (THD *thd, TABLE *dst_table, bool union_distinct_only, bool calc_found_rows)
 Sets up each(*) query block in this query expression for materialization into the given table by making a materialization parameter for each block (*) modulo union_distinct_only. More...
 
- Public Member Functions inherited from Query_term
Query_termpushdown_limit_order_by (Query_term_set_op *parent=nullptr)
 Called after contextualization to simplify query, c.f. More...
 
bool validate_structure (const Query_term *parent, int depth=0) const
 Return true if structure is too deep, i.e. More...
 
std::pair< bool, bool > redundant_order_by (Query_block *block, int level)
 Determine if we have a redundant ORDER BY in block. More...
 
virtual Query_term_type term_type () const =0
 Get the node tree type. More...
 
virtual const char * operator_string () const =0
 Get the node type description. More...
 
virtual ~Query_term ()=default
 Node destructor. More...
 
Query_term_set_opparent () const
 Getter for m_parent, q.v. More...
 
virtual void debugPrint (int level, std::ostringstream &buf) const =0
 Print the tree rooted at this node to buf. More...
 
void printPointers (std::ostringstream &buf) const
 Print the pointer of this node and its parent to buf. More...
 
void set_setop_query_result (Query_result *rs)
 Setter for m_setop_query_result, q.v. More...
 
Query_resultsetop_query_result ()
 Getter for m_setop_query_result, q.v. More...
 
Query_result_unionsetop_query_result_union ()
 Getter for m_setop_query_result, q.v. Use only if we can down cast. More...
 
void cleanup_query_result (bool full)
 Cleanup m_setop_query_result, q.v. More...
 
void set_owning_operand ()
 Setter for m_owning_operand, q.v. More...
 
bool owning_operand ()
 Getter for m_owning_operand, q.v. More...
 
void set_result_table (Table_ref *tl)
 Setter for m_result_table, q.v. More...
 
Table_refresult_table ()
 Getter for m_result_table, q.v. More...
 
void set_fields (mem_root_deque< Item * > *fields)
 
mem_root_deque< Item * > * fields ()
 

Public Attributes

mem_root_deque< Query_term * > m_children
 Tree structure. More...
 
int64_t m_last_distinct
 Index of last query expression which has <set-op> DISTINCT on its left. More...
 
int64_t m_first_distinct
 Presently only needed by EXCEPT set operator: the index of the first DISTINCT set operand: minimum legal value is 1. More...
 
bool m_is_materialized {true}
 true if the result of this set operation is materialized. More...
 

Protected Member Functions

 Query_term_set_op (MEM_ROOT *mem_root)
 
void print (int level, std::ostringstream &buf, const char *type) const
 Common printing minion for set operations. More...
 

Private Attributes

Query_blockm_block {nullptr}
 Replaces the old "fake" query block for post processing result set with ORDER BY, LIMIT. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from Query_term
static void indent (int level, std::ostringstream &buf)
 Print blank space indentation (unit: two) to buf according to level. More...
 
static void print_order (const THD *thd, String *str, ORDER *ord, enum_query_type query_type)
 Print into str the order indicated in ord, using standard print_for_order Used by traditional explain. More...
 
- Protected Attributes inherited from Query_term
Query_term_set_opm_parent {nullptr}
 Back pointer to the node whose child we are, or nullptr (root term). More...
 
Query_resultm_setop_query_result {nullptr}
 The query result for this term. More...
 
bool m_owning_operand {false}
 The operand of a n-ary set operation (that owns the common query result) has this set to true. More...
 
Table_refm_result_table {nullptr}
 Result temporary table for the set operation, if applicable. More...
 
mem_root_deque< Item * > * m_fields {nullptr}
 Used only when streaming, i.e. More...
 

Detailed Description

Common base class for n-ary set operations, including unary.

Constructor & Destructor Documentation

◆ Query_term_set_op()

Query_term_set_op::Query_term_set_op ( MEM_ROOT mem_root)
inlineprotected

Member Function Documentation

◆ child_count()

size_t Query_term_set_op::child_count ( ) const
inlineoverridevirtual

Get the number of children this node has.

Returns
the number

Reimplemented from Query_term.

◆ cleanup()

void Query_term_set_op::cleanup ( bool  full)
overridevirtual

Reset resources used.

Parameters
fulldo full cleanup. Same semantics as for Query_expression's cleanup

Reimplemented from Query_term.

◆ destroy_tree()

void Query_term_set_op::destroy_tree ( )
inlineoverridevirtual

Destroy the query term tree structure.

Implements Query_term.

◆ has_mixed_distinct_operators()

bool Query_term_set_op::has_mixed_distinct_operators ( )

Check if this set operation has a mix of DISTINCT and ALL.

Returns
true if so. Always false for unary

◆ is_unary()

bool Query_term_set_op::is_unary ( ) const
inline

Check if this term is a unary set operation.

Returns
true if so

◆ open_result_tables()

bool Query_term_set_op::open_result_tables ( THD thd,
int  level 
)
overridevirtual

Open tmp tables for the tree of set operation query results, by recursing.

Parameters
thdsession context
levellevel in the tree, top should be called with 0.
Returns
true on error

Reimplemented from Query_term.

◆ print()

void Query_term_set_op::print ( int  level,
std::ostringstream &  buf,
const char *  type 
) const
protected

Common printing minion for set operations.

Parameters
levellevel in tree
bufthe buffer to format output into
typedescriptive string of set operation to use for printing

◆ query_block()

Query_block * Query_term_set_op::query_block ( ) const
inlineoverridevirtual

Getter for m_block, q.v.

Implements Query_term.

◆ set_block()

bool Query_term_set_op::set_block ( Query_block b)
inline

Setter for m_block, q.v.

◆ setup_materialize_set_op()

Mem_root_array< MaterializePathParameters::QueryBlock > Query_term_set_op::setup_materialize_set_op ( THD thd,
TABLE dst_table,
bool  union_distinct_only,
bool  calc_found_rows 
)

Sets up each(*) query block in this query expression for materialization into the given table by making a materialization parameter for each block (*) modulo union_distinct_only.

Parameters
thdsession context
dst_tablethe table to materialize into
union_distinct_onlyif true, materialize only UNION DISTINCT query blocks (any UNION ALL blocks are presumed handled higher up, by AppendIterator)
calc_found_rowsif true, calculate rows found
Returns
array of materialization parameters

Member Data Documentation

◆ m_block

Query_block* Query_term_set_op::m_block {nullptr}
private

Replaces the old "fake" query block for post processing result set with ORDER BY, LIMIT.

The query block(s) of the query specifications can be found via m_children.

◆ m_children

mem_root_deque<Query_term *> Query_term_set_op::m_children

Tree structure.

Cardinality is one for unary, two or more for UNION, EXCEPT, INTERSECT

◆ m_first_distinct

int64_t Query_term_set_op::m_first_distinct

Presently only needed by EXCEPT set operator: the index of the first DISTINCT set operand: minimum legal value is 1.

If not DISTINCT, it should have the value std::numeric_limits<int64_t>::max(). The value is set in PT_set_operation::merge_descendants.

◆ m_is_materialized

bool Query_term_set_op::m_is_materialized {true}

true if the result of this set operation is materialized.

A priori true unless we have a pure UNION ALL.

◆ m_last_distinct

int64_t Query_term_set_op::m_last_distinct

Index of last query expression which has <set-op> DISTINCT on its left.

In a list of <set-op>ed 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. Is -1 for Unary.


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