MySQL 9.0.0
Source Code Documentation
PT_query_specification Class Reference

#include <parse_tree_nodes.h>

Inheritance diagram for PT_query_specification:
[legend]

Public Member Functions

 PT_query_specification (const POS &pos, PT_hint_list *opt_hints_arg, const Query_options &options_arg, PT_item_list *item_list_arg, PT_into_destination *opt_into1_arg, const Mem_root_array_YY< PT_table_reference * > &from_clause_arg, Item *opt_where_clause_arg, PT_group *opt_group_clause_arg, Item *opt_having_clause_arg, PT_window_list *opt_window_clause_arg, Item *opt_qualify_clause_arg, bool implicit_from_clause)
 
 PT_query_specification (const POS &pos, const Query_options &options_arg, PT_item_list *item_list_arg, const Mem_root_array_YY< PT_table_reference * > &from_clause_arg, Item *opt_where_clause_arg)
 
 PT_query_specification (const POS &pos, const Query_options &options_arg, PT_item_list *item_list_arg)
 
bool do_contextualize (Parse_context *pc) override
 
bool has_into_clause () const override
 
bool has_trailing_into_clause () const override
 
bool is_set_operation () const override
 
bool can_absorb_order_and_limit (bool, bool) const override
 True if this query expression can absorb an extraneous order by/limit clause. More...
 
bool is_table_value_constructor () const override
 
PT_insert_values_listget_row_value_list () const override
 
- Public Member Functions inherited from PT_query_expression_body
 PT_query_expression_body (const POS &pos)
 
- Public Member Functions inherited from Parse_tree_node_tmpl< Context >
virtual ~Parse_tree_node_tmpl ()=default
 
bool is_contextualized () const
 
virtual bool contextualize (Context *pc) final
 
void error (Context *pc, const POS &pos) const
 syntax_error() function replacement for deferred reporting of syntax errors More...
 
void error (Context *pc, const POS &pos, const char *msg) const
 syntax_error() function replacement for deferred reporting of syntax errors More...
 
void errorf (Context *pc, const POS &pos, const char *format,...) const
 syntax_error() function replacement for deferred reporting of syntax errors More...
 

Protected Member Functions

void add_json_info (Json_object *obj) override
 Add all the node-specific json fields. More...
 
- Protected Member Functions inherited from PT_query_primary
 PT_query_primary (const POS &pos)
 
- Protected Member Functions inherited from Parse_tree_node_tmpl< Context >
 Parse_tree_node_tmpl ()=delete
 
 Parse_tree_node_tmpl (const POS &pos)
 
 Parse_tree_node_tmpl (const POS &start_pos, const POS &end_pos)
 
bool begin_parse_tree (Show_parse_tree *tree)
 
bool end_parse_tree (Show_parse_tree *tree)
 
virtual bool do_contextualize (Context *pc)
 Do all context-sensitive things and mark the node as contextualized. More...
 

Private Types

typedef PT_query_primary super
 

Private Member Functions

bool is_implicit_from_clause () const
 

Private Attributes

PT_hint_listopt_hints
 
Query_options options
 
PT_item_listitem_list
 
PT_into_destinationopt_into1
 
const bool m_is_from_clause_implicit
 
Mem_root_array_YY< PT_table_reference * > from_clause
 
Itemopt_where_clause
 
PT_groupopt_group_clause
 
Itemopt_having_clause
 
PT_window_listopt_window_clause
 
Itemopt_qualify_clause
 

Additional Inherited Members

- Public Types inherited from Parse_tree_node_tmpl< Context >
typedef Context context_t
 
- Static Public Member Functions inherited from Parse_tree_node_tmpl< Context >
static void * operator new (size_t size, MEM_ROOT *mem_root, const std::nothrow_t &arg=std::nothrow) noexcept
 
static void operator delete (void *ptr, size_t size)
 
static void operator delete (void *, MEM_ROOT *, const std::nothrow_t &) noexcept
 
- Public Attributes inherited from Parse_tree_node_tmpl< Context >
POS m_pos
 

Member Typedef Documentation

◆ super

Constructor & Destructor Documentation

◆ PT_query_specification() [1/3]

PT_query_specification::PT_query_specification ( const POS pos,
PT_hint_list opt_hints_arg,
const Query_options options_arg,
PT_item_list item_list_arg,
PT_into_destination opt_into1_arg,
const Mem_root_array_YY< PT_table_reference * > &  from_clause_arg,
Item opt_where_clause_arg,
PT_group opt_group_clause_arg,
Item opt_having_clause_arg,
PT_window_list opt_window_clause_arg,
Item opt_qualify_clause_arg,
bool  implicit_from_clause 
)
inline

