• Jon Olav Hauglid's avatar
    Bug #48315 Metadata lock is not taken for merged views that use · 813ad38e
    Jon Olav Hauglid authored
               an INFORMATION_SCHEMA table
    
    When a prepared statement using a merged view containing an information
    schema table was executed, a metadata lock of the view was not taken.
    This meant that it was possible for concurrent view DDL to execute,
    thereby breaking the binary log. For example, it was possible
    for DROP VIEW to appear in the binary log before a query using the view.
    This also happened when a statement in a stored routine was executed a
    second time.
    
    For such views, the information schema table is merged into the view
    during the prepare phase (or first execution of a statement in a routine).
    The problem was that we took a short cut and were not executing full-blown
    view opening during subsequent executions of the statement. As a result,
    a metadata lock on the view was not taken to protect the view definition.
    
    This patch resolves the problem by making sure a metadata lock is taken
    for views even after information schema tables are merged into them.
    
    Test cased added to view.test.
    813ad38e
sql_base.cc 286 KB