• Jon Olav Hauglid's avatar
    Backport from mysql-trunk of: · 6c1bbb50
    Jon Olav Hauglid authored
    ------------------------------------------------------------
    revno: 3258
    committer: Jon Olav Hauglid <jon.hauglid@oracle.com>
    branch nick: mysql-trunk-bug12663165
    timestamp: Thu 2011-07-14 10:05:12 +0200
    message:
      Bug#12663165 SP DEAD CODE REMOVAL DOESN'T UNDERSTAND CONTINUE HANDLERS
      
      When stored routines are loaded, a simple optimizer tries to locate
      and remove dead code. The problem was that this dead code removal
      did not work correctly with CONTINUE handlers.
      
      If a statement triggers a CONTINUE handler, the following statement
      will be executed after the handler statement has completed. This
      means that the following statement is not dead code even if the
      previous statement unconditionally alters control flow. This fact
      was lost on the dead code removal routine, which ended up with
      removing instructions that could have been executed. This could
      then lead to assertions, crashes and generally bad behavior when
      the stored routine was executed.
      
      This patch fixes the problem by marking as live code all stored
      routine instructions that are in the same scope as a CONTINUE handler.
      
      Test case added to sp.test.
    6c1bbb50
sp_head.h 33.1 KB