summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Shulga <dmitry.shulga@mariadb.com>2022-12-20 15:11:50 +0700
committerDmitry Shulga <dmitry.shulga@mariadb.com>2022-12-20 15:11:50 +0700
commit55308ed593ff81a0c159ad76400f7ceb94ac1b4f (patch)
treeab084c92d254081f9968f13a1ce32f9468ae3892
parentbd42be6b2b95543f6e53edf5fda592651787e938 (diff)
downloadmariadb-git-55308ed593ff81a0c159ad76400f7ceb94ac1b4f.tar.gz
MDEV-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 its derived classes. 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.
-rw-r--r--sql/sp_head.cc9
-rw-r--r--sql/sp_instr.cc6
-rw-r--r--sql/sp_instr.h11
3 files changed, 14 insertions, 12 deletions
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index aec8983f76f..ffcedaea315 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -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);
diff --git a/sql/sp_instr.cc b/sql/sp_instr.cc
index d75cd11187a..c51c7f9d3db 100644
--- a/sql/sp_instr.cc
+++ b/sql/sp_instr.cc
@@ -817,7 +817,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
@@ -905,7 +905,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
@@ -1655,7 +1655,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
diff --git a/sql/sp_instr.h b/sql/sp_instr.h
index 8cf752b80f9..423d6f77153 100644
--- a/sql/sp_instr.h
+++ b/sql/sp_instr.h
@@ -58,6 +58,9 @@ public:
// "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 */
@@ -160,7 +163,7 @@ public:
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;
}
@@ -493,7 +496,7 @@ public:
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
{
@@ -548,7 +551,7 @@ public:
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
{
@@ -1022,7 +1025,7 @@ public:
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
{