MySQL 9.5.0
Source Code Documentation
sp_inl Namespace Reference

Classes

class  sp_inline_instr
 Base class for instructions within stored programs (currently limited to stored functions) that are eligible for inlining. More...
 
class  sp_inline_instr_freturn
 The sp_inline_instr_freturn class provides the base implementation for inlining RETURN instructions (sp_instr_freturn) in stored functions. More...
 
class  sp_inline_instr_set
 The sp_inline_instr_set class provides the base implementation for inlining SET instructions (sp_instr_set) within stored functions. More...
 
class  sp_inline_instr_stmt
 The sp_inline_instr_stmt class provides the base implementation for inlining statement instructions (sp_instr_stmt) within stored functions. More...
 

Functions

static Itemfind_variable_from_offset_inner (uint offset, std::unordered_map< uint, Item * > &map_var_offset_to_value, Item **args, uint arg_count)
 
static Itemfind_variable_from_offset (Item *var_item, std::unordered_map< uint, Item * > &map_var_offset_to_value, Item **args, uint arg_count)
 
void report_stored_function_inlining_error (THD *thd, const char *func_name, std::string &err_reason)
 Finalizes the error message for stored function inlining and reports the error. More...
 
bool needs_stored_function_inlining (THD *thd)
 Main functions for stored function inlining. More...
 
bool can_inline_stored_function (THD *thd, sp_head *sp, uint sp_arg_count)
 Checks if general stored function properties are eligible for inlining. More...
 
Mem_root_array< sp_inline_instr * > * prepare (THD *thd, sp_head *sp, std::unordered_set< sp_head * > &used_sp_functions)
 Creates the list of prepared instructions. More...
 
Iteminline_stored_function (THD *thd, Mem_root_array< sp_inline_instr * > *prepared_instructions, Item **sp_args, uint sp_arg_count, sp_head *sp_head, Name_resolution_context *sp_name_resolution_ctx)
 Inlines the given stored function instructions into a single Item. More...
 

Function Documentation

◆ can_inline_stored_function()

bool sp_inl::can_inline_stored_function ( THD thd,
sp_head sp,
uint  sp_arg_count 
)

Checks if general stored function properties are eligible for inlining.

Parameters
[in]thdThread context
[in]spStored program (function) instance
[in]sp_arg_countNumber of arguments of the stored function
Returns
"true" if the function can potentially be inlined, "false" otherwise.

◆ find_variable_from_offset()

static Item * sp_inl::find_variable_from_offset ( Item var_item,
std::unordered_map< uint, Item * > &  map_var_offset_to_value,
Item **  args,
uint  arg_count 
)
static

◆ find_variable_from_offset_inner()

static Item * sp_inl::find_variable_from_offset_inner ( uint  offset,
std::unordered_map< uint, Item * > &  map_var_offset_to_value,
Item **  args,
uint  arg_count 
)
static

◆ inline_stored_function()

Item * sp_inl::inline_stored_function ( THD thd,
Mem_root_array< sp_inline_instr * > *  prepared_instructions,
Item **  sp_args,
uint  sp_arg_count,
sp_head sp_head,
Name_resolution_context sp_name_resolution_ctx 
)

Inlines the given stored function instructions into a single Item.

Parameters
[in]thdThread context
[in]prepared_instructionsInstructions to inline
[in]sp_argsInput arguments of the stored function
[in]sp_arg_countNumber of arguments of the stored function
[in]sp_headStored function instance
[in]sp_name_resolution_ctxName resolution context of the stored function
Returns
"nullptr" if an error occurs, inlined Item otherwise

◆ needs_stored_function_inlining()

bool sp_inl::needs_stored_function_inlining ( THD thd)

Main functions for stored function inlining.

Checks if stored function inlining is required.

Currently we attempt stored function inlining only for the secondary engine. In certain cases (such as PFS creation) m_sql_cmd could be nullptr.

Parameters
[in]thdThread context
Returns
"true" if inlining is required, "false" otherwise

◆ prepare()

Mem_root_array< sp_inline_instr * > * sp_inl::prepare ( THD thd,
sp_head sp,
std::unordered_set< sp_head * > &  used_sp_functions 
)

Creates the list of prepared instructions.

A prepared instruction is an instruction eligible for inlining according to its method validate(). This function also computes and marks the redundant instructions so they can be later recognized using the method is_redundant_instr(). A redundant instruction is an instruction not needed for computing the returned result of the stored function.

Parameters
[in]thdThread context
[in]spStored program (stored function) instance
[out]used_sp_functionsSet of stored function instances called from sp
Returns
nullptr if an error occurs. List of prepared instructions otherwise. The list may contain both redundant and not redundant instruction.

◆ report_stored_function_inlining_error()

void sp_inl::report_stored_function_inlining_error ( THD thd,
const char *  func_name,
std::string &  err_reason 
)

Finalizes the error message for stored function inlining and reports the error.

Parameters
[in]thdThread context
[in]func_nameStored function name
[in]err_reasonFailure reason