• Davi Arnaut's avatar
    Backport of Bug#36649 to mysql-next-mr · 20189faa
    Davi Arnaut authored
    ------------------------------------------------------------
    revno: 2630.39.3
    revision-id: davi.arnaut@sun.com-20081210215359-i876m4zgc2d6rzs3
    parent: kostja@sun.com-20081208222938-9es7wl61moli71ht
    committer: Davi Arnaut <Davi.Arnaut@Sun.COM>
    branch nick: 36649-6.0
    timestamp: Wed 2008-12-10 19:53:59 -0200
    message:
      Bug#36649: Condition area is not properly cleaned up after stored routine invocation
    
      The problem is that the diagnostics area of a trigger is not
      isolated from the area of the statement that caused the trigger
      invocation. In MySQL terms, it means that warnings generated
      during the execution of the trigger are not removed from the
      "warning area" at the end of the execution.
    
      Before this fix, the rules for MySQL message list life cycle (see
      manual entry for SHOW WARNINGS) did not apply to statements
      inside stored programs:
    
        - The manual says that the list of messages is cleared by a
          statement that uses a table (any table). However, such
          statement, if run inside a stored program did not clear the
          message list.
        - The manual says that the list is cleared by a statement that
          generates a new error or a warning, but this was not the case
          with stored program statements either and is changed to be the
          case as well.
    
      In other words, after this fix, a statement has the same effect
      on the message list regardless of whether it's executed inside a
      stored program/sub-statement or not.
    
      This introduces an incompatible change:
    
        - before this fix, a, e.g. statement inside a trigger could
          never clear the global warning list
        - after this fix, a trigger that generates a warning or uses a
          table, clears the global warning list
        - however, when we leave a trigger or a function, the caller's
          warning information is restored (see more on this below).
    
      This change is not backward compatible as it is intended to make
      MySQL behavior similar to the SQL standard behavior:
    
      A stored function or trigger will get its own "warning area" (or,
      in standard terminology, diagnostics area).  At the beginning of
      the stored function or trigger, all messages from the caller area
      will be copied to the area of the trigger.  During execution, the
      message list will be cleared according to the MySQL rules
      described on the manual (SHOW WARNINGS entry).  At the end of the
      function/trigger, the "warning area" will be destroyed along with
      all warnings it contains, except that if the last statement of
      the function/trigger generated messages, these are copied into
      the "warning area" of the caller.
    
      Consequently, statements that use a table or generate a warning
      *will* clear warnings inside the trigger, but that will have no
      effect to the warning list of the calling (outer) statement.
    20189faa
sp_head.cc 105 KB