diff options
-rw-r--r-- | sql/item.cc | 18 | ||||
-rw-r--r-- | sql/item.h | 2 | ||||
-rw-r--r-- | sql/sp_head.cc | 18 | ||||
-rw-r--r-- | sql/sp_rcontext.cc | 10 | ||||
-rw-r--r-- | sql/sp_rcontext.h | 6 |
5 files changed, 24 insertions, 30 deletions
diff --git a/sql/item.cc b/sql/item.cc index f609bfdf082..72703c2f7b0 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1778,7 +1778,7 @@ bool Item_splocal::fix_fields(THD *thd, Item **ref) Item * Item_splocal::this_item() { - DBUG_ASSERT(m_sp == m_thd->spcont->sp); + DBUG_ASSERT(m_sp == m_thd->spcont->m_sp); DBUG_ASSERT(fixed); return m_thd->spcont->get_item(m_var_idx); } @@ -1786,7 +1786,7 @@ Item_splocal::this_item() const Item * Item_splocal::this_item() const { - DBUG_ASSERT(m_sp == m_thd->spcont->sp); + DBUG_ASSERT(m_sp == m_thd->spcont->m_sp); DBUG_ASSERT(fixed); return m_thd->spcont->get_item(m_var_idx); } @@ -1795,7 +1795,7 @@ Item_splocal::this_item() const Item ** Item_splocal::this_item_addr(THD *thd, Item **) { - DBUG_ASSERT(m_sp == thd->spcont->sp); + DBUG_ASSERT(m_sp == thd->spcont->m_sp); DBUG_ASSERT(fixed); return thd->spcont->get_item_addr(m_var_idx); } @@ -1902,7 +1902,7 @@ bool Item_splocal_row_field::fix_fields(THD *thd, Item **ref) Item * Item_splocal_row_field::this_item() { - DBUG_ASSERT(m_sp == m_thd->spcont->sp); + DBUG_ASSERT(m_sp == m_thd->spcont->m_sp); DBUG_ASSERT(fixed); return m_thd->spcont->get_item(m_var_idx)->element_index(m_field_idx); } @@ -1911,7 +1911,7 @@ Item_splocal_row_field::this_item() const Item * Item_splocal_row_field::this_item() const { - DBUG_ASSERT(m_sp == m_thd->spcont->sp); + DBUG_ASSERT(m_sp == m_thd->spcont->m_sp); DBUG_ASSERT(fixed); return m_thd->spcont->get_item(m_var_idx)->element_index(m_field_idx); } @@ -1920,7 +1920,7 @@ Item_splocal_row_field::this_item() const Item ** Item_splocal_row_field::this_item_addr(THD *thd, Item **) { - DBUG_ASSERT(m_sp == thd->spcont->sp); + DBUG_ASSERT(m_sp == thd->spcont->m_sp); DBUG_ASSERT(fixed); return thd->spcont->get_item(m_var_idx)->addr(m_field_idx); } @@ -2008,7 +2008,7 @@ bool Item_case_expr::fix_fields(THD *thd, Item **ref) Item * Item_case_expr::this_item() { - DBUG_ASSERT(m_sp == m_thd->spcont->sp); + DBUG_ASSERT(m_sp == m_thd->spcont->m_sp); return m_thd->spcont->get_case_expr(m_case_expr_id); } @@ -2018,7 +2018,7 @@ Item_case_expr::this_item() const Item * Item_case_expr::this_item() const { - DBUG_ASSERT(m_sp == m_thd->spcont->sp); + DBUG_ASSERT(m_sp == m_thd->spcont->m_sp); return m_thd->spcont->get_case_expr(m_case_expr_id); } @@ -2027,7 +2027,7 @@ Item_case_expr::this_item() const Item ** Item_case_expr::this_item_addr(THD *thd, Item **) { - DBUG_ASSERT(m_sp == thd->spcont->sp); + DBUG_ASSERT(m_sp == thd->spcont->m_sp); return thd->spcont->get_case_expr_addr(m_case_expr_id); } diff --git a/sql/item.h b/sql/item.h index 82106fea92b..f21c88c69a4 100644 --- a/sql/item.h +++ b/sql/item.h @@ -2271,7 +2271,7 @@ public: Routine to which this Item_splocal belongs. Used for checking if correct runtime context is used for variable handling. */ - sp_head *m_sp; + const sp_head *m_sp; #endif public: diff --git a/sql/sp_head.cc b/sql/sp_head.cc index a6377b319af..ed4b76026a0 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -1444,7 +1444,7 @@ sp_rcontext *sp_head::rcontext_create(THD *thd, Field *ret_value, bool switch_security_ctx) { if (!(m_flags & HAS_COLUMN_TYPE_REFS)) - return sp_rcontext::create(thd, m_pcont, ret_value, *defs); + return sp_rcontext::create(thd, this, m_pcont, ret_value, *defs); sp_rcontext *res= NULL; #ifndef NO_EMBEDDED_ACCESS_CHECKS Security_context *save_security_ctx; @@ -1453,7 +1453,7 @@ sp_rcontext *sp_head::rcontext_create(THD *thd, Field *ret_value, return NULL; #endif if (!defs->resolve_type_refs(thd)) - res= sp_rcontext::create(thd, m_pcont, ret_value, *defs); + res= sp_rcontext::create(thd, this, m_pcont, ret_value, *defs); #ifndef NO_EMBEDDED_ACCESS_CHECKS if (switch_security_ctx) m_security_ctx.restore_security_context(thd, save_security_ctx); @@ -1590,10 +1590,6 @@ sp_head::execute_trigger(THD *thd, goto err_with_cleanup; } -#ifndef DBUG_OFF - nctx->sp= this; -#endif - thd->spcont= nctx; err_status= execute(thd, FALSE); @@ -1714,10 +1710,6 @@ sp_head::execute_function(THD *thd, Item **argp, uint argcount, */ thd->restore_active_arena(&call_arena, &backup_arena); -#ifndef DBUG_OFF - nctx->sp= this; -#endif - /* Pass arguments. */ for (arg_no= 0; arg_no < argcount; arg_no++) { @@ -1920,9 +1912,6 @@ sp_head::execute_procedure(THD *thd, List<Item> *args) DBUG_RETURN(TRUE); } -#ifndef DBUG_OFF - octx->sp= 0; -#endif thd->spcont= octx; /* set callers_arena to thd, for upper-level function to work */ @@ -1935,9 +1924,6 @@ sp_head::execute_procedure(THD *thd, List<Item> *args) thd->spcont= save_spcont; DBUG_RETURN(TRUE); } -#ifndef DBUG_OFF - nctx->sp= this; -#endif if (params > 0) { diff --git a/sql/sp_rcontext.cc b/sql/sp_rcontext.cc index 8290a927a77..96913f8619f 100644 --- a/sql/sp_rcontext.cc +++ b/sql/sp_rcontext.cc @@ -35,10 +35,14 @@ /////////////////////////////////////////////////////////////////////////// -sp_rcontext::sp_rcontext(const sp_pcontext *root_parsing_ctx, +sp_rcontext::sp_rcontext(const sp_head *owner, + const sp_pcontext *root_parsing_ctx, Field *return_value_fld, bool in_sub_stmt) :end_partial_result_set(false), +#ifndef DBUG_OFF + m_sp(owner), +#endif m_root_parsing_ctx(root_parsing_ctx), m_var_table(NULL), m_return_value_fld(return_value_fld), @@ -59,11 +63,13 @@ sp_rcontext::~sp_rcontext() sp_rcontext *sp_rcontext::create(THD *thd, + const sp_head *owner, const sp_pcontext *root_parsing_ctx, Field *return_value_fld, Row_definition_list &field_def_lst) { - sp_rcontext *ctx= new (thd->mem_root) sp_rcontext(root_parsing_ctx, + sp_rcontext *ctx= new (thd->mem_root) sp_rcontext(owner, + root_parsing_ctx, return_value_fld, thd->in_sub_stmt); if (!ctx) diff --git a/sql/sp_rcontext.h b/sql/sp_rcontext.h index 9a4a8e27032..5e5bca62982 100644 --- a/sql/sp_rcontext.h +++ b/sql/sp_rcontext.h @@ -70,6 +70,7 @@ public: /// /// @return valid sp_rcontext object or NULL in case of OOM-error. static sp_rcontext *create(THD *thd, + const sp_head *owner, const sp_pcontext *root_parsing_ctx, Field *return_value_fld, Row_definition_list &defs); @@ -77,7 +78,8 @@ public: ~sp_rcontext(); private: - sp_rcontext(const sp_pcontext *root_parsing_ctx, + sp_rcontext(const sp_head *owner, + const sp_pcontext *root_parsing_ctx, Field *return_value_fld, bool in_sub_stmt); @@ -180,7 +182,7 @@ public: #ifndef DBUG_OFF /// The stored program for which this runtime context is created. Used for /// checking if correct runtime context is used for variable handling. - sp_head *sp; + const sp_head *m_sp; #endif ///////////////////////////////////////////////////////////////////////// |