• Marko Mäkelä's avatar
    MDEV-15562: Simplify FOREIGN KEY error handling on DDL · f58a0b3a
    Marko Mäkelä authored
    The error handling for ALTER TABLE…ALGORITHM=COPY as well as
    CREATE TABLE used to commit the CREATE TABLE transaction and then
    issue DROP TABLE in a separate transaction. This is unnecessarily
    breaking atomicity during DDL operations. Let us revise it so
    that the DROP TABLE will be executed within the same transaction,
    which will finally be rolled back.
    
    FIXME: Introduce an undo log record so that the data file would be
    deleted on rollback and no DROP TABLE would be needed at all.
    
    FIXME: Avoid unnecessary access to per-table tablespace during DROP TABLE.
    If the .ibd file is going to be deleted anyway, we should not bother
    to mark the pages free.
    
    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().
    f58a0b3a
row0mysql.cc 133 KB