MySQL 8.3.0
Source Code Documentation
PT_common_table_expr Class Reference

Represents an element of the WITH list: WITH [...], [...] SELECT ..., ^ or ^ i.e. More...

#include <parse_tree_nodes.h>

Inheritance diagram for PT_common_table_expr:
[legend]

Public Member Functions

 PT_common_table_expr (const POS &pos, const LEX_STRING &name, const LEX_STRING &subq_text, uint subq_text_offset, PT_subquery *sn, const Create_col_name_list *column_names, MEM_ROOT *mem_root)
 
const LEX_STRINGname () const
 The name after AS. More...
 
bool make_subquery_node (THD *thd, PT_subquery **node)
 
bool match_table_ref (Table_ref *tl, bool in_self, bool *found)
 
bool is (const Common_table_expr *other) const
 
void print (const THD *thd, String *str, enum_query_type query_type)
 
bool do_contextualize (Parse_context *pc) override
 
- 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 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 Parse_tree_node super
 

Private Attributes

LEX_STRING m_name
 
const LEX_STRING m_subq_text
 Raw text of query expression (including parentheses) More...
 
uint m_subq_text_offset
 Offset in bytes of m_subq_text in original statement which had the WITH clause. More...
 
PT_subquery *const m_subq_node
 Parsed version of subq_text. More...
 
const Create_col_name_list m_column_names
 List of explicitly specified column names; if empty, no list. More...
 
Common_table_expr m_postparse
 A Table_ref representing a CTE needs access to the WITH list element it derives from. More...
 

Friends

bool Query_expression::clear_correlated_query_blocks ()
 

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
 

Detailed Description

Represents an element of the WITH list: WITH [...], [...] SELECT ..., ^ or ^ i.e.

a Common Table Expression (CTE, or Query Name in SQL99 terms).

Member Typedef Documentation

◆ super

Constructor & Destructor Documentation

◆ PT_common_table_expr()

PT_common_table_expr::PT_common_table_expr ( const POS pos,
const LEX_STRING name,
const LEX_STRING subq_text,
uint  subq_text_offset,
PT_subquery sn,
const Create_col_name_list column_names,
MEM_ROOT mem_root 
)
explicit

Member Function Documentation

◆ add_json_info()

void PT_common_table_expr::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 >.

◆ do_contextualize()

bool PT_common_table_expr::do_contextualize ( Parse_context pc)
override

◆ is()

bool PT_common_table_expr::is ( const Common_table_expr other) const
inline
Returns
true if 'other' is the same instance as 'this'

◆ name()

const LEX_STRING & PT_common_table_expr::name ( ) const
inline

The name after AS.

◆ print()

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

Friends And Related Function Documentation

◆ Query_expression::clear_correlated_query_blocks

Member Data Documentation

◆ m_column_names

const Create_col_name_list PT_common_table_expr::m_column_names
private

List of explicitly specified column names; if empty, no list.

◆ m_name

LEX_STRING PT_common_table_expr::m_name
private

◆ m_postparse

Common_table_expr PT_common_table_expr::m_postparse
private

A Table_ref representing a CTE needs access to the WITH list element it derives from.

However, in order to:

  • limit the members which Table_ref can access
  • avoid including this header file everywhere Table_ref needs to access these members, these members are relocated into a separate inferior object whose declaration is in table.h, like that of Table_ref. It's the "postparse" part. Table_ref accesses this inferior object only.

◆ m_subq_node

PT_subquery* const PT_common_table_expr::m_subq_node
private

Parsed version of subq_text.

◆ m_subq_text

const LEX_STRING PT_common_table_expr::m_subq_text
private

Raw text of query expression (including parentheses)

◆ m_subq_text_offset

uint PT_common_table_expr::m_subq_text_offset
private

Offset in bytes of m_subq_text in original statement which had the WITH clause.


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