• unknown's avatar
    Bug #29929 LOCK TABLES does not pre-lock tables used in triggers of the locked tables · 07955aea
    unknown authored
    When a table was explicitly locked with LOCK TABLES no associated
    tables from any related trigger on the subject table were locked.
    As a result of this the user could experience unexpected locking
    behavior and statement failures similar to "failed: 1100: Table'xx'
    was not locked with LOCK TABLES".
    
    This patch fixes this problem by making sure triggers are
    pre-loaded on any statement if the subject table was explicitly
    locked with LOCK TABLES.
    
    
    mysql-test/r/sp-prelocking.result:
      Added test case
    mysql-test/t/sp-prelocking.test:
      Added test case
    sql/sql_lex.cc:
      - Moved some conditional logic out of the table iteration.
      - Added event map values for LOCK TABLE command.
    sql/table.cc:
      - Refactored set_trg_event_tpye into the two simpler functions set_trg_event_map
        and set_trg_event_map as methods for manipulating the table event map.
        The original function was only called from st_lex::set_trg_event_type_for_tables
        so it was possible to move the event map creation logic to this function as
        a loop optimization.
    sql/table.h:
      - Refactored set_trg_event_tpye into the two simpler functions set_trg_event_map
        and set_trg_event_map as methods for manipulating the table event map.
        The original function was only called from st_lex::set_trg_event_type_for_tables
        so it was possible to move the event map creation logic to this function as
        a loop optimization.
    07955aea
table.h 32.5 KB