MySQL  8.0.19
Source Code Documentation
sp_lex_branch_instr Class Reference

sp_lex_branch_instr is a base class for SP-instructions, which might perform conditional jump depending on the value of an SQL-expression. More...

#include <sp_instr.h>

Inheritance diagram for sp_lex_branch_instr:
sp_lex_instr sp_branch_instr sp_instr sp_printable sp_instr_jump_case_when sp_instr_jump_if_not sp_instr_set_case_expr

Public Member Functions

void set_cont_dest (uint cont_dest)
 
virtual uint opt_mark (sp_head *sp, List< sp_instr > *leads)
 Mark this instruction as reachable during optimization and return the index to the next instruction. More...
 
virtual void opt_move (uint dst, List< sp_branch_instr > *ibp)
 Inform the instruction that it has been moved during optimization. More...
 
virtual uint get_cont_dest () const
 Get the continuation destination (instruction pointer for the CONTINUE HANDLER) of this instruction. More...
 
virtual bool is_invalid () const
 
virtual void invalidate ()
 Invalidate the object. More...
 
virtual LEX_CSTRING get_expr_query () const
 
virtual void set_destination (uint old_dest, uint new_dest)
 Update the destination; used by the SP-instruction-optimizer. More...
 
virtual void backpatch (uint dest)
 Update all instruction with the given label in the backpatch list to the specified instruction pointer. More...
 
- Public Member Functions inherited from sp_lex_instr
 sp_lex_instr (uint ip, sp_pcontext *ctx, LEX *lex, bool is_lex_owner)
 
virtual ~sp_lex_instr ()
 
bool validate_lex_and_execute_core (THD *thd, uint *nextp, bool open_tables)
 Make a few attempts to execute the instruction. More...
 
virtual SQL_I_List< Item_trigger_field > * get_instr_trig_field_list ()
 
virtual bool execute (THD *thd, uint *nextp)
 Execute this instruction. More...
 
- Public Member Functions inherited from sp_instr
 sp_instr (uint ip, sp_pcontext *ctx)
 
virtual ~sp_instr ()
 
virtual PSI_statement_infoget_psi_info ()=0
 
uint get_ip () const
 
sp_pcontextget_parsing_ctx () const
 
virtual uint opt_shortcut_jump (sp_head *, sp_instr *start)
 Short-cut jumps to jumps 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 ()
 
- Public Member Functions inherited from sp_branch_instr
virtual ~sp_branch_instr ()
 

Protected Member Functions

 sp_lex_branch_instr (uint ip, sp_pcontext *ctx, LEX *lex, Item *expr_item, LEX_CSTRING expr_query)
 
 sp_lex_branch_instr (uint ip, sp_pcontext *ctx, LEX *lex, Item *expr_item, LEX_CSTRING expr_query, uint dest)
 
