MySQL 8.4.2
Source Code Documentation
parse_tree_helpers.h File Reference
#include <assert.h>
#include <sys/types.h>
#include <new>
#include "lex_string.h"
#include "my_inttypes.h"
#include "mysql/strings/m_ctype.h"
#include "mysql_time.h"
#include "sql/item.h"
#include "sql/item_func.h"
#include "sql/parse_location.h"
#include "sql/parse_tree_node_base.h"
#include "sql/resourcegroups/resource_group_basic_types.h"
#include "sql/set_var.h"
#include "sql/sql_error.h"
#include "sql/sql_list.h"

Go to the source code of this file.

Classes

class  Parse_tree_item
 Base class for parse-time Item objects. More...
 
class  PT_item_list
 Wrapper class for an Item list head, used to allocate Item lists in the parser in a context-independent way. More...
 

Functions

template<typename Context , typename Array >
bool contextualize_array (Context *pc, Array *array)
 Contextualize a Mem_root_array of parse tree nodes of the type PTN. More...
 
template<class To , Item_func::Functype Tag>
To * item_cond_cast (Item *const from)
 Helper function to imitate dynamic_cast for Item_cond hierarchy. More...
 
template<class Class , Item_func::Functype Tag>
Itemflatten_associative_operator (MEM_ROOT *mem_root, const POS &pos, Item *left, Item *right)
 Flatten associative operators at parse time. More...
 
Item_splocalcreate_item_for_sp_var (THD *thd, LEX_CSTRING name, class sp_variable *spv, const char *query_start_ptr, const char *start, const char *end)
 Create an object to represent a SP variable in the Item-hierarchy. More...
 
LEX_CSTRING make_string (THD *thd, const char *start_ptr, const char *end_ptr)
 Make a new string allocated on THD's mem-root. More...
 
void sp_create_assignment_lex (THD *thd, const char *option_ptr)
 
bool sp_create_assignment_instr (THD *thd, const char *expr_end_ptr)
 Create a SP instruction for a SET assignment. More...
 
bool resolve_engine (THD *thd, const LEX_CSTRING &name, bool is_temp_table, bool strict, handlerton **ret)
 Resolve engine by its name. More...
 
bool apply_privileges (THD *thd, const Mem_root_array< class PT_role_or_privilege * > &privs)
 This helper function is responsible for aggregating grants from parser tokens to containers and masks which can be used during semantic analysis. More...
 
bool is_identifier (const char *str, const char *ident)
 
bool is_identifier (const LEX_STRING &str, const char *ident)
 
bool validate_vcpu_range (const resourcegroups::Range &range)
 
bool validate_resource_group_priority (THD *thd, int *priority, const LEX_CSTRING &name, const resourcegroups::Type &type)
 
bool check_resource_group_support ()
 
bool check_resource_group_name_len (const LEX_CSTRING &name, Sql_condition::enum_severity_level severity)
 
void move_cf_appliers (Parse_context *tddlpc, Column_parse_context *cpc)
 

Function Documentation

◆ apply_privileges()

bool apply_privileges ( THD thd,
const Mem_root_array< class PT_role_or_privilege * > &  privs 
)

This helper function is responsible for aggregating grants from parser tokens to containers and masks which can be used during semantic analysis.

Parameters
thdThe thread handler
privsA list of parser tokens representing roles or privileges.
Returns
Error state
Return values
trueAn error occurred
falseSuccess

◆ check_resource_group_name_len()

bool check_resource_group_name_len ( const LEX_CSTRING name,
Sql_condition::enum_severity_level  severity 
)

◆ check_resource_group_support()

bool check_resource_group_support ( )

◆ contextualize_array()

template<typename Context , typename Array >
bool contextualize_array ( Context *  pc,
Array *  array 
)

Contextualize a Mem_root_array of parse tree nodes of the type PTN.

Template Parameters
ContextParse context.
ArrayArray of parse tree nodes.
Parameters
[in,out]pcParse context.
[in,out]arrayArray of nodes to contextualize.
Returns
false on success.