◆ PT_query_specification() [2/3]

PT_query_specification::PT_query_specification ( const POS pos,
const Query_options options_arg,
PT_item_list item_list_arg,
const Mem_root_array_YY< PT_table_reference * > &  from_clause_arg,
Item opt_where_clause_arg 
)
inline

◆ PT_query_specification() [3/3]

PT_query_specification::PT_query_specification ( const POS pos,
const Query_options options_arg,
PT_item_list item_list_arg 
)
inline

Member Function Documentation

◆ add_json_info()

void PT_query_specification::add_json_info ( Json_object json_obj)
overrideprotectedvirtual

Add all the node-specific json fields.

Any class that needs to add such info should override this function rather than doing it in do_contextualize(). E.g. the parse tree node for AVG() may have "distinct" field to indicate if AVG(DISTINCT ...) is used or not.

Parameters
json_objJson object for this parse tree node.

Reimplemented from Parse_tree_node_tmpl< Context >.

◆ can_absorb_order_and_limit()

bool PT_query_specification::can_absorb_order_and_limit ( bool  order,
bool  limit 
) const
inlineoverridevirtual

True if this query expression can absorb an extraneous order by/limit clause.

The ORDER BY/LIMIT syntax is mostly consistestent, i.e. a trailing clause may not refer to the tables in the <query primary>, with one glaring exception:

(...( SELECT ... )...) ORDER BY ...

If the nested query expression doesn't contain ORDER BY, the statement is interpreted as if the ORDER BY was absorbed by the innermost query expression, i.e.:

(...( SELECT ... ORDER BY ... )...)

There is no rewriting of the parse tree nor AST happening here, the transformation is done by the contextualizer (see PT_query_expression::contextualize_order_and_limit), which interprets the parse tree, and builds the AST according to this interpretation. This interpretation is governed by the following rule: An ORDER BY can be absorbed if none the nested query expressions contains an ORDER BY or LIMIT. The rule is complex, so here are some examples for illustration:

In these cases the ORDER BY is absorbed:

( SELECT * FROM t1 ) ORDER BY t1.a;
(( SELECT * FROM t1 )) ORDER BY t1.a;

In these cases the ORDER BY is not absorbed:

( SELECT * FROM t1 ORDER BY 1 ) ORDER BY t1.a;
(( SELECT * FROM t1 ) ORDER BY 1 ) ORDER BY t1.a;
( SELECT * FROM t1 LIMIT 1 ) ORDER BY t1.a;
(( SELECT * FROM t1 ) LIMIT 1 ) ORDER BY t1.a;

The same happens with LIMIT, obviously, but the optimizer is freeer to choose when to apply the limit, and there are name no resolution issues involved.

Parameters
orderTrue if the outer query block has the ORDER BY clause.
limitTrue if the outer query block has the LIMIT clause.

Implements PT_query_expression_body.

◆ do_contextualize()

bool PT_query_specification::do_contextualize ( Parse_context pc)
override

◆ get_row_value_list()

PT_insert_values_list * PT_query_specification::get_row_value_list ( ) const
inlineoverridevirtual

◆ has_into_clause()

bool PT_query_specification::has_into_clause ( ) const
inlineoverridevirtual

◆ has_trailing_into_clause()

bool PT_query_specification::has_trailing_into_clause ( ) const
inlineoverridevirtual

◆ is_implicit_from_clause()

bool PT_query_specification::is_implicit_from_clause ( ) const
inlineprivate

◆ is_set_operation()

bool PT_query_specification::is_set_operation ( ) const
inlineoverridevirtual

◆ is_table_value_constructor()

bool PT_query_specification::is_table_value_constructor ( ) const
inlineoverridevirtual

Member Data Documentation

◆ from_clause

Mem_root_array_YY<PT_table_reference *> PT_query_specification::from_clause
private

◆ item_list

PT_item_list* PT_query_specification::item_list
private

◆ m_is_from_clause_implicit

const bool PT_query_specification::m_is_from_clause_implicit
private

◆ opt_group_clause

PT_group* PT_query_specification::opt_group_clause
private

◆ opt_having_clause

Item* PT_query_specification::opt_having_clause
private

◆ opt_hints

PT_hint_list* PT_query_specification::opt_hints
private

◆ opt_into1

PT_into_destination* PT_query_specification::opt_into1
private

◆ opt_qualify_clause

Item* PT_query_specification::opt_qualify_clause
private

◆ opt_where_clause

Item* PT_query_specification::opt_where_clause
private

◆ opt_window_clause

PT_window_list* PT_query_specification::opt_window_clause
private

◆ options

Query_options PT_query_specification::options
private

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