The sp_inline_instr_stmt class provides the base implementation for inlining statement instructions (sp_instr_stmt) within stored functions.
More...
|
| | sp_inline_instr_stmt (sp_instr *sp_instr) |
| |
| bool | validate (std::string &err_reason) override |
| | Checks if this stored function instruction can be inlined. More...
|
| |
| bool | compute_is_redundant_and_collect_functions (THD *thd, std::unordered_set< uint > &offsets_live_variables, std::unordered_set< sp_head * > &used_sp_functions, std::string &err_reason) override |
| | Determines whether the current stored function instruction is redundant based on the provided set of live variables. More...
|
| |
| bool | process (THD *thd, std::unordered_map< uint, Item * > &map_var_offset_to_value, Item **sp_args, uint sp_arg_count, sp_head *sp_head, Name_resolution_context *sp_name_resolution_ctx, Item **result_item) override |
| | Processes an sp_inline_instr that is validated and non-redundant. More...
|
| |
| bool | check_redundant_instr_for_errors (THD *thd, std::string &err_reason) override |
| | Checks for any errors that may occur during the preparation phase of a redundant instruction. More...
|
| |
| | sp_inline_instr (sp_instr *sp_instr) |
| |
| virtual | ~sp_inline_instr () |
| |
| void | set_is_validated_instr () |
| | Sets m_is_validated_instr to true, indicating that the instruction has successfully passed the checks performed by validate(). More...
|
| |
| bool | is_validated_instr () |
| | Gets the value of m_is_validated_instr. More...
|
| |
| void | set_is_redundant_instr () |
| | Sets m_is_redundant_instr to true, indicating that the instruction is not required for computing the return result of a stored function. More...
|
| |
| bool | is_redundant_instr () |
| | Gets the value of m_is_redundant_instr. More...
|
| |
| uint | get_ip () |
| | Retrieves the instruction pointer (IP) for this instruction. More...
|
| |
|
| static void | record_instruction_inlining_error (std::string &err_reason, uint ip) |
| |
| bool | walk_and_collect_functions_and_variables (THD *thd, Item *item, std::unordered_set< uint > &var_offsets, std::unordered_set< sp_head * > &used_sp_functions, std::string &err_reason) |
| | Traverses the item tree and collects variable offsets for any encountered Item::ROUTINE_FIELD_ITEM instances. More...
|
| |
| bool | collect_functions_and_variables_from_query_block (THD *thd, Query_block *qb, std::unordered_set< uint > &variable_offsets, std::unordered_set< sp_head * > &used_sp_functions, std::string &err_reason) |
| | Collects variable offsets for all encountered Item::ROUTINE_FIELD_ITEM instances across the various components of the query block. More...
|
| |
| Item * | parse_and_inline_expression (THD *thd, Item *expr_item, std::unordered_map< uint, Item * > &map_var_offset_to_value, Item **sp_args, uint sp_arg_count) |
| | Creates a deep copy of the input expression and then in-place replaces the references to local variables with their values. More...
|
| |
| Item_singlerow_subselect * | create_and_inline_subquery (THD *thd, std::unordered_map< uint, Item * > &map_var_offset_to_value, Item **sp_args, uint sp_arg_count, sp_head *sp_head, Name_resolution_context *sp_name_resolution_ctx) |
| | Transform sp_inline_instr into a subquery with inlined references to local variables. More...
|
| |
| sp_instr * | m_sp_instr |
| | The original sp_instr which this class is meant to inline. More...
|
| |
The sp_inline_instr_stmt class provides the base implementation for inlining statement instructions (sp_instr_stmt) within stored functions.
Currently, inlining is supported for SELECT INTO statements that insert into a single local variable. For further details about statement instructions, refer to the sp_instr_stmt class.
| bool sp_inl::sp_inline_instr_stmt::compute_is_redundant_and_collect_functions |
( |
THD * |
thd, |
|
|
std::unordered_set< uint > & |
offsets_live_variables, |
|
|
std::unordered_set< sp_head * > & |
used_sp_functions, |
|
|
std::string & |
err_reason |
|
) |
| |
|
inlineoverridevirtual |
Determines whether the current stored function instruction is redundant based on the provided set of live variables.
A live variable is one that is required to compute the final result of the stored function. An instruction is considered redundant if it does not contribute to this result. If the instruction is determined to be non-redundant, this function updates the set of live variables with those used by the instruction. Additionally, the function collects instances of stored functions referenced in this instruction in order to use them later for recursion detection.
- Parameters
-
| [in] | thd | Thread context. |
| [in,out] | offsets_live_variables | Current set of live variable offsets. |
| [out] | used_sp_functions | Set of stored function instances used in this instruction. |
| [out] | err_reason | Populated with the error reason if an error occurs. |
- Returns
- false if the computation is successful; true otherwise.
Implements sp_inl::sp_inline_instr.