My Project
Public Member Functions
sp_instr_cpush Class Reference

#include <sp_instr.h>

Inheritance diagram for sp_instr_cpush:
sp_lex_instr sp_instr Sql_alloc sp_printable

List of all members.

Public Member Functions

 sp_instr_cpush (uint ip, sp_pcontext *ctx, LEX *cursor_lex, LEX_STRING cursor_query, int cursor_idx)
virtual void print (String *str)
virtual void cleanup_stmt ()
virtual bool execute (THD *thd, uint *nextp)
virtual bool exec_core (THD *thd, uint *nextp)
virtual bool is_invalid () const
virtual void invalidate ()
virtual void get_query (String *sql_query) const
virtual bool on_after_expr_parsing (THD *thd)

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.


Member Function Documentation

virtual void sp_instr_cpush::cleanup_stmt ( ) [inline, virtual]

This call is used to cleanup the instruction when a sensitive cursor is closed. For now stored procedures always use materialized cursors and the call is not used.

bool sp_instr_cpush::exec_core ( THD *  thd,
uint *  nextp 
) [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.

Implements sp_lex_instr.

bool sp_instr_cpush::execute ( THD *  thd,
uint *  nextp 
) [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.

Reimplemented from sp_lex_instr.

virtual void sp_instr_cpush::get_query ( String sql_query) const [inline, 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 from sp_lex_instr.

virtual void sp_instr_cpush::invalidate ( ) [inline, virtual]

Invalidate the object.

Implements sp_lex_instr.

virtual bool sp_instr_cpush::is_invalid ( ) const [inline, 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.

Implements sp_lex_instr.

virtual bool sp_instr_cpush::on_after_expr_parsing ( THD *  thd) [inline, 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 from sp_lex_instr.


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