#include <sp_rcontext.h>
Inheritance diagram for sp_rcontext:


Definition at line 64 of file sp_rcontext.h.
| sp_rcontext::sp_rcontext | ( | const sp_rcontext & | ) | [private] |
| sp_rcontext::sp_rcontext | ( | sp_pcontext * | root_parsing_ctx, | |
| Field * | return_value_fld, | |||
| sp_rcontext * | prev_runtime_ctx | |||
| ) |
Definition at line 33 of file sp_rcontext.cc.
00036 :m_root_parsing_ctx(root_parsing_ctx), 00037 m_var_table(0), 00038 m_var_items(0), 00039 m_return_value_fld(return_value_fld), 00040 m_return_value_set(FALSE), 00041 m_hcount(0), 00042 m_hsp(0), 00043 m_ihsp(0), 00044 m_hfound(-1), 00045 m_ccount(0), 00046 m_case_expr_holders(0), 00047 m_prev_runtime_ctx(prev_runtime_ctx) 00048 { 00049 }
| sp_rcontext::~sp_rcontext | ( | ) |
Definition at line 52 of file sp_rcontext.cc.
References free_blobs(), and m_var_table.
00053 { 00054 if (m_var_table) 00055 free_blobs(m_var_table); 00056 }
Here is the call graph for this function:

