• Jon Olav Hauglid's avatar
    Bug #57659 Segfault in Query_cache::invalidate_data for TRUNCATE TABLE · e16d4c49
    Jon Olav Hauglid authored
    This crash could happen if TRUNCATE TABLE indirectly failed to open a
    merge table due to failures to open underlying tables. Even if opening
    failed, the TRUNCATE TABLE code would try to invalidate the table in
    the query cache. Since this table had been closed and memory released,
    this could lead to a crash.
    
    This bug was introduced by a combination of the changes introduced by
    the patch for Bug#52044, where failing to open a table will cause opened
    tables to be closed. And the changes in patch for Bug#49938, where
    TRUNCATE TABLE uses the standard open tables function.
    
    This patch fixes the problem by setting the TABLE pointer to NULL before 
    invalidating the query cache.
    
    Test case added to truncate_coverage.test.
    e16d4c49
sql_truncate.cc 15.9 KB