- Protected Member Functions inherited from sp_lex_instr
virtual bool exec_core (THD *thd, uint *nextp)=0
 Execute core function of instruction after all preparations (e.g. More...
 
virtual void get_query (String *sql_query) const
 Return the query string, which can be passed to the parser. More...
 
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

uint m_dest
 Where we will go. More...
 
uint m_cont_dest
 Where continue handlers will go. More...
 
sp_instrm_optdest
 
sp_instrm_cont_optdest
 
Itemm_expr_item
 Expression item. More...
 
LEX_CSTRING m_expr_query
 SQL-query corresponding to the expression. More...
 
- Protected Attributes inherited from sp_lex_instr
LEXm_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_pcontextm_parsing_ctx
 Instruction parsing context. More...
 

Additional Inherited Members

- Public Attributes inherited from sp_instr
Query_arena m_arena
 

Detailed Description

sp_lex_branch_instr is a base class for SP-instructions, which might perform conditional jump depending on the value of an SQL-expression.

Constructor & Destructor Documentation

◆ sp_lex_branch_instr() [1/2]

sp_lex_branch_instr::sp_lex_branch_instr ( uint  ip,
sp_pcontext ctx,
LEX lex,
Item expr_item,
LEX_CSTRING  expr_query 
)
inlineprotected

◆ sp_lex_branch_instr() [2/2]

sp_lex_branch_instr::sp_lex_branch_instr ( uint  ip,
sp_pcontext ctx,
LEX lex,
Item expr_item,
LEX_CSTRING  expr_query,
uint  dest 
)
inlineprotected

Member Function Documentation

◆ backpatch()

virtual void sp_lex_branch_instr::backpatch ( uint  dest)
inlinevirtual

Update all instruction with the given label in the backpatch list to the specified instruction pointer.

Parameters
destdestination instruction pointer.

Implements sp_branch_instr.

Reimplemented in sp_instr_set_case_expr.

◆ get_cont_dest()

virtual uint sp_lex_branch_instr::get_cont_dest ( ) const
inlinevirtual

Get the continuation destination (instruction pointer for the CONTINUE HANDLER) of this instruction.

Returns
the continuation destination

Reimplemented from sp_instr.

◆ get_expr_query()

virtual LEX_CSTRING sp_lex_branch_instr::get_expr_query ( ) const
inlinevirtual
Returns
the expression query string. This string can not be passed directly to the parser as it is most likely not a valid SQL-statement.
Note
as it can be seen in the get_query() implementation, get_expr_query() might return EMPTY_CSTR. EMPTY_CSTR means that no query-expression is available. That happens when class provides different implementation of get_query(). Strictly speaking, this is a drawback of the current class hierarchy.

Reimplemented from sp_lex_instr.

◆ invalidate()

virtual void sp_lex_branch_instr::invalidate ( )
inlinevirtual

Invalidate the object.

Implements sp_lex_instr.

Reimplemented in sp_instr_jump_case_when.

◆ is_invalid()

virtual bool sp_lex_branch_instr::is_invalid ( ) const
inlinevirtual
Return values
falseif the object (i.e. LEX-object) is valid and exec_core() can be just called.
trueif 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.

Implements sp_lex_instr.

◆ opt_mark()

uint sp_lex_branch_instr::opt_mark ( sp_head ,
List< sp_instr > *  leads 
)
virtual

Mark this instruction as reachable during optimization and return the index to the next instruction.

Jump instruction will add their destination to the leads list.

Reimplemented from sp_instr.

Reimplemented in sp_instr_set_case_expr.

◆ opt_move()

void sp_lex_branch_instr::opt_move ( uint  dst,
List< sp_branch_instr > *  ibp 
)
virtual

Inform the instruction that it has been moved during optimization.

Most instructions will simply update its index, but jump instructions must also take care of their destination pointers. Forward jumps get pushed to the backpatch list 'ibp'.

Reimplemented from sp_instr.

Reimplemented in sp_instr_set_case_expr.

◆ set_cont_dest()

void sp_lex_branch_instr::set_cont_dest ( uint  cont_dest)
inline

◆ set_destination()

virtual void sp_lex_branch_instr::set_destination ( uint  old_dest,
uint  new_dest 
)
inlinevirtual

Update the destination; used by the SP-instruction-optimizer.

Parameters
old_destcurrent (old) destination (instruction pointer).
new_destnew destination (instruction pointer).

Implements sp_branch_instr.

Reimplemented in sp_instr_set_case_expr.

Member Data Documentation

◆ m_cont_dest

uint sp_lex_branch_instr::m_cont_dest
protected

Where continue handlers will go.

◆ m_cont_optdest

sp_instr* sp_lex_branch_instr::m_cont_optdest
protected

◆ m_dest

uint sp_lex_branch_instr::m_dest
protected

Where we will go.

◆ m_expr_item

Item* sp_lex_branch_instr::m_expr_item
protected

Expression item.

◆ m_expr_query

LEX_CSTRING sp_lex_branch_instr::m_expr_query
protected

SQL-query corresponding to the expression.

◆ m_optdest

sp_instr* sp_lex_branch_instr::m_optdest
protected

The documentation for this class was generated from the following files: