The way how InnoDB writes undo log about CREATE TABLE and DROP TABLE introduces the limitation that only one table may be created or dropped within a transaction.
We should replace the current mechanism (around trx->table_id) and introduce new undo log records for the following:
- delete-if-exists a file on rollback (when rolling back CREATE TABLE)
- delete-if-exists a file on purge (after DROP TABLE has been committed)
Applying either operation must write MLOG_FILE_DELETE2 to the redo log before actually deleting any files.
To avoid name clashes between DROP TABLE and subsequent CREATE TABLE by the same name (before the old files were purged), we should probably rename the files to temporary names before dropping. Also the rename operation must be undo logged and redo logged. Furthermore, during normal operation we could delete the files for the dropped table. The deletion by the purge subsystem would only be a fall-back measure for crash recovery.