MySQL 8.3.0
Source Code Documentation
sp_instr_jump_case_when Class Reference

sp_instr_jump_case_when instruction is used in the "simple CASE" implementation. More...

#include <sp_instr.h>

Inheritance diagram for sp_instr_jump_case_when:
[legend]

Public Member Functions

 sp_instr_jump_case_when (uint ip, LEX *lex, int case_expr_id, Item *when_expr_item, LEX_CSTRING when_expr_query)
 
void print (const THD *thd, String *str) override
 
bool exec_core (THD *thd, uint *nextp) override
 Execute core function of instruction after all preparations (e.g. More...
 
void invalidate () override
 Invalidate the object. More...
 
bool on_after_expr_parsing (THD *thd) override
 Build CASE-expression item tree: Item_func_eq(case-expression, when-i-expression) More...
 
PSI_statement_infoget_psi_info () override
 
- Public Member Functions inherited from sp_lex_branch_instr
void set_cont_dest (uint cont_dest)
 
uint opt_mark (sp_head *sp, List< sp_instr > *leads) override
 Mark this instruction as reachable during optimization and return the index to the next instruction. More...
 
void opt_move (uint dst, List< sp_branch_instr > *ibp) override
 Inform the instruction that it has been moved during optimization. More...
 
uint get_cont_dest () const override
 Get the continuation destination (instruction pointer for the CONTINUE HANDLER) of this instruction. More...
 
bool is_invalid () const override
 
LEX_CSTRING get_expr_query () const override
 
void set_destination (uint old_dest, uint new_dest) override
 Update the destination; used by the SP-instruction-optimizer. More...
 
void backpatch (uint dest) override
 Update all instruction with the given label in the backpatch list to the specified instruction pointer. More...
 
void adjust_sql_command (LEX *lex) override
 Some expressions may be re-parsed as SELECT statements, but need to be adjusted to another SQL command. More...
 
- Public Member Functions inherited from sp_lex_instr
 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
 
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 ~sp_printable ()=default
 
- Public Member Functions inherited from sp_branch_instr
virtual ~sp_branch_instr ()=default
 

Static Public Attributes

static PSI_statement_info psi_info
 

Private Attributes

int m_case_expr_id
 Identifier (index) of the CASE-expression in the runtime context. More...
 
Item_case_exprm_case_expr_item
 Item representing the CASE-expression. More...
 
Itemm_eq_item
 Item corresponding to the main item of the jump-condition-expression: it's the equal function (=) in the (case-expression = when-i-expression) expression. More...
 

Additional Inherited Members

- Public Attributes inherited from sp_instr
Query_arena m_arena
 
- Protected Member Functions inherited from sp_lex_branch_instr
 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 void get_query (String *sql_query) const
 Return the query string, which can be passed to the parser. 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 inherited from sp_lex_branch_instr
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...
 

Detailed Description

sp_instr_jump_case_when instruction is used in the "simple CASE" implementation.

It's a jump instruction with the following condition: (CASE-expression = WHEN-expression) CASE-expression is retrieved from sp_rcontext; WHEN-expression is kept by this instruction.

Constructor & Destructor Documentation

◆ sp_instr_jump_case_when()

sp_instr_jump_case_when::sp_instr_jump_case_when ( uint  ip,
LEX lex,
int  case_expr_id,
Item when_expr_item,
LEX_CSTRING  when_expr_query 
)
inline

Member Function Documentation

◆ exec_core()

bool sp_instr_jump_case_when::exec_core ( THD thd,
uint *  nextp 
)
overridevirtual

Execute core function of instruction after all preparations (e.g.

setting of proper LEX, saving part of the thread context).

Parameters
thdThread context.
[out]nextpnext instruction pointer
Returns
Error flag.

Implements sp_lex_instr.

◆ get_psi_info()

PSI_statement_info * sp_instr_jump_case_when::get_psi_info ( )
inlineoverridevirtual

Implements sp_instr.

◆ invalidate()

void sp_instr_jump_case_when::invalidate ( )
inlineoverridevirtual

Invalidate the object.

Reimplemented from sp_lex_branch_instr.

◆ on_after_expr_parsing()

bool sp_instr_jump_case_when::on_after_expr_parsing ( THD thd)
overridevirtual

Build CASE-expression item tree: Item_func_eq(case-expression, when-i-expression)

This function is used for the following form of CASE statement: CASE case-expression WHEN when-1-expression THEN ... WHEN when-2-expression THEN ... ... WHEN when-n-expression THEN ... END CASE

The thing is that after the parsing we have an item (item tree) for the case-expression and for each when-expression. Here we build jump conditions: expressions like (case-expression = when-i-expression).

Parameters
thdThread context.
Returns
Error flag.

Reimplemented from sp_lex_instr.

◆ print()

void sp_instr_jump_case_when::print ( const THD thd,
String str 
)
overridevirtual

Implements sp_printable.

Member Data Documentation

◆ m_case_expr_id

int sp_instr_jump_case_when::m_case_expr_id
private

Identifier (index) of the CASE-expression in the runtime context.

◆ m_case_expr_item

Item_case_expr* sp_instr_jump_case_when::m_case_expr_item
private

Item representing the CASE-expression.

◆ m_eq_item

Item* sp_instr_jump_case_when::m_eq_item
private

Item corresponding to the main item of the jump-condition-expression: it's the equal function (=) in the (case-expression = when-i-expression) expression.

◆ psi_info

PSI_statement_info sp_instr_jump_case_when::psi_info
static
Initial value:
= {
0, "jump_case_when", PSI_FLAG_DISABLED | PSI_FLAG_UNTIMED,
"Stored Program: jump CASE WHEN microcode instruction"}
#define PSI_FLAG_DISABLED
Instrument is disabled by default.
Definition: psi_bits.h:145
#define PSI_FLAG_UNTIMED
Instrument is not timed by default.
Definition: psi_bits.h:150

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