• Satya B's avatar
    BUG#40827 - Killing insert-select to MyISAM can cause table corruption · 24146bb2
    Satya B authored
                      
    Killing insert-select statement on MyISAM corrupts the table.
                      
    Killing the insert-select statement corrupts the MyISAM table only
    when the destination table is empty and when it has indexes. When 
    we bulk insert huge data and if the destination table is empty we 
    disable the indexes for fast inserts, data is then inserted and 
    indexes are re-enabled after bulk_insert operation
                      
    Killing the query, aborts the repair table operation during enable
    indexes phase leading to table corruption.
                    
    We now truncate the table when we detect that enable indexes is
    killed for bulk insert query.As we have an empty table before the 
    operation, we can fix by truncating the table.
    
    mysql-test/r/myisam.result:
      Result file for BUG#40827
    mysql-test/t/myisam.test:
      Testcase for BUG#40827
    storage/myisam/ha_myisam.cc:
      Fixed end_bulk_insert() method to truncate the table when we detect enable 
      index operation is killed.
    24146bb2
ha_myisam.cc 67.9 KB