My Project
Classes | Public Member Functions | Static Public Member Functions | Public Attributes
sp_rcontext Class Reference
Inheritance diagram for sp_rcontext:
Sql_alloc

List of all members.

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)

Public Attributes

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

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.
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.
Returns:
the continue instruction pointer if the last activated CONTINUE handler. This function must not be called for the EXIT handlers.
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.
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.
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.

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.
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.
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.


Member Data Documentation

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().

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.


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