My Project
Public Member Functions | Protected Member Functions
sp_lex_instr Class Reference

#include <sp_instr.h>

Inheritance diagram for sp_lex_instr:
sp_instr Sql_alloc sp_printable sp_instr_cpush sp_instr_freturn sp_instr_set sp_instr_set_trigger_field sp_instr_stmt sp_lex_branch_instr sp_instr_jump_case_when sp_instr_jump_if_not sp_instr_set_case_expr

List of all members.

Public Member Functions

 sp_lex_instr (uint ip, sp_pcontext *ctx, LEX *lex, bool is_lex_owner)
bool validate_lex_and_execute_core (THD *thd, uint *nextp, bool open_tables)
virtual SQL_I_List
< Item_trigger_field > * 
get_instr_trig_field_list ()
virtual bool execute (THD *thd, uint *nextp)

Protected Member Functions

virtual bool exec_core (THD *thd, uint *nextp)=0
virtual bool is_invalid () const =0
virtual void invalidate ()=0
virtual void get_query (String *sql_query) const
virtual LEX_STRING get_expr_query () const
virtual bool on_after_expr_parsing (THD *thd)
virtual void cleanup_before_parsing (THD *thd)

Detailed Description

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.


Member Function Documentation

void sp_lex_instr::cleanup_before_parsing ( THD *  thd) [protected, virtual]

Destroy items in the free list before re-parsing the statement query string (and thus, creating new items).

Parameters:
thdThread context.

Reimplemented in sp_instr_set_trigger_field.

virtual bool sp_lex_instr::exec_core ( THD *  thd,
uint *  nextp 
) [protected, pure virtual]

Execute core function of instruction after all preparations (e.g. setting of proper LEX, saving part of the thread context).

Parameters:
thdThread context.
nextp[out]next instruction pointer
Returns:
Error flag.

Implemented in sp_instr_cpush, sp_instr_jump_case_when, sp_instr_set_case_expr, sp_instr_jump_if_not, sp_instr_freturn, sp_instr_set_trigger_field, sp_instr_set, and sp_instr_stmt.

virtual bool sp_lex_instr::execute ( THD *  thd,
uint *  nextp 
) [inline, virtual]

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.

Implements sp_instr.

Reimplemented in sp_instr_cpush, and sp_instr_stmt.

virtual LEX_STRING sp_lex_instr::get_expr_query ( ) const [inline, protected, virtual]
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_STR. EMPTY_STR 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 in sp_lex_branch_instr, sp_instr_freturn, sp_instr_set_trigger_field, and sp_instr_set.

void sp_lex_instr::get_query ( String sql_query) const [protected, virtual]

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 in sp_instr_cpush, and sp_instr_stmt.

virtual void sp_lex_instr::invalidate ( ) [protected, pure virtual]
virtual bool sp_lex_instr::is_invalid ( ) const [protected, pure virtual]
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.

Implemented in sp_instr_cpush, sp_lex_branch_instr, sp_instr_freturn, sp_instr_set_trigger_field, sp_instr_set, and sp_instr_stmt.

virtual bool sp_lex_instr::on_after_expr_parsing ( THD *  thd) [inline, protected, virtual]

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 in sp_instr_cpush, sp_instr_jump_case_when, sp_instr_set_case_expr, sp_instr_jump_if_not, sp_instr_freturn, sp_instr_set_trigger_field, sp_instr_set, and sp_instr_stmt.

bool sp_lex_instr::validate_lex_and_execute_core ( THD *  thd,
uint *  nextp,
bool  open_tables 
)

Make a few attempts to execute the instruction.

Basically, this operation does the following things:

  • install Reprepare_observer to catch metadata changes (if any);
  • calls reset_lex_and_exec_core() to execute the instruction;
  • if the execution fails due to a change in metadata, re-parse the instruction's SQL-statement and repeat execution.
Parameters:
thdThread context.
[out]nextpNext instruction pointer
open_tablesFlag 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).
Returns:
Error status.

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines