19 #include "my_global.h"
20 #include "sp_pcontext.h"
21 #include "sql_class.h"
67 :Query_arena(0, STMT_INITIALIZED_FOR_SP),
88 virtual bool execute(THD *thd, uint *nextp) = 0;
99 {
return get_ip() + 1; }
137 bool opt_is_marked()
const
174 m_is_lex_owner(
false),
175 m_first_execution(
true),
176 m_prelocking_tables(NULL),
177 m_lex_query_tables_own_last(NULL)
179 set_lex(lex, is_lex_owner);
180 memset(&m_lex_mem_root, 0,
sizeof (
MEM_ROOT));
191 if (alloc_root_inited(&m_lex_mem_root))
193 free_root(&m_lex_mem_root, MYF(0));
236 bool reset_lex_and_exec_core(THD *thd, uint *nextp,
bool open_tables);
247 LEX *parse_expr(THD *thd,
sp_head *sp);
259 void set_lex(LEX *lex,
bool is_lex_owner);
288 virtual bool exec_core(THD *thd, uint *nextp) = 0;
324 {
return EMPTY_STR; }
368 bool m_first_execution;
405 :
sp_lex_instr(ip, lex->get_sp_current_parsing_ctx(), lex,
true),
414 virtual bool execute(THD *thd, uint *nextp);
420 virtual void print(
String *str);
426 virtual bool exec_core(THD *thd, uint *nextp);
435 { sql_query->append(m_query.str, m_query.length); }
465 :
sp_lex_instr(ip, lex->get_sp_current_parsing_ctx(), lex, is_lex_owner),
467 m_value_item(value_item),
468 m_value_query(value_query)
475 virtual void print(
String *str);
481 virtual bool exec_core(THD *thd, uint *nextp);
484 {
return m_value_item == NULL; }
487 { m_value_item= NULL; }
491 DBUG_ASSERT(thd->lex->select_lex.item_list.elements == 1);
493 m_value_item= thd->lex->select_lex.item_list.head();
499 {
return m_value_query; }
527 :
sp_lex_instr(ip, lex->get_sp_current_parsing_ctx(), lex,
true),
528 m_trigger_field_name(trigger_field_name),
529 m_trigger_field(trigger_field),
530 m_value_item(value_item),
531 m_value_query(value_query)
538 virtual void print(
String *str);
544 virtual bool exec_core(THD *thd, uint *nextp);
547 {
return m_value_item == NULL; }
550 { m_value_item= NULL; }
557 {
return m_value_query; }
585 enum enum_field_types return_field_type)
586 :
sp_lex_instr(ip, lex->get_sp_current_parsing_ctx(), lex,
true),
587 m_expr_item(expr_item),
588 m_expr_query(expr_query),
589 m_return_field_type(return_field_type)
596 virtual void print(
String *str);
612 virtual bool exec_core(THD *thd, uint *nextp);
615 {
return m_expr_item == NULL; }
625 DBUG_ASSERT(thd->lex->select_lex.item_list.elements == 1);
627 m_expr_item= thd->lex->select_lex.item_list.head();
633 {
return m_expr_query; }
643 enum enum_field_types m_return_field_type;
678 virtual void print(
String *str);
737 m_cont_optdest(NULL),
749 m_cont_optdest(NULL),
755 void set_cont_dest(uint cont_dest)
834 expr_item, expr_query)
843 expr_item, expr_query, dest)
850 virtual void print(
String *str);
856 virtual bool exec_core(THD *thd, uint *nextp);
860 DBUG_ASSERT(thd->lex->select_lex.item_list.elements == 1);
862 m_expr_item= thd->lex->select_lex.item_list.head();
882 Item *case_expr_item,
885 case_expr_item, case_expr_query),
886 m_case_expr_id(case_expr_id)
893 virtual void print(
String *str);
933 virtual bool exec_core(THD *thd, uint *nextp);
937 DBUG_ASSERT(thd->lex->select_lex.item_list.elements == 1);
939 m_expr_item= thd->lex->select_lex.item_list.head();
964 Item *when_expr_item,
967 when_expr_item, when_expr_query),
968 m_case_expr_id(case_expr_id)
975 virtual void print(
String *str);
981 virtual bool exec_core(THD *thd, uint *nextp);
986 m_case_expr_item= NULL;
992 {
return build_expr_items(thd); }
1015 bool build_expr_items(THD *thd);
1060 {
return m_handler; }
1066 virtual void print(
String *str);
1072 virtual bool execute(THD *thd, uint *nextp);
1078 {
return get_ip(); }
1086 DBUG_ASSERT(!
m_dest || !m_opt_hpop);
1118 virtual void print(
String *str)
1119 { str->append(STRING_WITH_LEN(
"hpop")); }
1125 virtual bool execute(THD *thd, uint *nextp);
1142 virtual void print(
String *str);
1148 virtual bool execute(THD *thd, uint *nextp);
1152 {
return get_ip(); }
1192 m_cursor_query(cursor_query),
1194 m_cursor_idx(cursor_idx)
1199 cursor_lex->safe_to_cache_query=
false;
1206 virtual void print(
String *str);
1224 virtual bool execute(THD *thd, uint *nextp);
1230 virtual bool exec_core(THD *thd, uint *nextp);
1233 {
return !m_valid; }
1239 { sql_query->append(m_cursor_query.str, m_cursor_query.length); }
1277 virtual void print(
String *str);
1283 virtual bool execute(THD *thd, uint *nextp);
1300 m_cursor_idx(cursor_idx)
1307 virtual void print(
String *str);
1313 virtual bool execute(THD *thd, uint *nextp);
1332 m_cursor_idx(cursor_idx)
1339 virtual void print(
String *str);
1345 virtual bool execute(THD *thd, uint *nextp);
1364 m_cursor_idx(cursor_idx)
1371 virtual void print(
String *str);
1377 virtual bool execute(THD *thd, uint *nextp);
1380 { m_varlist.push_back(var); }
1410 virtual void print(
String *str);
1418 my_message(m_errcode, ER(m_errcode), MYF(0));
1419 *nextp= get_ip() + 1;
1436 #endif // _SP_INSTR_H_