24 #include "my_global.h"
25 #include "sql_class.h"
27 #include "sp_pcontext.h"
48 virtual void print(
String *str) = 0;
75 m_db_cl(thd->variables.collation_database)
86 virtual void change_env(THD *thd)
const
88 thd->variables.collation_database=
m_db_cl;
90 Default_object_creation_ctx::change_env(thd);
138 struct Backpatch_info
146 m_expr_start_ptr(NULL),
147 m_current_stmt_start_ptr(NULL),
148 m_option_start_ptr(NULL),
149 m_param_start_ptr(NULL),
150 m_param_end_ptr(NULL),
151 m_body_start_ptr(NULL),
153 m_saved_memroot(NULL),
154 m_saved_free_list(NULL)
196 thd->mem_root= m_saved_memroot;
197 thd->free_list= m_saved_free_list;
199 m_saved_memroot= NULL;
200 m_saved_free_list= NULL;
208 {
return m_saved_memroot != NULL; }
212 void process_new_sp_instr(THD *thd,
sp_instr *
i);
229 DBUG_ASSERT(m_expr_start_ptr);
230 const char *p= m_expr_start_ptr;
231 m_expr_start_ptr= NULL;
234 return m_expr_start_ptr;
248 DBUG_ASSERT(!m_expr_start_ptr);
249 m_expr_start_ptr= expr_start_ptr;
254 const char *get_current_stmt_start_ptr()
const
255 {
return m_current_stmt_start_ptr; }
257 void set_current_stmt_start_ptr(
const char *stmt_start_ptr)
258 { m_current_stmt_start_ptr= stmt_start_ptr; }
262 const char *get_option_start_ptr()
const
263 {
return m_option_start_ptr; }
265 void set_option_start_ptr(
const char *option_start_ptr)
266 { m_option_start_ptr= option_start_ptr; }
270 const char *get_parameter_start_ptr()
const
271 {
return m_param_start_ptr; }
273 void set_parameter_start_ptr(
const char *ptr)
274 { m_param_start_ptr= ptr; }
276 const char *get_parameter_end_ptr()
const
277 {
return m_param_end_ptr; }
279 void set_parameter_end_ptr(
const char *ptr)
280 { m_param_end_ptr= ptr; }
284 const char *get_body_start_ptr()
const
285 {
return m_body_start_ptr; }
287 void set_body_start_ptr(
const char *ptr)
288 { m_body_start_ptr= ptr; }
292 void push_lex(LEX *lex)
293 { m_lex_stack.push_front(lex); }
296 {
return m_lex_stack.pop(); }
370 const char *m_expr_start_ptr;
373 const char *m_current_stmt_start_ptr;
376 const char *m_option_start_ptr;
389 const char *m_param_start_ptr;
396 const char *m_param_end_ptr;
402 const char *m_body_start_ptr;
433 Item *m_saved_free_list;
449 CONTAINS_DYNAMIC_SQL= 16,
451 HAS_SET_AUTOCOMMIT_STMT= 64,
453 HAS_COMMIT_OR_ROLLBACK= 128,
454 LOG_SLOW_STATEMENTS= 256,
455 LOG_GENERAL_LOG= 512,
456 HAS_SQLCOM_RESET= 1024,
457 HAS_SQLCOM_FLUSH= 2048,
564 Security_context m_security_ctx;
586 static void *
operator new(
size_t size)
throw ();
587 static void operator delete(
void *ptr,
size_t size)
throw ();
593 {
return m_flags & IS_INVOKED; }
600 {
return m_sp_cache_version; }
607 {
return m_creation_ctx; }
610 { m_creation_ctx= creation_ctx->clone(mem_root); }
726 {
return m_instructions.elements(); }
729 {
return *m_instructions.
back(); }
749 char *
name(uint *lenp = 0)
const
752 *lenp= (uint) m_name.length;
756 char *create_string(THD *thd, ulong *lenp);
770 const char *field_name,
773 void set_info(longlong created,
775 st_sp_chistics *chistics,
776 sql_mode_t sql_mode);
778 void set_definer(
const char *definer, uint definerlen);
816 return (i < (uint) m_instructions.elements()) ? m_instructions.
at(i) : NULL;
849 if (
m_flags & CONTAINS_DYNAMIC_SQL)
850 my_error(ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG, MYF(0),
"Dynamic SQL");
851 else if (
m_flags & MULTI_RESULTS)
852 my_error(ER_SP_NO_RETSET, MYF(0), where);
853 else if (
m_flags & HAS_SET_AUTOCOMMIT_STMT)
854 my_error(ER_SP_CANT_SET_AUTOCOMMIT, MYF(0));
855 else if (
m_flags & HAS_COMMIT_OR_ROLLBACK)
856 my_error(ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG, MYF(0));
857 else if (
m_flags & HAS_SQLCOM_RESET)
858 my_error(ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG, MYF(0),
"RESET");
859 else if (
m_flags & HAS_SQLCOM_FLUSH)
860 my_error(ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG, MYF(0),
"FLUSH");
863 (CONTAINS_DYNAMIC_SQL|MULTI_RESULTS|HAS_SET_AUTOCOMMIT_STMT|
864 HAS_COMMIT_OR_ROLLBACK|HAS_SQLCOM_RESET|HAS_SQLCOM_FLUSH));
880 void propagate_attributes(Query_tables_list *prelocking_ctx)
888 DBUG_PRINT(
"info", (
"lex->get_stmt_unsafe_flags(): 0x%x",
889 prelocking_ctx->get_stmt_unsafe_flags()));
890 DBUG_PRINT(
"info", (
"sp_head(0x%p=%s)->unsafe_flags: 0x%x",
891 this,
name(), unsafe_flags));
892 prelocking_ctx->set_stmt_unsafe_flags(unsafe_flags);
899 {
return const_cast<sp_pcontext *
> (m_root_parsing_ctx); }
906 {
return const_cast<MEM_ROOT *
> (&main_mem_root); }
912 {
return const_cast<MEM_ROOT *
> (mem_root); }
926 #ifndef NO_EMBEDDED_ACCESS_CHECKS
978 ulong m_sp_cache_version;
988 void init_sp_name(THD *thd,
sp_name *spname);
1005 bool execute(THD *thd,
bool merge_da_on_success);
1028 bool merge_table_list(THD *thd,
TABLE_LIST *
table, LEX *lex_for_tmp_check);