| void sp_rcontext::clear_handler | ( | ) | [inline] |
Definition at line 151 of file sp_rcontext.h.
References m_hfound.
00152 { 00153 m_hfound= -1; 00154 }
| Item_cache * sp_rcontext::create_case_expr_holder | ( | THD * | thd, | |
| Item_result | result_type | |||
| ) | [private] |
Definition at line 436 of file sp_rcontext.cc.
References Item_cache::get_cache().
Referenced by set_case_expr().
00437 { 00438 Item_cache *holder; 00439 Query_arena current_arena; 00440 00441 thd->set_n_backup_active_arena(thd->spcont->callers_arena, ¤t_arena); 00442 00443 holder= Item_cache::get_cache(result_type); 00444 00445 thd->restore_active_arena(thd->spcont->callers_arena, ¤t_arena); 00446 00447 return holder; 00448 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void sp_rcontext::enter_handler | ( | int | hid | ) | [inline] |
Definition at line 169 of file sp_rcontext.h.
References m_ihsp, and m_in_handler.
00170 { 00171 m_in_handler[m_ihsp++]= hid; 00172 }
| void sp_rcontext::exit_handler | ( | ) | [inline] |
| bool sp_rcontext::find_handler | ( | uint | sql_errno, | |
| MYSQL_ERROR::enum_warning_level | level | |||
| ) |
Definition at line 195 of file sp_rcontext.cc.
References sp_handler_t::cond, cond, sp_cond_type::exception, FALSE, find_handler(), IS_EXCEPTION_CONDITION, IS_NOT_FOUND_CONDITION, IS_WARNING_CONDITION, m_handler, m_hcount, m_hfound, m_ihsp, m_in_handler, m_prev_runtime_ctx, mysql_errno_to_sqlstate(), sp_cond_type::notfound, sp_cond_type::number, sp_cond_type::state, strcmp(), TRUE, sp_cond_type::type, MYSQL_ERROR::WARN_LEVEL_ERROR, MYSQL_ERROR::WARN_LEVEL_WARN, and sp_cond_type::warning.
Referenced by find_handler().
00197 { 00198 if (m_hfound >= 0) 00199 return 1; // Already got one 00200 00201 const char *sqlstate= mysql_errno_to_sqlstate(sql_errno); 00202 int i= m_hcount, found= -1; 00203 00204 /* Search handlers from the latest (innermost) to the oldest (outermost) */ 00205 while (i--) 00206 { 00207 sp_cond_type_t *cond= m_handler[i].cond; 00208 int j= m_ihsp; 00209 00210 /* Check active handlers, to avoid invoking one recursively */ 00211 while (j--) 00212 if (m_in_handler[j] == m_handler[i].handler) 00213 break; 00214 if (j >= 0) 00215 continue; // Already executing this handler 00216 00217 switch (cond->type) 00218 { 00219 case sp_cond_type_t::number: 00220 if (sql_errno == cond->mysqlerr && 00221 (found < 0 || m_handler[found].cond->type > sp_cond_type_t::number)) 00222 found= i; // Always the most specific 00223 break; 00224 case sp_cond_type_t::state: 00225 if (strcmp(sqlstate, cond->sqlstate) == 0 && 00226 (found < 0 || m_handler[found].cond->type > sp_cond_type_t::state)) 00227 found= i; 00228 break; 00229 case sp_cond_type_t::warning: 00230 if ((IS_WARNING_CONDITION(sqlstate) || 00231 level == MYSQL_ERROR::WARN_LEVEL_WARN) && 00232 found < 0) 00233 found= i; 00234 break; 00235 case sp_cond_type_t::notfound: 00236 if (IS_NOT_FOUND_CONDITION(sqlstate) && found < 0) 00237 found= i; 00238 break; 00239 case sp_cond_type_t::exception: 00240 if (IS_EXCEPTION_CONDITION(sqlstate) && 00241 level == MYSQL_ERROR::WARN_LEVEL_ERROR && 00242 found < 0) 00243 found= i; 00244 break; 00245 } 00246 } 00247 if (found < 0) 00248 { 00249 /* 00250 Only "exception conditions" are propagated to handlers in calling 00251 contexts. If no handler is found locally for a "completion condition" 00252 (warning or "not found") we will simply resume execution. 00253 */ 00254 if (m_prev_runtime_ctx && IS_EXCEPTION_CONDITION(sqlstate) && 00255 level == MYSQL_ERROR::WARN_LEVEL_ERROR) 00256 return m_prev_runtime_ctx->find_handler(sql_errno, level); 00257 return FALSE; 00258 } 00259 m_hfound= found; 00260 return TRUE; 00261 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 133 of file sp_rcontext.h.
References sp_handler_t::foffset, sp_handler_t::handler, m_handler, m_hfound, SP_HANDLER_NONE, and sp_handler_t::type.
00134 { 00135 if (m_hfound < 0) 00136 return SP_HANDLER_NONE; 00137 *ip= m_handler[m_hfound].handler; 00138 *fp= m_handler[m_hfound].foffset; 00139 return m_handler[m_hfound].type; 00140 }
| bool sp_rcontext::found_handler_here | ( | ) | [inline] |
Definition at line 144 of file sp_rcontext.h.
References m_hfound.
00145 { 00146 return (m_hfound >= 0); 00147 }
| Item * sp_rcontext::get_case_expr | ( | int | case_expr_id | ) |
Definition at line 502 of file sp_rcontext.cc.
References m_case_expr_holders.
00503 { 00504 return m_case_expr_holders[case_expr_id]; 00505 }
| Item ** sp_rcontext::get_case_expr_addr | ( | int | case_expr_id | ) |
Definition at line 509 of file sp_rcontext.cc.
References m_case_expr_holders.
00510 { 00511 return (Item**) m_case_expr_holders + case_expr_id; 00512 }
Definition at line 193 of file sp_rcontext.h.
References m_cstack.
00194 { 00195 return m_cstack[i]; 00196 }
Definition at line 302 of file sp_rcontext.cc.
References m_var_items.
Referenced by sp_head::execute_function().
00303 { 00304 return m_var_items[var_idx]; 00305 }
Here is the caller graph for this function:

Definition at line 309 of file sp_rcontext.cc.
References m_var_items.
Referenced by sp_head::execute_procedure().
00310 { 00311 return m_var_items + var_idx; 00312 }
Here is the caller graph for this function:

| bool sp_rcontext::init | ( | THD * | thd | ) |
Definition at line 69 of file sp_rcontext.cc.
References sp_pcontext::get_num_case_exprs(), init_var_items(), init_var_table(), m_case_expr_holders, m_cstack, m_handler, m_hstack, m_in_handler, m_root_parsing_ctx, sp_pcontext::max_cursor_index(), sp_pcontext::max_handler_index(), and TRUE.
Referenced by sp_head::execute_function(), sp_head::execute_procedure(), and sp_head::execute_trigger().
00070 { 00071 if (init_var_table(thd) || init_var_items()) 00072 return TRUE; 00073 00074 return 00075 !(m_handler= 00076 (sp_handler_t*)thd->alloc(m_root_parsing_ctx->max_handler_index() * 00077 sizeof(sp_handler_t))) || 00078 !(m_hstack= 00079 (uint*)thd->alloc(m_root_parsing_ctx->max_handler_index() * 00080 sizeof(uint))) || 00081 !(m_in_handler= 00082 (uint*)thd->alloc(m_root_parsing_ctx->max_handler_index() * 00083 sizeof(uint))) || 00084 !(m_cstack= 00085 (sp_cursor**)thd->alloc(m_root_parsing_ctx->max_cursor_index() * 00086 sizeof(sp_cursor*))) || 00087 !(m_case_expr_holders= 00088 (Item_cache**)thd->calloc(m_root_parsing_ctx->get_num_case_exprs() * 00089 sizeof (Item_cache*))); 00090 }
Here is the call graph for this function:

Here is the caller graph for this function:

| bool sp_rcontext::init_var_items | ( | ) | [private] |
Definition at line 134 of file sp_rcontext.cc.
References FALSE, st_table::field, m_root_parsing_ctx, m_var_items, m_var_table, sp_pcontext::max_var_index(), sql_alloc(), and TRUE.
Referenced by init().
00135 { 00136 uint idx; 00137 uint num_vars= m_root_parsing_ctx->max_var_index(); 00138 00139 if (!(m_var_items= (Item**) sql_alloc(num_vars * sizeof (Item *)))) 00140 return TRUE; 00141 00142 for (idx = 0; idx < num_vars; ++idx) 00143 { 00144 if (!(m_var_items[idx]= new Item_field(m_var_table->field[idx]))) 00145 return TRUE; 00146 } 00147 00148 return FALSE; 00149 }
Here is the call graph for this function:

Here is the caller graph for this function:

| bool sp_rcontext::init_var_table | ( | THD * | thd | ) | [private] |
Definition at line 104 of file sp_rcontext.cc.
References st_table::alias, st_table::copy_blobs, create_virtual_tmp_table(), DBUG_ASSERT, FALSE, m_root_parsing_ctx, m_var_table, sp_pcontext::max_var_index(), sp_pcontext::retrieve_field_definitions(), and TRUE.
Referenced by init().
00105 { 00106 List<create_field> field_def_lst; 00107 00108 if (!m_root_parsing_ctx->max_var_index()) 00109 return FALSE; 00110 00111 m_root_parsing_ctx->retrieve_field_definitions(&field_def_lst); 00112 00113 DBUG_ASSERT(field_def_lst.elements == m_root_parsing_ctx->max_var_index()); 00114 00115 if (!(m_var_table= create_virtual_tmp_table(thd, field_def_lst))) 00116 return TRUE; 00117 00118 m_var_table->copy_blobs= TRUE; 00119 m_var_table->alias= ""; 00120 00121 return FALSE; 00122 }
Here is the call graph for this function:

Here is the caller graph for this function:

| bool sp_rcontext::is_return_value_set | ( | ) | const [inline] |
Definition at line 106 of file sp_rcontext.h.
References m_return_value_set.
Referenced by sp_head::execute_function().
00107 { 00108 return m_return_value_set; 00109 }
Here is the caller graph for this function:

| void sp_rcontext::operator= | ( | sp_rcontext & | ) | [private] |
| void sp_rcontext::pop_all_cursors | ( | ) | [inline] |
Definition at line 187 of file sp_rcontext.h.
References m_ccount, and pop_cursors().
00188 { 00189 pop_cursors(m_ccount); 00190 }
Here is the call graph for this function:

| void sp_rcontext::pop_cursors | ( | uint | count | ) |
Definition at line 272 of file sp_rcontext.cc.
References m_ccount, and m_cstack.
Referenced by pop_all_cursors().
Here is the caller graph for this function:

| void sp_rcontext::pop_handlers | ( | uint | count | ) | [inline] |
| uint sp_rcontext::pop_hstack | ( | ) | [inline] |
| void sp_rcontext::push_cursor | ( | sp_lex_keeper * | lex_keeper, | |
| sp_instr_cpush * | i | |||
| ) |
| void sp_rcontext::push_handler | ( | struct sp_cond_type * | cond, | |
| uint | h, | |||
| int | type, | |||
| uint | f | |||
| ) | [inline] |
Definition at line 112 of file sp_rcontext.h.
References cond, sp_handler_t::cond, sp_handler_t::foffset, sp_handler_t::handler, m_handler, m_hcount, and sp_handler_t::type.
00113 { 00114 m_handler[m_hcount].cond= cond; 00115 m_handler[m_hcount].handler= h; 00116 m_handler[m_hcount].type= type; 00117 m_handler[m_hcount].foffset= f; 00118 m_hcount+= 1; 00119 }
| void sp_rcontext::push_hstack | ( | uint | h | ) | [inline] |
| int sp_rcontext::set_case_expr | ( | THD * | thd, | |
| int | case_expr_id, | |||
| Item ** | case_expr_item_ptr | |||
| ) |
Definition at line 481 of file sp_rcontext.cc.
References create_case_expr_holder(), FALSE, m_case_expr_holders, Item::result_type(), sp_prepare_func_item(), Item_cache::store(), and TRUE.
00482 { 00483 Item *case_expr_item= sp_prepare_func_item(thd, case_expr_item_ptr); 00484 if (!case_expr_item) 00485 return TRUE; 00486 00487 if (!m_case_expr_holders[case_expr_id] || 00488 m_case_expr_holders[case_expr_id]->result_type() != 00489 case_expr_item->result_type()) 00490 { 00491 m_case_expr_holders[case_expr_id]= 00492 create_case_expr_holder(thd, case_expr_item->result_type()); 00493 } 00494 00495 m_case_expr_holders[case_expr_id]->store(case_expr_item); 00496 00497 return FALSE; 00498 }
Here is the call graph for this function:

Definition at line 153 of file sp_rcontext.cc.
References DBUG_ASSERT, m_return_value_fld, m_return_value_set, sp_eval_expr(), and TRUE.
00154 { 00155 DBUG_ASSERT(m_return_value_fld); 00156 00157 m_return_value_set = TRUE; 00158 00159 return sp_eval_expr(thd, m_return_value_fld, return_value_item); 00160 }
Here is the call graph for this function:

Definition at line 289 of file sp_rcontext.cc.
References Field::set_null(), sp_eval_expr(), and value.
00290 { 00291 if (!value) 00292 { 00293 field->set_null(); 00294 return 0; 00295 } 00296 00297 return sp_eval_expr(thd, field, value); 00298 }
Here is the call graph for this function:

Definition at line 282 of file sp_rcontext.cc.
References st_table::field, m_var_table, and value.
Referenced by sp_head::execute_function(), and sp_head::execute_procedure().
00283 { 00284 return set_variable(thd, m_var_table->field[var_idx], value); 00285 }
Here is the caller graph for this function:

| Query_arena* sp_rcontext::callers_arena |
Item_cache** sp_rcontext::m_case_expr_holders [private] |
Definition at line 246 of file sp_rcontext.h.
Referenced by get_case_expr(), get_case_expr_addr(), init(), and set_case_expr().
uint sp_rcontext::m_ccount [private] |
Definition at line 244 of file sp_rcontext.h.
Referenced by pop_all_cursors(), pop_cursors(), and push_cursor().
sp_cursor** sp_rcontext::m_cstack [private] |
Definition at line 243 of file sp_rcontext.h.
Referenced by get_cursor(), init(), pop_cursors(), and push_cursor().
sp_handler_t* sp_rcontext::m_handler [private] |
Definition at line 235 of file sp_rcontext.h.
Referenced by find_handler(), found_handler(), init(), and push_handler().
uint sp_rcontext::m_hcount [private] |
Definition at line 236 of file sp_rcontext.h.
Referenced by find_handler(), pop_handlers(), and push_handler().
int sp_rcontext::m_hfound [private] |
Definition at line 241 of file sp_rcontext.h.
Referenced by clear_handler(), find_handler(), found_handler(), and found_handler_here().
uint sp_rcontext::m_hsp [private] |
uint* sp_rcontext::m_hstack [private] |
Definition at line 237 of file sp_rcontext.h.
Referenced by init(), pop_hstack(), and push_hstack().
uint sp_rcontext::m_ihsp [private] |
Definition at line 240 of file sp_rcontext.h.
Referenced by enter_handler(), exit_handler(), and find_handler().
uint* sp_rcontext::m_in_handler [private] |
Definition at line 239 of file sp_rcontext.h.
Referenced by enter_handler(), find_handler(), and init().
sp_rcontext* sp_rcontext::m_prev_runtime_ctx [private] |
Field* sp_rcontext::m_return_value_fld [private] |
bool sp_rcontext::m_return_value_set [private] |
Definition at line 233 of file sp_rcontext.h.
Referenced by is_return_value_set(), and set_return_value().
sp_pcontext* sp_rcontext::m_root_parsing_ctx [private] |
Definition at line 212 of file sp_rcontext.h.
Referenced by init(), init_var_items(), and init_var_table().
Item** sp_rcontext::m_var_items [private] |
Definition at line 221 of file sp_rcontext.h.
Referenced by get_item(), get_item_addr(), and init_var_items().
TABLE* sp_rcontext::m_var_table [private] |
Definition at line 215 of file sp_rcontext.h.
Referenced by init_var_items(), init_var_table(), set_variable(), and ~sp_rcontext().
Definition at line 84 of file sp_rcontext.h.
Referenced by sp_head::execute_function(), sp_head::execute_procedure(), and sp_head::execute_trigger().
1.4.7

