summaryrefslogtreecommitdiff
path: root/sql/sp_head.h
diff options
context:
space:
mode:
authorunknown <pem@mysql.com>2006-01-25 15:11:49 +0100
committerunknown <pem@mysql.com>2006-01-25 15:11:49 +0100
commit7ee65fcf8560ab981c5afcd9a3e747577f22e8f0 (patch)
treed0809b2aee3fe4e188c050796ec4c74587189bd8 /sql/sp_head.h
parent8f395ebbfa87f21cb7acf655876790df99389499 (diff)
downloadmariadb-git-7ee65fcf8560ab981c5afcd9a3e747577f22e8f0.tar.gz
Fixed BUG#15737: Stored procedure optimizer bug with LEAVE
Second version. The problem was that the optimizer didn't work correctly with forwards jumps to "no-op" hpop and cpop instructions. Don't generate "no-op" instructions (hpop 0 and cpop 0), it isn't actually necessary. mysql-test/r/sp-code.result: Updated results for new test case (BUG#15737) mysql-test/t/sp-code.test: New test case (BUG#15737) sql/sp_head.cc: Removed backpatch methods from sp_instr_hpop/cpop, since they're not needed any more. Added more documentation to sp_head::optimize() sql/sp_head.h: Removed backpatch and opt_mark methods from sp_instr_hpop/cpop, since they're not needed any more. Added comments to optimizer methods in sp_instr. sql/sql_yacc.yy: Don't generate "no-op" hpop and cpop instructions for LEAVE, it's not necessary. Just generate them when needed.
Diffstat (limited to 'sql/sp_head.h')
-rw-r--r--sql/sp_head.h40
1 files changed, 22 insertions, 18 deletions
diff --git a/sql/sp_head.h b/sql/sp_head.h
index 858bf523a07..89e86badc09 100644
--- a/sql/sp_head.h
+++ b/sql/sp_head.h
@@ -461,17 +461,34 @@ public:
virtual void backpatch(uint dest, sp_pcontext *dst_ctx)
{}
+ /*
+ Mark this instruction as reachable during optimization and return the
+ index to the next instruction. Jump instruction will mark their
+ destination too recursively.
+ */
virtual uint opt_mark(sp_head *sp)
{
marked= 1;
return m_ip+1;
}
+ /*
+ Short-cut jumps to jumps during optimization. This is used by the
+ jump instructions' opt_mark() methods. 'start' is the starting point,
+ used to prevent the mark sweep from looping for ever. Return the
+ end destination.
+ */
virtual uint opt_shortcut_jump(sp_head *sp, sp_instr *start)
{
return m_ip;
}
+ /*
+ Inform the instruction that it has been moved during optimization.
+ Most instructions will simply update its index, but jump instructions
+ 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)
{
m_ip= dst;
@@ -696,6 +713,9 @@ public:
m_dest= dest;
}
+ /*
+ Update the destination; used by the optimizer.
+ */
virtual void set_destination(uint old_dest, uint new_dest)
{
if (m_dest == old_dest)
@@ -739,6 +759,7 @@ public:
virtual uint opt_mark(sp_head *sp);
+ /* Override sp_instr_jump's shortcut; we stop here */
virtual uint opt_shortcut_jump(sp_head *sp, sp_instr *start)
{
return m_ip;
@@ -822,6 +843,7 @@ public:
virtual uint opt_mark(sp_head *sp);
+ /* Override sp_instr_jump's shortcut; we stop here. */
virtual uint opt_shortcut_jump(sp_head *sp, sp_instr *start)
{
return m_ip;
@@ -859,15 +881,6 @@ public:
virtual void print(String *str);
- virtual void backpatch(uint dest, sp_pcontext *dst_ctx);
-
- virtual uint opt_mark(sp_head *sp)
- {
- if (m_count)
- marked= 1;
- return m_ip+1;
- }
-
private:
uint m_count;
@@ -953,15 +966,6 @@ public:
virtual void print(String *str);
- virtual void backpatch(uint dest, sp_pcontext *dst_ctx);
-
- virtual uint opt_mark(sp_head *sp)
- {
- if (m_count)
- marked= 1;
- return m_ip+1;
- }
-
private:
uint m_count;