MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
sp_rcontext Class Reference
Inheritance diagram for sp_rcontext:
Collaboration diagram for sp_rcontext:

Classes

class  Handler_call_frame
class  sp_handler_entry
class  Sql_condition_info

Public Member Functions

bool set_variable (THD *thd, uint var_idx, Item **value)
Itemget_item (uint var_idx) const
Item ** get_item_addr (uint var_idx) const
bool set_return_value (THD *thd, Item **return_value_item)
bool is_return_value_set () const
bool push_handler (sp_handler *handler, uint first_ip)
void pop_handlers (sp_pcontext *current_scope)
const Sql_condition_inforaised_condition () const
bool handle_sql_condition (THD *thd, uint *ip, const sp_instr *cur_spi)
void exit_handler (sp_pcontext *target_scope)
uint get_last_handler_continue_ip () const
bool push_cursor (sp_instr_cpush *i)
void pop_cursors (uint count)
void pop_all_cursors ()
sp_cursorget_cursor (uint i) const
bool set_case_expr (THD *thd, int case_expr_id, Item **case_expr_item_ptr)
Itemget_case_expr (int case_expr_id) const
Item ** get_case_expr_addr (int case_expr_id) const

Static Public Member Functions

static sp_rcontextcreate (THD *thd, const sp_pcontext *root_parsing_ctx, Field *return_value_fld)
- Static Public Member Functions inherited from Sql_alloc
static void * operator new (size_t size) throw ()
static void * operator new[] (size_t size) throw ()
static void * operator new[] (size_t size, MEM_ROOT *mem_root) throw ()
static void * operator new (size_t size, MEM_ROOT *mem_root) throw ()
static void operator delete (void *ptr, size_t size)
static void operator delete (void *ptr, MEM_ROOT *mem_root)
static void operator delete[] (void *ptr, MEM_ROOT *mem_root)
static void operator delete[] (void *ptr, size_t size)

Public Attributes

Query_arena * callers_arena
bool end_partial_result_set
sp_headsp
 The stored program for which this runtime context is created.

Detailed Description

Definition at line 51 of file sp_rcontext.h.

Member Function Documentation

sp_rcontext * sp_rcontext::create ( THD *  thd,
const sp_pcontext root_parsing_ctx,
Field return_value_fld 
)
static

Construct and properly initialize a new sp_rcontext instance. The static create-function is needed because we need a way to return an error from the constructor.

Parameters
thdThread handle.
root_parsing_ctxTop-level parsing context for this stored program.
return_value_fldField object to store the return value (for stored functions only).
Returns
valid sp_rcontext object or NULL in case of OOM-error.

Definition at line 65 of file sp_rcontext.cc.

Here is the caller graph for this function:

void sp_rcontext::exit_handler ( sp_pcontext target_scope)

Handle return from SQL-handler.

Parameters
target_scopeThe BEGIN..END block, containing the target (next) instruction.

Definition at line 230 of file sp_rcontext.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

uint sp_rcontext::get_last_handler_continue_ip ( ) const
inline
Returns
the continue instruction pointer if the last activated CONTINUE handler. This function must not be called for the EXIT handlers.

Definition at line 279 of file sp_rcontext.h.

Here is the call graph for this function:

Here is the caller graph for this function:

bool sp_rcontext::handle_sql_condition ( THD *  thd,
uint *  ip,
const sp_instr cur_spi 
)

Handle current SQL condition (if any).

This is the public-interface function to handle SQL conditions in stored routines.

Parameters
thdThread handle.
ip[out]Instruction pointer to the first handler instruction.
cur_spiCurrent SP instruction.
Return values
trueif an SQL-handler has been activated. That means, all of the following conditions are satisfied:
  • the SP-instruction raised SQL-condition(s),
  • and there is an SQL-handler to process at least one of those SQL-conditions,
  • and that SQL-handler has been activated. Note, that the return value has nothing to do with "error flag" semantics.
falseotherwise.

Definition at line 254 of file sp_rcontext.cc.

Here is the call graph for this function:

void sp_rcontext::pop_cursors ( uint  count)

Pop and delete given number of sp_cursor instance from the cursor stack.

Parameters
countNumber of cursors to pop & delete.

Definition at line 185 of file sp_rcontext.cc.

void sp_rcontext::pop_handlers ( sp_pcontext current_scope)

Pop and delete given number of sp_handler_entry instances from the handler call stack.

Parameters
current_scopeThe current BEGIN..END block.

Definition at line 218 of file sp_rcontext.cc.

Here is the call graph for this function:

bool sp_rcontext::push_cursor ( sp_instr_cpush i)

Create a new sp_cursor instance and push it to the cursor stack.

Parameters
iCursor-push instruction.
Returns
error flag.
Return values
falseon success.
trueon error.

Definition at line 163 of file sp_rcontext.cc.

bool sp_rcontext::push_handler ( sp_handler handler,
uint  first_ip 
)

Create a new sp_handler_entry instance and push it to the handler call stack.

Parameters
handlerSQL-handler object.
first_ipFirst instruction pointer of the handler.
Returns
error flag.
Return values
falseon success.
trueon error.

Definition at line 194 of file sp_rcontext.cc.

Here is the call graph for this function:

bool sp_rcontext::set_case_expr ( THD *  thd,
int  case_expr_id,
Item **  case_expr_item_ptr 
)

Set CASE expression to the specified value.

Parameters
thdThread handler.
case_expr_idThe CASE expression identifier.
case_expr_itemThe CASE expression value
Returns
error flag.
Return values
falseon success.
trueon error.
Note
The idea is to reuse Item_cache for the expression of the one CASE statement. This optimization takes place when there is CASE statement inside of a loop. So, in other words, we will use the same object on each iteration instead of creating a new one for each iteration.

TODO Hypothetically, a type of CASE expression can be different for each iteration. For instance, this can happen if the expression contains a session variable (something like @VAR) and its type is changed from one iteration to another.

In order to cope with this problem, we check type each time, when we use already created object. If the type does not match, we re-create Item. This also can (should?) be optimized.

Definition at line 450 of file sp_rcontext.cc.

Here is the caller graph for this function:

Member Data Documentation

Query_arena* sp_rcontext::callers_arena

Arena used to (re) allocate items on. E.g. reallocate INOUT/OUT SP-variables when they don't fit into prealloced items. This is common situation with String items. It is used mainly in sp_eval_func_item().

Definition at line 192 of file sp_rcontext.h.

bool sp_rcontext::end_partial_result_set

Flag to end an open result set before start executing an SQL-handler (if one is found). Otherwise the client will hang due to a violation of the client/server protocol.

Definition at line 197 of file sp_rcontext.h.


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