• Marko Mäkelä's avatar
    Fix FOREIGN KEY error handling on DDL · ae73b7d8
    Marko Mäkelä authored
    dict_create_add_foreigns_to_dictionary(): Do not commit the transaction.
    We want simple rollback in case dict_load_foreigns() would fail.
    
    create_table_info_t::create_table(), row_create_index_for_mysql(),
    row_table_add_foreign_constraints(): Before invoking rollback, drop
    the table. Rollback would invoke trx_t::evict_table(), and after that
    dropping the table would be a no-op.
    
    ha_innobase::create(): Before rollback, drop the table. If the SQL
    layer invoked ha_innobase::delete_table() later, it would be a no-op
    because the rollback would have invoked trx_t::evict_table().
    
    FIXME: Introduce an undo log record so that the data file would be
    deleted on rollback. Also, avoid unnecessary access to the tablespace
    during DROP TABLE or the rollback of CREATE TABLE. If the file is going
    to be deleted anyway, we should not bother to mark the pages free.
    ae73b7d8
ha_innodb.cc 604 KB