#include <sp_rcontext.h>
|
| ~sp_rcontext () |
|
bool | set_variable (THD *thd, bool standalone, uint var_idx, Item **value) |
|
Item * | get_item (uint var_idx) const |
|
Item ** | get_item_addr (uint var_idx) const |
|
bool | set_return_value (THD *thd, bool standalone, Item **return_value_item) |
|
bool | is_return_value_set () const |
|
bool | push_handler (sp_handler *handler, uint first_ip) |
| Create a new sp_handler_entry instance and push it to the handler call stack. More...
|
|
void | pop_handlers (sp_pcontext *current_scope) |
| Pop and delete given number of sp_handler_entry instances from the handler call stack. More...
|
|
Handler_call_frame * | current_handler_frame () const |
| Get the Handler_call_frame representing the currently active handler. More...
|
|
bool | handle_sql_condition (THD *thd, uint *ip, const sp_instr *cur_spi) |
| Handle current SQL condition (if any). More...
|
|
void | exit_handler (THD *thd, sp_pcontext *target_scope) |
| Handle return from SQL-handler. More...
|
|
uint | get_last_handler_continue_ip () const |
|
bool | push_cursor (sp_instr_cpush *i) |
| Create a new sp_cursor instance and push it to the cursor stack. More...
|
|
void | pop_cursors (uint count) |
| Pop and delete given number of sp_cursor instance from the cursor stack. More...
|
|
void | pop_all_cursors () |
|
sp_cursor * | get_cursor (uint i) const |
|
bool | set_case_expr (THD *thd, bool standalone, int case_expr_id, Item **case_expr_item_ptr) |
| Set CASE expression to the specified value. More...
|
|
Item * | get_case_expr (int case_expr_id) const |
|
Item ** | get_case_expr_addr (int case_expr_id) const |
|
◆ ~sp_rcontext()
sp_rcontext::~sp_rcontext |
( |
| ) |
|
◆ sp_rcontext() [1/2]
sp_rcontext::sp_rcontext |
( |
const sp_pcontext * |
root_parsing_ctx, |
|
|
Field * |
return_value_fld, |
|
|
bool |
in_sub_stmt |
|
) |
| |
|
private |
◆ sp_rcontext() [2/2]
◆ alloc_arrays()
bool sp_rcontext::alloc_arrays |
( |
THD * |
thd | ) |
|
|
private |
Internal function to allocate memory for arrays.
- Parameters
-
- Returns
- error flag: false on success, true in case of failure.
◆ create()
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
-
thd | Thread handle. |
root_parsing_ctx | Top-level parsing context for this stored program. |
return_value_fld | Field object to store the return value (for stored functions only). |
- Returns
- valid sp_rcontext object or NULL in case of OOM-error.
◆ create_case_expr_holder()
Item_cache * sp_rcontext::create_case_expr_holder |
( |
THD * |
thd, |
|
|
const Item * |
item |
|
) |
| const |
|
private |
Create an instance of appropriate Item_cache class depending on the specified type in the callers arena.
- Note
- We should create cache items in the callers arena, as they are used between in several instructions.
- Parameters
-
thd | Thread handler. |
item | Item to get the expression type. |
- Returns
- Pointer to valid object on success, or NULL in case of error.
◆ current_handler_frame()
Get the Handler_call_frame representing the currently active handler.
◆ exit_handler()
void sp_rcontext::exit_handler |
( |
THD * |
thd, |
|
|
sp_pcontext * |
target_scope |
|
) |
| |
Handle return from SQL-handler.
- Parameters
-
thd | Thread handle. |
target_scope | The BEGIN..END block, containing the target (next) instruction. |
◆ get_case_expr()
Item * sp_rcontext::get_case_expr |
( |
int |
case_expr_id | ) |
const |
|
inline |
◆ get_case_expr_addr()
Item ** sp_rcontext::get_case_expr_addr |
( |
int |
case_expr_id | ) |
const |
|
inline |
◆ get_cursor()
◆ get_item()
Item * sp_rcontext::get_item |
( |
uint |
var_idx | ) |
const |
|
inline |
◆ get_item_addr()
Item ** sp_rcontext::get_item_addr |
( |
uint |
var_idx | ) |
const |
|
inline |
◆ get_last_handler_continue_ip()
uint sp_rcontext::get_last_handler_continue_ip |
( |
| ) |
const |
|
inline |
- Returns
- the continue instruction pointer of the last activated CONTINUE handler. This function must not be called for the EXIT handlers.
◆ handle_sql_condition()
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
-
| thd | Thread handle. |
[out] | ip | Instruction pointer to the first handler instruction. |
| cur_spi | Current SP instruction. |
- Return values
-
true | if 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.
|
false | otherwise. |
◆ init_var_items()
bool sp_rcontext::init_var_items |
( |
THD * |
thd | ) |
|
|
private |
Create and initialize an Item-adapter (Item_field) for each SP-var field.
param thd Thread handle.
- Returns
- error flag.
- Return values
-
false | on success. |
true | on error. |
◆ init_var_table()
bool sp_rcontext::init_var_table |
( |
THD * |
thd | ) |
|
|
private |
Create and initialize a table to store SP-variables.
param thd Thread handle.
- Returns
- error flag.
- Return values
-
false | on success. |
true | on error. |
◆ is_return_value_set()
bool sp_rcontext::is_return_value_set |
( |
| ) |
const |
|
inline |
◆ operator=()
◆ pop_all_cursors()
void sp_rcontext::pop_all_cursors |
( |
| ) |
|
|
inline |
◆ pop_cursors()
void sp_rcontext::pop_cursors |
( |
uint |
count | ) |
|
Pop and delete given number of sp_cursor instance from the cursor stack.
- Parameters
-
count | Number of cursors to pop & delete. |
◆ pop_handler_frame()
void sp_rcontext::pop_handler_frame |
( |
THD * |
thd | ) |
|
|
private |
Pop the Handler_call_frame on top of the stack of active handlers.
Also pop the matching Diagnostics Area and transfer conditions.
◆ pop_handlers()
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_scope | The current BEGIN..END block. |
◆ push_cursor()
Create a new sp_cursor instance and push it to the cursor stack.
- Parameters
-
i | Cursor-push instruction. |
- Returns
- error flag.
- Return values
-
false | on success. |
true | on error. |
◆ push_handler()
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
-
handler | SQL-handler object. |
first_ip | First instruction pointer of the handler. |
- Returns
- error flag.
- Return values
-
false | on success. |
true | on error. |
◆ set_case_expr()
bool sp_rcontext::set_case_expr |
( |
THD * |
thd, |
|
|
bool |
standalone, |
|
|
int |
case_expr_id, |
|
|
Item ** |
case_expr_item_ptr |
|
) |
| |
Set CASE expression to the specified value.
- Parameters
-
thd | Thread handler. |
standalone | Whether instruction is a standalone query expr. |
case_expr_id | The CASE expression identifier. |
case_expr_item_ptr | The CASE expression value |
- Returns
- false on success, true on 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.
◆ set_return_value()
bool sp_rcontext::set_return_value |
( |
THD * |
thd, |
|
|
bool |
standalone, |
|
|
Item ** |
return_value_item |
|
) |
| |
◆ set_variable() [1/2]
bool sp_rcontext::set_variable |
( |
THD * |
thd, |
|
|
bool |
standalone, |
|
|
Field * |
field, |
|
|
Item ** |
value |
|
) |
| |
|
private |
◆ set_variable() [2/2]
bool sp_rcontext::set_variable |
( |
THD * |
thd, |
|
|
bool |
standalone, |
|
|
uint |
var_idx, |
|
|
Item ** |
value |
|
) |
| |
|
inline |
◆ 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().
◆ end_partial_result_set
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.
◆ m_activated_handlers
Stack of caught SQL conditions.
◆ m_case_expr_holders
Array of CASE expression holders.
◆ m_ccount
uint sp_rcontext::m_ccount |
|
private |
Current number of cursors in m_cstack.
◆ m_cstack
◆ m_in_sub_stmt
bool sp_rcontext::m_in_sub_stmt |
|
private |
Flag to tell if the runtime context is created for a sub-statement.
◆ m_return_value_fld
Field* sp_rcontext::m_return_value_fld |
|
private |
This is a pointer to a field, which should contain return value for stored functions (only).
For stored procedures, this pointer is NULL.
◆ m_return_value_set
bool sp_rcontext::m_return_value_set |
|
private |
Indicates whether the return value (in m_return_value_fld) has been set during execution.
◆ m_root_parsing_ctx
Top-level (root) parsing context for this runtime context.
◆ m_var_items
Collection of Item_field proxies, each of them points to the corresponding field in m_var_table.
◆ m_var_table
TABLE* sp_rcontext::m_var_table |
|
private |
Virtual table for storing SP-variables.
◆ m_visible_handlers
Stack of visible handlers.
◆ sp
The stored program for which this runtime context is created.
The documentation for this class was generated from the following files: