Commit 40d730fb authored by Dmitry Shulga's avatar Dmitry Shulga

DEV-5816: Stored programs: validation of stored program statements

This is the prerequisite patch to change a signature of the virtual
method opt_move() in the base class sp_instr and classes derived from it.
The parameterized type of the instuctions list returned in the second
argument is changed from sp_instr to sp_instr_opt_meta since only
jump instructions are placed in this list on returning from
the method call.
parent 66d88176
......@@ -3146,7 +3146,7 @@ bool sp_head::replace_instr_to_nop(THD *thd, uint ip)
void sp_head::optimize()
{
List<sp_instr> bp;
List<sp_instr_opt_meta> bp;
sp_instr *i;
uint src, dst;
......@@ -3168,14 +3168,13 @@ void sp_head::optimize()
if (src != dst)
{
/* Move the instruction and update prev. jumps */
sp_instr *ibp;
List_iterator_fast<sp_instr> li(bp);
sp_instr_opt_meta *ibp;
List_iterator_fast<sp_instr_opt_meta> li(bp);
set_dynamic(&m_instr, (uchar*)&i, dst);
while ((ibp= li++))
{
sp_instr_opt_meta *im= static_cast<sp_instr_opt_meta *>(ibp);
im->set_destination(src, dst);
ibp->set_destination(src, dst);
}
}
i->opt_move(dst, &bp);
......
......@@ -815,7 +815,7 @@ sp_instr_jump::opt_shortcut_jump(sp_head *sp, sp_instr *start)
}
void
sp_instr_jump::opt_move(uint dst, List<sp_instr> *bp)
sp_instr_jump::opt_move(uint dst, List<sp_instr_opt_meta> *bp)
{
if (m_dest > m_ip)
bp->push_back(this); // Forward
......@@ -903,7 +903,7 @@ sp_instr_jump_if_not::opt_mark(sp_head *sp, List<sp_instr> *leads)
}
void
sp_instr_jump_if_not::opt_move(uint dst, List<sp_instr> *bp)
sp_instr_jump_if_not::opt_move(uint dst, List<sp_instr_opt_meta> *bp)
{
/*
cont. destinations may point backwards after shortcutting jumps
......@@ -1653,7 +1653,7 @@ sp_instr_set_case_expr::opt_mark(sp_head *sp, List<sp_instr> *leads)
}
void
sp_instr_set_case_expr::opt_move(uint dst, List<sp_instr> *bp)
sp_instr_set_case_expr::opt_move(uint dst, List<sp_instr_opt_meta> *bp)
{
if (m_cont_dest > m_ip)
bp->push_back(this); // Forward
......
......@@ -70,6 +70,9 @@ class sp_lex_cursor: public sp_lex_local, public Query_arena
// "Instructions"...
//
// Forward declaration for use in the method sp_instr::opt_move().
class sp_instr_opt_meta;
class sp_instr :public Query_arena, public Sql_alloc
{
sp_instr(const sp_instr &); /**< Prevent use of these */
......@@ -173,7 +176,7 @@ class sp_instr :public Query_arena, public Sql_alloc
must also take care of their destination pointers. Forward jumps get
pushed to the backpatch list 'ibp'.
*/
virtual void opt_move(uint dst, List<sp_instr> *ibp)
virtual void opt_move(uint dst, List<sp_instr_opt_meta> *ibp)
{
m_ip= dst;
}
......@@ -528,7 +531,7 @@ class sp_instr_jump : public sp_instr_opt_meta
uint opt_shortcut_jump(sp_head *sp, sp_instr *start) override;
void opt_move(uint dst, List<sp_instr> *ibp) override;
void opt_move(uint dst, List<sp_instr_opt_meta> *ibp) override;
void backpatch(uint dest, sp_pcontext *dst_ctx) override
{
......@@ -587,7 +590,7 @@ class sp_instr_jump_if_not : public sp_instr_jump
return m_ip;
}
void opt_move(uint dst, List<sp_instr> *ibp) override;
void opt_move(uint dst, List<sp_instr_opt_meta> *ibp) override;
void set_destination(uint old_dest, uint new_dest) override
{
......@@ -1086,7 +1089,7 @@ class sp_instr_set_case_expr : public sp_instr_opt_meta
uint opt_mark(sp_head *sp, List<sp_instr> *leads) override;
void opt_move(uint dst, List<sp_instr> *ibp) override;
void opt_move(uint dst, List<sp_instr_opt_meta> *ibp) override;
void set_destination(uint old_dest, uint new_dest) override
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment