MySQL 8.4.3
Source Code Documentation
sp_instr_cpush Class Reference

sp_instr_cpush corresponds to DECLARE CURSOR, implements DECLARE CURSOR and OPEN. More...

#include <sp_instr.h>

Inheritance diagram for sp_instr_cpush:
[legend]

Public Member Functions

 sp_instr_cpush (uint ip, sp_pcontext *ctx, LEX *cursor_lex, LEX_CSTRING cursor_query, int cursor_idx)
 
void print (const THD *thd, String *str) override
 
bool execute (THD *thd, uint *nextp) override
 Execute this instruction. More...
 
bool exec_core (THD *thd, uint *nextp) override
 Execute core function of instruction after all preparations (e.g. More...
 
bool is_invalid () const override
 
void invalidate () override
 Invalidate the object. More...
 
void get_query (String *sql_query) const override
 Return the query string, which can be passed to the parser. More...
 
bool on_after_expr_parsing (THD *) override
 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...
 
PSI_statement_infoget_psi_info () override
 
- 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
 
- Public Member Functions inherited from sp_instr
 sp_instr (uint ip, sp_pcontext *ctx)
 
 ~sp_instr () override
 
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_pcontextget_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 ~sp_printable ()=default
 

Static Public Attributes

static PSI_statement_info psi_info
 

Private Attributes

LEX_CSTRING m_cursor_query
 This attribute keeps the cursor SELECT statement. More...
 
bool m_valid
 Flag if the LEX-object of this instruction is valid or not. More...
 
int m_cursor_idx
 Used to identify the cursor in the sp_rcontext. More...
 

Additional Inherited Members

- Public Attributes inherited from sp_instr
Query_arena m_arena
 
- Protected Member Functions inherited from sp_lex_instr
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 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_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_cpush corresponds to DECLARE CURSOR, implements DECLARE CURSOR and OPEN.

This is the most important instruction in cursor implementation. It is created and added to sp_head when DECLARE CURSOR is being parsed. The arena of this instruction contains LEX-object for the cursor's SELECT-statement.

This instruction is actually used to open the cursor.

execute() operation "implements" DECLARE CURSOR statement – it merely pushes a new cursor object into the stack in sp_rcontext object.

exec_core() operation implements OPEN statement. It is important to implement OPEN statement in this instruction, because OPEN may lead to re-parsing of the SELECT-statement. So, the original Arena and parsing context must be used.

Constructor & Destructor Documentation

◆ sp_instr_cpush()

sp_instr_cpush::sp_instr_cpush ( uint  ip,
sp_pcontext ctx,
LEX cursor_lex,
LEX_CSTRING  cursor_query,
int  cursor_idx 
)
inline

Member Function Documentation

◆ exec_core()

bool sp_instr_cpush::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.

◆ execute()

bool sp_instr_cpush::execute ( THD thd,
uint *  nextp 
)
overridevirtual

Execute this instruction.

Parameters
thdThread context
[out]nextpindex 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.
Returns
Error status.

Reimplemented from sp_lex_instr.

◆ get_psi_info()

PSI_statement_info * sp_instr_cpush::get_psi_info ( )
inlineoverridevirtual

Implements sp_instr.

◆ get_query()

void sp_instr_cpush::get_query ( String sql_query) const
inlineoverridevirtual

Return the query string, which can be passed to the parser.

I.e. the operation should return a valid SQL-statement query string.

Parameters
[out]sql_querySQL-statement query string.

Reimplemented from sp_lex_instr.

◆ invalidate()

void sp_instr_cpush::invalidate ( )
inlineoverridevirtual

Invalidate the object.

Implements sp_lex_instr.

◆ is_invalid()

bool sp_instr_cpush::is_invalid ( ) const
inlineoverridevirtual
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.

◆ on_after_expr_parsing()

bool sp_instr_cpush::on_after_expr_parsing ( THD thd)
inlineoverridevirtual

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.

Parameters
thdThread context.
Returns
Error flag.

Reimplemented from sp_lex_instr.

◆ print()

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

Implements sp_printable.

Member Data Documentation

◆ m_cursor_idx

int sp_instr_cpush::m_cursor_idx
private

Used to identify the cursor in the sp_rcontext.

◆ m_cursor_query

LEX_CSTRING sp_instr_cpush::m_cursor_query
private

This attribute keeps the cursor SELECT statement.

◆ m_valid

bool sp_instr_cpush::m_valid
private

Flag if the LEX-object of this instruction is valid or not.

The LEX-object is not valid when metadata have changed.

◆ psi_info

PSI_statement_info sp_instr_cpush::psi_info
static
Initial value:
= {
"Stored Program: install a DECLARE CURSOR microcode instruction"}
#define PSI_FLAG_DISABLED
Instrument is disabled by default.
Definition: psi_bits.h:146
#define PSI_FLAG_UNTIMED
Instrument is not timed by default.
Definition: psi_bits.h:151

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