◆ create_item_for_sp_var()

Item_splocal * create_item_for_sp_var ( THD thd,
LEX_CSTRING  name,
sp_variable spv,
const char *  query_start_ptr,
const char *  start,
const char *  end 
)

Create an object to represent a SP variable in the Item-hierarchy.

Parameters
thdThe current thread.
nameThe SP variable name.
spvThe SP variable (optional).
query_start_ptrStart of the SQL-statement query string (optional).
startStart position of the SP variable name in the query.
endEnd position of the SP variable name in the query.
Remarks
If spv is not specified, the name is used to search for the variable in the parse-time context. If the variable does not exist, a error is set and NULL is returned to the caller.
Returns
An Item_splocal object representing the SP variable, or NULL on error.

◆ flatten_associative_operator()

template<class Class , Item_func::Functype Tag>
Item * flatten_associative_operator ( MEM_ROOT mem_root,
const POS pos,
Item left,
Item right 
)

Flatten associative operators at parse time.

This function flattens AND and OR operators at parse time if applicable, otherwise it creates new Item_cond_and or Item_cond_or respectively.

Template parameter Class is Item_cond_and or Item_cond_or Template parameter Tag is COND_AND_FUNC (for Item_cond_and) or COND_OR_FUNC otherwise

Parameters
mem_rootMEM_ROOT
posparse location
leftleft argument of the operator
rightright argument of the operator
Returns
resulting parse tree Item

◆ is_identifier() [1/2]

bool is_identifier ( const char *  str,
const char *  ident 
)
inline

◆ is_identifier() [2/2]

bool is_identifier ( const LEX_STRING str,
const char *  ident 
)
inline

◆ item_cond_cast()

template<class To , Item_func::Functype Tag>
To * item_cond_cast ( Item *const  from)

Helper function to imitate dynamic_cast for Item_cond hierarchy.

Template parameter To is the destination type (Item_cond_and etc.) Template parameter Tag is the Functype tag to compare from->functype() with

Parameters
fromsource item
Returns
typecasted item of the type To or NULL

◆ make_string()

LEX_CSTRING make_string ( THD thd,
const char *  start_ptr,
const char *  end_ptr 
)

Make a new string allocated on THD's mem-root.

Parameters
thdthread handler.
start_ptrstart of the new string.
end_ptrend of the new string.
Returns
LEX_CSTRING object, containing a pointer to a newly constructed/allocated string, and its length. The pointer is NULL in case of out-of-memory error.

◆ move_cf_appliers()

void move_cf_appliers ( Parse_context tddlpc,
Column_parse_context cpc 
)

◆ resolve_engine()

bool resolve_engine ( THD thd,
const LEX_CSTRING name,
bool  is_temp_table,
bool  strict,
handlerton **  ret 
)

Resolve engine by its name.

Parameters
thdThread handler.
nameEngine's name.
is_temp_tableTrue if temporary table.
strictForce error if engine is unknown(*).
[out]retEngine object or NULL(**).
Returns
true if error is reported(**), otherwise false.
Note
*) NO_ENGINE_SUBSTITUTION sql_mode overrides the strict parameter.
**) If strict if false and engine is unknown, the function outputs a warning, sets ret to NULL and returns false (success).

◆ sp_create_assignment_instr()

bool sp_create_assignment_instr ( THD thd,
const char *  expr_end_ptr 
)

Create a SP instruction for a SET assignment.

See also
sp_create_assignment_lex
Parameters
thdThread context
expr_end_ptrOption-value-expression end pointer
Returns
false if success, true otherwise.

◆ sp_create_assignment_lex()

void sp_create_assignment_lex ( THD thd,
const char *  option_ptr 
)

◆ validate_resource_group_priority()

bool validate_resource_group_priority ( THD thd,
int *  priority,
const LEX_CSTRING name,
const resourcegroups::Type type 
)

◆ validate_vcpu_range()

bool validate_vcpu_range ( const resourcegroups::Range range)