|
|
|
|
|
by evanelias
486 days ago
|
|
That's simply not accurate! If an ALTER TABLE results in an integrity violation in MySQL, that ALTER TABLE is rolled back. In modern MySQL, DDL is atomic and crash-safe on a per-statement basis. It's just not "transactional", in the sense that you can't combine multiple DDL statements (nor mix DDL and DML) into a single transaction. See https://dev.mysql.com/doc/refman/8.0/en/atomic-ddl.html for reference. Modern versions of MariaDB also have atomic DDL, although their underlying implementation is quite different. And even in older versions of MySQL and MariaDB, an ALTER TABLE which causes an integrity violation was still rolled back. Think about it: the only possible non-instantaneous integrity violations are when adding a new unique key, new foreign key, or new check constraint. Check constraints didn't exist in old versions of MySQL or MariaDB, so that just leaves unique keys and foreign keys. And there's no notion of a "partially populated" index or a "half applied" foreign key constraint in MySQL, so your assertion of the ALTER just "stopping" mid-stream without rollback is just plain wrong. |
|