• Kristofer Pettersson's avatar
    Bug#45781 infinite hang/crash in "opening tables" after handler tries to open merge · fae95a49
    Kristofer Pettersson authored
              table
    
    The MERGE table storage engine does not support the HA_CAN_SQL_HANDLE feature
    and any attempt to open the merge table will fail with ER_ILLEGAL_HA.
    
    After an error occurred the tables that was opened must be closed again
    or they will be left in an inconsistent state. However, the assumption
    made in the code for closing and register handler tables was that only
    one table will be opened, and this is not true for MERGE tables which
    will cause multiple tables to open.
    
    The next time a SELECT operation was issued on the merge table it
    caused the system to freeze.
    
    This patch fixes this issue by making sure that all tables which
    are opened also are closed in the event of an error.
    
    
    mysql-test/r/merge.result:
      Added test case for bug 45781
    mysql-test/t/merge.test:
      Added test case for bug 45781
    sql/sql_handler.cc:
      * mysql_ha_open() was never ment to open more than one table. If we encounter more tables, we should
        close all tables related to the current substatement and raise an exception.
    fae95a49
merge.result 52.5 KB