diff options
author | Dmitry Shulga <dmitry.shulga@mariadb.com> | 2023-03-16 18:13:29 +0700 |
---|---|---|
committer | Dmitry Shulga <dmitry.shulga@mariadb.com> | 2023-03-16 18:40:40 +0700 |
commit | d522fed5a53b233dc0f3f69232002ebe39a7bdd7 (patch) | |
tree | 9647c143c029c8d9bf0254067cf2ac48f46ba095 | |
parent | 69023e93e7943d6e8d2face5486dc411fedde701 (diff) | |
download | mariadb-git-d522fed5a53b233dc0f3f69232002ebe39a7bdd7.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.cc | 9 | ||||
-rw-r--r-- | sql/sp_instr.cc | 6 | ||||
-rw-r--r-- | sql/sp_instr.h | 11 |
3 files changed, 14 insertions, 12 deletions
diff --git a/sql/sp_head.cc b/sql/sp_head.cc index cb4c5c6140c..6577433bcfd 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 44615a8d732..94926d6227f 100644 --- a/sql/sp_instr.cc +++ b/sql/sp_instr.cc @@ -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 diff --git a/sql/sp_instr.h b/sql/sp_instr.h index a92c9256e35..90f427d64ce 100644 --- a/sql/sp_instr.h +++ b/sql/sp_instr.h @@ -70,6 +70,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 */ @@ -173,7 +176,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; } @@ -528,7 +531,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 { @@ -587,7 +590,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 { @@ -1086,7 +1089,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 { |