| MySQL 5.6.14 Source Code Document
    | 
#include <sp_pcontext.h>


| Public Types | |
| enum | enum_scope { REGULAR_SCOPE, HANDLER_SCOPE } | 
| Public Member Functions | |
| sp_pcontext * | push_context (THD *thd, enum_scope scope) | 
| Create and push a new context in the tree. | |
| sp_pcontext * | pop_context () | 
| sp_pcontext * | parent_context () const | 
| int | get_level () const | 
| uint | diff_handlers (const sp_pcontext *ctx, bool exclusive) const | 
| uint | diff_cursors (const sp_pcontext *ctx, bool exclusive) const | 
| uint | max_var_index () const | 
| uint | current_var_count () const | 
| uint | context_var_count () const | 
| uint | var_context2runtime (uint i) const | 
| sp_variable * | add_variable (THD *thd, LEX_STRING name, enum enum_field_types type, sp_variable::enum_mode mode) | 
| void | retrieve_field_definitions (List< Create_field > *field_def_lst) const | 
| sp_variable * | find_variable (LEX_STRING name, bool current_scope_only) const | 
| sp_variable * | find_variable (uint offset) const | 
| void | declare_var_boundary (uint n) | 
| int | get_num_case_exprs () const | 
| int | push_case_expr_id () | 
| void | pop_case_expr_id () | 
| int | get_current_case_expr_id () const | 
| sp_label * | push_label (THD *thd, LEX_STRING name, uint ip) | 
| sp_label * | find_label (LEX_STRING name) | 
| sp_label * | last_label () | 
| sp_label * | pop_label () | 
| bool | add_condition (THD *thd, LEX_STRING name, sp_condition_value *value) | 
| sp_condition_value * | find_condition (LEX_STRING name, bool current_scope_only) const | 
| See comment for find_variable() above. | |
| sp_handler * | add_handler (THD *thd, sp_handler::enum_type type) | 
| bool | check_duplicate_handler (const sp_condition_value *cond_value) const | 
| sp_handler * | find_handler (const char *sql_state, uint sql_errno, Sql_condition::enum_warning_level level) const | 
| bool | add_cursor (LEX_STRING name) | 
| bool | find_cursor (LEX_STRING name, uint *poff, bool current_scope_only) const | 
| See comment for find_variable() above. | |
| const LEX_STRING * | find_cursor (uint offset) const | 
| Find cursor by offset (for debugging only). | |
| uint | max_cursor_index () const | 
| uint | current_cursor_count () const | 
| Additional Inherited Members | |
|  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) | 
The class represents parse-time context, which keeps track of declared variables/parameters, conditions, handlers, cursors and labels.
sp_context objects are organized in a tree according to the following rules:
sp_pcontext objects are used both at parse-time and at runtime.
During the parsing stage sp_pcontext objects are used:
During the runtime phase, a tree of sp_pcontext objects is used:
Definition at line 262 of file sp_pcontext.h.
| REGULAR_SCOPE | REGULAR_SCOPE designates regular BEGIN ... END blocks. | 
| HANDLER_SCOPE | HANDLER_SCOPE designates SQL-handler blocks. | 
Definition at line 265 of file sp_pcontext.h.
| sp_variable * sp_pcontext::add_variable | ( | THD * | thd, | 
| LEX_STRING | name, | ||
| enum enum_field_types | type, | ||
| sp_variable::enum_mode | mode | ||
| ) | 
Add SP-variable to the parsing context.
| thd | Thread context. | 
| name | Name of the SP-variable. | 
| type | Type of the SP-variable. | 
| mode | Mode of the SP-variable. | 
Definition at line 184 of file sp_pcontext.cc.

| bool sp_pcontext::check_duplicate_handler | ( | const sp_condition_value * | cond_value | ) | const | 
This is an auxilary parsing-time function to check if an SQL-handler exists in the current parsing context (current scope) for the given SQL-condition. This function is used to check for duplicates during the parsing phase.
This function can not be used during the runtime phase to check SQL-handler existence because it searches for the SQL-handler in the current scope only (during runtime, current and parent scopes should be checked according to the SQL-handler resolution rules).
| condition_value | the handler condition value (not SQL-condition!). | 
| true | if such SQL-handler exists. | 
| false | otherwise. | 
Definition at line 288 of file sp_pcontext.cc.

| 
 | inline | 
Definition at line 336 of file sp_pcontext.h.

| 
 | inline | 
Definition at line 332 of file sp_pcontext.h.

| 
 | inline | 
Set the current scope boundary (for default values).
| n | The number of variables to skip. | 
Definition at line 390 of file sp_pcontext.h.
| uint sp_pcontext::diff_cursors | ( | const sp_pcontext * | ctx, | 
| bool | exclusive | ||
| ) | const | 
Calculate and return the number of cursors to pop between the given context and this one.
| ctx | the other parsing context. | 
| exclusive | specifies if the last scope should be excluded. | 
Definition at line 132 of file sp_pcontext.cc.
| uint sp_pcontext::diff_handlers | ( | const sp_pcontext * | ctx, | 
| bool | exclusive | ||
| ) | const | 
Calculate and return the number of handlers to pop between the given context and this one.
| ctx | the other parsing context. | 
| exclusive | specifies if the last scope should be excluded. | 
Definition at line 114 of file sp_pcontext.cc.
| sp_handler * sp_pcontext::find_handler | ( | const char * | sql_state, | 
| uint | sql_errno, | ||
| Sql_condition::enum_warning_level | level | ||
| ) | const | 
Find an SQL handler for the given SQL condition according to the SQL-handler resolution rules. This function is used at runtime.
| sql_state | The SQL condition state | 
| sql_errno | The error code | 
| level | The SQL condition level | 
Definition at line 310 of file sp_pcontext.cc.


| sp_variable * sp_pcontext::find_variable | ( | LEX_STRING | name, | 
| bool | current_scope_only | ||
| ) | const | 
Find SP-variable by name.
The function does a linear search (from newer to older variables, in case we have shadowed names).
The function is called only at parsing time.
| name | Variable name. | 
| current_scope_only | A flag if we search only in current scope. | 
Definition at line 150 of file sp_pcontext.cc.


| sp_variable * sp_pcontext::find_variable | ( | uint | offset | ) | const | 
Find SP-variable by the offset in the root parsing context.
The function is used for two things:
| offset | Variable offset in the root parsing context. | 
Definition at line 173 of file sp_pcontext.cc.

| 
 | inline | 
Definition at line 327 of file sp_pcontext.h.
| sp_pcontext * sp_pcontext::pop_context | ( | ) | 
Pop a node from the parsing context tree.
Definition at line 99 of file sp_pcontext.cc.
| sp_pcontext * sp_pcontext::push_context | ( | THD * | thd, | 
| sp_pcontext::enum_scope | scope | ||
| ) | 
Create and push a new context in the tree.
| thd | thread context. | 
| scope | scope of the new parsing context. | 
Definition at line 89 of file sp_pcontext.cc.

| void sp_pcontext::retrieve_field_definitions | ( | List< Create_field > * | field_def_lst | ) | const | 
Retrieve full type information about SP-variables in this parsing context and its children.
| field_def_lst[out] | Container to store type information. | 
Definition at line 453 of file sp_pcontext.cc.


| 
 | inline | 
Definition at line 340 of file sp_pcontext.h.