sp_rcontext::sp cleanup
- Renaming sp_rcontext::sp to sp_rcontext:m_sp for consistency with other sp_rcontext_members, and for consistency with the same purpose member Item_sp_variable::m_sp. - Passing a "const sp_head*" pointer to sp_rcontext::sp_rcontext() and to sp_rcontext::create(). Initializing sp_rcontext::m_sp right in the constructor instead of having a separate initialization after "new sp_rcontext" or sp_rcontext::create(). - Adding the "const" qualifier to sp_rcontext::m_sp and Item_sp_variable::m_sp
This commit is contained in:
parent
f5e09b5f8f
commit
e156db85a7
18
sql/item.cc
18
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);
|
||||
}
|
||||
|
@ -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:
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
Loading…
x
Reference in New Issue
Block a user