16 #ifndef _SP_RCONTEXT_H_
17 #define _SP_RCONTEXT_H_
19 #include "sql_class.h"
20 #include "sp_pcontext.h"
66 Field *return_value_fld);
72 Field *return_value_fld,
82 class sp_handler_entry
95 sp_handler_entry(
const sp_handler *_handler, uint _first_ip)
96 :
handler(_handler), first_ip(_first_ip)
123 Sql_condition::enum_warning_level
level;
138 const char *_sql_state,
139 Sql_condition::enum_warning_level _level,
140 const char *_message)
144 memcpy(
sql_state, _sql_state, SQLSTATE_LENGTH);
147 strncpy(
message, _message, MYSQL_ERRMSG_SIZE);
155 class Handler_call_frame
162 Sql_condition_info sql_condition_info;
176 Handler_call_frame(
const sp_handler *_handler,
178 const char *_sql_state,
179 Sql_condition::enum_warning_level _level,
180 const char *_message,
183 sql_condition_info(_sql_errno, _sql_state, _level, _message),
184 continue_ip(_continue_ip)
206 bool set_variable(THD *thd, uint var_idx,
Item **value)
207 {
return set_variable(thd, m_var_table->field[var_idx], value); }
209 Item *get_item(uint var_idx)
const
210 {
return m_var_items[var_idx]; }
212 Item **get_item_addr(uint var_idx)
const
213 {
return m_var_items.array() + var_idx; }
215 bool set_return_value(THD *thd,
Item **return_value_item);
217 bool is_return_value_set()
const
218 {
return m_return_value_set; }
241 const Sql_condition_info *raised_condition()
const
243 return m_activated_handlers.elements() ?
244 &(*m_activated_handlers.
back())->sql_condition_info : NULL;
281 uint ip= (*m_activated_handlers.
back())->continue_ip;
282 DBUG_ASSERT(ip != 0);
305 void pop_all_cursors()
309 {
return m_cstack[
i]; }
342 Item *get_case_expr(
int case_expr_id)
const
343 {
return m_case_expr_holders[case_expr_id]; }
345 Item ** get_case_expr_addr(
int case_expr_id)
const
346 {
return (
Item**) m_case_expr_holders.array() + case_expr_id; }
354 bool alloc_arrays(THD *thd);
363 bool init_var_table(THD *thd);
372 bool init_var_items(THD *thd);
384 Item_cache *create_case_expr_holder(THD *thd,
const Item *item)
const;
386 bool set_variable(THD *thd,
Field *field,
Item **value);
401 Field *m_return_value_fld;
405 bool m_return_value_set;
431 typedef class st_select_lex_unit SELECT_LEX_UNIT;
440 class Select_fetch_into_spvars:
public select_result_interceptor
445 Select_fetch_into_spvars() {}
446 uint get_field_count() {
return field_count; }
449 virtual bool send_eof() {
return FALSE; }
451 virtual int prepare(
List<Item> &list, SELECT_LEX_UNIT *u);
456 :m_server_side_cursor(NULL),
465 bool close(THD *thd);
468 {
return test(m_server_side_cursor); }
473 {
return m_push_instr; }
476 Select_fetch_into_spvars m_result;