MySQL  8.0.18
Source Code Documentation
parse_tree_helpers.cc File Reference
#include "sql/parse_tree_helpers.h"
#include "m_string.h"
#include "my_dbug.h"
#include "my_inttypes.h"
#include "my_sqlcommand.h"
#include "my_sys.h"
#include "mysql/components/services/log_shared.h"
#include "mysql/mysql_lex_string.h"
#include "mysql_com.h"
#include "mysqld_error.h"
#include "sql/auth/auth_acls.h"
#include "sql/derror.h"
#include "sql/handler.h"
#include "sql/mysqld.h"
#include "sql/parse_tree_nodes.h"
#include "sql/resourcegroups/platform/thread_attrs_api.h"
#include "sql/resourcegroups/resource_group_mgr.h"
#include "sql/sp_head.h"
#include "sql/sp_instr.h"
#include "sql/sp_pcontext.h"
#include "sql/sql_class.h"
#include "sql/sql_error.h"
#include "sql/sql_lex.h"
#include "sql/sql_plugin_ref.h"
#include "sql/system_variables.h"
#include "sql/trigger_def.h"
#include "sql_string.h"

Functions

Item_splocalcreate_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. 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 *var_with_base, enum enum_var_type var_type, Item *val)
 Helper action for a SET statement. 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...
 
bool set_trigger_new_row (Parse_context *pc, LEX_CSTRING trigger_field_name, Item *expr_item, LEX_CSTRING 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 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)
 

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

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

◆ find_sys_var_null_base()

bool find_sys_var_null_base ( THD thd,
struct sys_var_with_base tmp 
)

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

◆ 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_CSTRING  trigger_field_name,
Item expr_item,
LEX_CSTRING  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)