• Karthik Kamath's avatar
    BUG#21142859: FUNCTION UPDATING A VIEW FAILS TO FIND TABLE · 90b9c957
    Karthik Kamath authored
                  THAT ACTUALLY EXISTS
    
    ANALYSIS:
    =========
    Stored functions updating a view where the view table has a
    trigger defined that updates another table, fails reporting
    an error that the table doesn't exist.
    
    If there is a trigger defined on a table, a variable
    'trg_event_map' will be set to a non-zero value after the
    parsed tree creation. This indicates what triggers we need to
    pre-load for the TABLE_LIST when opening an associated table.
    
    During the prelocking phase, the variable 'trg_event_map'
    will not be set for the view table. This value will be set
    after the processing of triggers defined on the table. During
    the processing of sub-statements, 'locked_tables_mode' will be
    set to 'LTM_PRELOCKED' which denotes that further locking
    of tables/functions cannot be done. This results in the other
    table not being locked and thus further processing results in
    an error getting reported.
    
    FIX:
    ====
    During the prelocking of view, the value of 'trg_event_map'
    of the view is copied to 'trg_event_map' of the next table
    in the TABLE_LIST. This results in the locking of tables
    associated with the trigger as well.
    90b9c957
sp-prelocking.test 8.04 KB