• Davi Arnaut's avatar
    Bug#37016: TRUNCATE TABLE removes some rows but not all · 8dbb9c88
    Davi Arnaut authored
    The special TRUNCATE TABLE (DDL) transaction wasn't being properly
    rolled back if a error occurred during row by row deletion. The
    error can be caused by a foreign key restriction imposed by InnoDB
    SE and would cause the server to erroneously issue a implicit
    commit.
    
    The solution is to rollback the transaction if a truncation via row
    by row deletion fails, otherwise commit. All effects of a TRUNCATE 
    ABLE operation are rolled back if a row by row deletion fails.
    
    mysql-test/include/commit.inc:
      Truncate always starts a transaction and commits at the end.
      The commit at the end increases the count by two, one is the
      storage engine commit and the other is the binary log.
    mysql-test/r/commit_1innodb.result:
      Update test case results.
    mysql-test/r/innodb_mysql.result:
      Update test case results.
    mysql-test/t/innodb_mysql.test:
      Add test case for Bug#37016
    sql/sql_delete.cc:
      Move truncation using row by row deletion to its own function.
      If row by row deletion fails, rollback the transaction.
      
      Remove the meddling with disabling and enabling of autocommit
      as TRUNCATE transaction is now explicitly ended (committed
      or rolled back).
    8dbb9c88
innodb_mysql.result 48.2 KB