MySQL  8.0.17
Source Code Documentation
parse_tree_helpers.h File Reference
#include <stddef.h>
#include <sys/types.h>
#include <new>
#include "lex_string.h"
#include "m_ctype.h"
#include "my_dbug.h"
#include "my_inttypes.h"
#include "mysql_time.h"
#include "sql/item.h"
#include "sql/item_func.h"
#include "sql/mem_root_array.h"
#include "sql/parse_tree_node_base.h"
#include "sql/resourcegroups/resource_group_basic_types.h"
#include "sql/set_var.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_STRING 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...
 
bool find_sys_var_null_base (THD *thd, struct sys_var_with_base *tmp)
 
bool set_system_variable (THD *thd, struct sys_var_with_base *tmp, enum enum_var_type var_type, Item *val)
 Helper action for a SET statement. More...
 
LEX_STRING make_string (THD *thd, const char *start_ptr, const char *end_ptr)
 Make a new string allocated on THD's mem-root. More...
 
bool set_trigger_new_row (Parse_context *pc, LEX_STRING trigger_field_name, Item *expr_item, LEX_STRING expr_query)
 Helper action for a SET statement. 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 is_key_cache_variable_suffix (const char *suffix)
 
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)
 

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)

◆ 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_STRING  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.

◆ find_sys_var_null_base()

bool find_sys_var_null_base ( THD thd,
struct sys_var_with_base tmp 
)

◆ 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

◆ is_key_cache_variable_suffix()

bool is_key_cache_variable_suffix ( const char *  suffix)

◆ 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_STRING 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_STRING object, containing a pointer to a newly constructed/allocated string, and its length. The pointer is NULL in case of out-of-memory error.

◆ 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).

◆ set_system_variable()

bool set_system_variable ( THD thd,
struct sys_var_with_base var_with_base,
enum enum_var_type  var_type,
Item val 
)

Helper action for a SET statement.

Used to push a system variable into the assignment list.

Parameters
thdthe current thread
var_with_basethe system variable with base name
var_typethe scope of the variable
valthe value being assigned to the variable
Returns
true if error, false otherwise.

◆ set_trigger_new_row()

bool set_trigger_new_row ( Parse_context pc,
LEX_STRING  trigger_field_name,
Item expr_item,
LEX_STRING  expr_query 
)

Helper action for a SET statement.

Used to SET a field of NEW row.

Parameters
pcthe parse context
trigger_field_namethe NEW-row field name
expr_itemthe value expression being assigned
expr_querythe value expression query
Returns
error status (true if error, false otherwise).

◆ 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)