MySQL 8.0.40
Source Code Documentation
|
sp_lex_instr is a class providing the interface and base implementation for SP-instructions, whose execution is based on expression evaluation. More...
#include <sp_instr.h>
Public Member Functions | |
sp_lex_instr (uint ip, sp_pcontext *ctx, LEX *lex, bool is_lex_owner) | |
~sp_lex_instr () override | |
bool | validate_lex_and_execute_core (THD *thd, uint *nextp, bool open_tables) |
Make a few attempts to execute the instruction. More... | |
SQL_I_List< Item_trigger_field > * | get_instr_trig_field_list () override |
bool | execute (THD *thd, uint *nextp) override |
Execute this instruction. More... | |
Public Member Functions inherited from sp_instr | |
sp_instr (uint ip, sp_pcontext *ctx) | |
~sp_instr () override | |
virtual PSI_statement_info * | get_psi_info ()=0 |
uint | get_ip () const |
virtual uint | get_cont_dest () const |
Get the continuation destination (instruction pointer for the CONTINUE HANDLER) of this instruction. More... | |
sp_pcontext * | get_parsing_ctx () const |
virtual uint | opt_mark (sp_head *, List< sp_instr > *leads) |
Mark this instruction as reachable during optimization and return the index to the next instruction. More... | |
virtual uint | opt_shortcut_jump (sp_head *, sp_instr *start) |
Short-cut jumps to jumps during optimization. More... | |
virtual void | opt_move (uint dst, List< sp_branch_instr > *ibp) |
Inform the instruction that it has been moved during optimization. More... | |
bool | opt_is_marked () const |
Public Member Functions inherited from sp_printable | |
virtual void | print (const THD *thd, String *str)=0 |
virtual | ~sp_printable ()=default |
Protected Member Functions | |
virtual bool | exec_core (THD *thd, uint *nextp)=0 |
Execute core function of instruction after all preparations (e.g. More... | |
virtual bool | is_invalid () const =0 |
virtual void | invalidate ()=0 |
Invalidate the object. More... | |
virtual void | get_query (String *sql_query) const |
Return the query string, which can be passed to the parser. More... | |
virtual void | adjust_sql_command (LEX *) |
Some expressions may be re-parsed as SELECT statements, but need to be adjusted to another SQL command. More... | |
virtual LEX_CSTRING | get_expr_query () const |
virtual bool | on_after_expr_parsing (THD *thd) |
Callback function which is called after the statement query string is successfully parsed, and the thread context has not been switched to the outer context. More... | |
virtual void | cleanup_before_parsing (THD *thd) |
Destroy items in the free list before re-parsing the statement query string (and thus, creating new items). More... | |
Protected Member Functions inherited from sp_instr | |
void | clear_da (THD *thd) const |
Clear diagnostics area. More... | |
Protected Attributes | |
LEX * | m_lex |
LEX-object. More... | |
Protected Attributes inherited from sp_instr | |
bool | m_marked |
Show if this instruction is reachable within the SP (used by SP-optimizer). More... | |
uint | m_ip |
Instruction pointer. More... | |
sp_pcontext * | m_parsing_ctx |
Instruction parsing context. More... | |
Private Member Functions | |
bool | reset_lex_and_exec_core (THD *thd, uint *nextp, bool open_tables) |
Prepare LEX and thread for execution of instruction, if requested open and lock LEX's tables, execute instruction's core function, perform cleanup afterwards. More... | |
bool | execute_expression (THD *thd, uint *nextp) |
Execute an expression (e.g an IF) that is not a complete SQL statement. More... | |
LEX * | parse_expr (THD *thd, sp_head *sp) |
(Re-)parse the query corresponding to this instruction and return a new LEX-object. More... | |
void | set_lex (LEX *lex, bool is_lex_owner) |
Set LEX-object. More... | |
void | free_lex () |
Cleanup and destroy assigned LEX-object if needed. More... | |
Private Attributes | |
MEM_ROOT | m_lex_mem_root {PSI_NOT_INSTRUMENTED, MEM_ROOT_BLOCK_SIZE} |
Mem-root for storing the LEX-tree during reparse. More... | |
bool | m_is_lex_owner |
Indicates whether this sp_lex_instr instance is responsible for LEX-object deletion. More... | |
bool | m_first_execution |
Indicates whether exec_core() has not been already called on the current LEX-object. More... | |
Table_ref * | m_prelocking_tables |
List of additional tables this statement needs to lock when it enters/leaves prelocked mode on its own. More... | |
Table_ref ** | m_lex_query_tables_own_last |
The value m_lex->query_tables_own_last should be set to this when the statement enters/leaves prelocked mode on its own. More... | |
SQL_I_List< Item_trigger_field > | m_trig_field_list |
List of all the Item_trigger_field's of instruction. More... | |
Additional Inherited Members | |
Public Attributes inherited from sp_instr | |
Query_arena | m_arena |
sp_lex_instr is a class providing the interface and base implementation for SP-instructions, whose execution is based on expression evaluation.
sp_lex_instr keeps LEX-object to be able to evaluate the expression.
sp_lex_instr also provides possibility to re-parse the original query string if for some reason the LEX-object is not valid any longer.
|
inline |
|
inlineoverride |
|
inlineprotectedvirtual |
Some expressions may be re-parsed as SELECT statements, but need to be adjusted to another SQL command.
This function facilitates that change.
Reimplemented in sp_instr_set, sp_instr_freturn, and sp_lex_branch_instr.
|
protectedvirtual |
Destroy items in the free list before re-parsing the statement query string (and thus, creating new items).
thd | Thread context. |
Reimplemented in sp_instr_set_trigger_field.
Execute core function of instruction after all preparations (e.g.
setting of proper LEX, saving part of the thread context).
thd | Thread context. | |
[out] | nextp | next instruction pointer |
Implemented in sp_instr_stmt, sp_instr_set, sp_instr_set_trigger_field, sp_instr_freturn, sp_instr_jump_if_not, sp_instr_set_case_expr, sp_instr_jump_case_when, and sp_instr_cpush.
Execute this instruction.
thd | Thread context | |
[out] | nextp | index of the next instruction to execute. (For most instructions this will be the instruction following this one). Note that this parameter is undefined in case of errors, use get_cont_dest() to find the continuation instruction for CONTINUE error handlers. |
Implements sp_instr.
Reimplemented in sp_instr_stmt, and sp_instr_cpush.
Execute an expression (e.g an IF) that is not a complete SQL statement.
Expressions that may be executed in this function: IF, CASE, DECLARE, SET, RETURN
thd | thread context | |
[out] | nextp | next instruction pointer |
|
private |
Cleanup and destroy assigned LEX-object if needed.
|
inlineprotectedvirtual |
Reimplemented in sp_instr_set, sp_instr_set_trigger_field, sp_instr_freturn, and sp_lex_branch_instr.
|
inlineoverridevirtual |
Reimplemented from sp_instr.
|
protectedvirtual |
Return the query string, which can be passed to the parser.
I.e. the operation should return a valid SQL-statement query string.
[out] | sql_query | SQL-statement query string. |
Reimplemented in sp_instr_stmt, and sp_instr_cpush.
|
protectedpure virtual |
Invalidate the object.
Implemented in sp_instr_stmt, sp_instr_set, sp_instr_set_trigger_field, sp_instr_freturn, sp_lex_branch_instr, sp_instr_jump_case_when, and sp_instr_cpush.
|
protectedpure virtual |
false | if the object (i.e. LEX-object) is valid and exec_core() can be just called. |
true | if the object is not valid any longer, exec_core() can not be called. The original query string should be re-parsed and a new LEX-object should be used. |
Implemented in sp_instr_stmt, sp_instr_set, sp_instr_set_trigger_field, sp_instr_freturn, sp_lex_branch_instr, and sp_instr_cpush.
|
inlineprotectedvirtual |
Callback function which is called after the statement query string is successfully parsed, and the thread context has not been switched to the outer context.
The thread context contains new LEX-object corresponding to the parsed query string.
thd | Thread context. |
Reimplemented in sp_instr_stmt, sp_instr_cpush, sp_instr_set, sp_instr_set_trigger_field, sp_instr_freturn, sp_instr_jump_if_not, sp_instr_set_case_expr, and sp_instr_jump_case_when.
(Re-)parse the query corresponding to this instruction and return a new LEX-object.
thd | Thread context. |
sp | The stored program. |
Move Item_trigger_field's list to instruction's Item_trigger_field list.
Prepare LEX and thread for execution of instruction, if requested open and lock LEX's tables, execute instruction's core function, perform cleanup afterwards.
thd | thread context | |
[out] | nextp | next instruction pointer |
open_tables | if true then check read access to tables in LEX's table list and open and lock them (used in instructions which need to calculate some expression and don't execute complete statement). |
|
private |
Set LEX-object.
Previously assigned LEX-object (if any) will be properly cleaned up and destroyed.
lex | LEX-object to be used by this instance of sp_lex_instr. |
is_lex_owner | the flag specifying if this instance sp_lex_instr owns (and thus deletes when needed) passed LEX-object. |
Make a few attempts to execute the instruction.
Basically, this operation does the following things:
thd | Thread context. | |
[out] | nextp | Next instruction pointer |
open_tables | Flag to specify if the function should check read access to tables in LEX's table list and open and lock them (used in instructions which need to calculate some expression and don't execute complete statement). |
|
private |
Indicates whether exec_core() has not been already called on the current LEX-object.
|
private |
Indicates whether this sp_lex_instr instance is responsible for LEX-object deletion.
|
protected |
LEX-object.
|
private |
Mem-root for storing the LEX-tree during reparse.
This mem-root is freed when a reparse is triggered or the stored routine is dropped.
|
private |
The value m_lex->query_tables_own_last should be set to this when the statement enters/leaves prelocked mode on its own.
|
private |
List of additional tables this statement needs to lock when it enters/leaves prelocked mode on its own.
|
private |
List of all the Item_trigger_field's of instruction.