-
Dmitry Lenev authored
leave the table unusable". Failing ALTER statement on partitioned table could have left this table in an unusable state. This has happened in cases when ALTER was executed using "fast" algorithm, which doesn't involve copying of data between old and new versions of table, and the resulting new table was incompatible with partitioning function in some way. The problem stems from the fact that discrepancies between new table definition and partitioning function are discovered only when the table is opened. In case of "fast" algorithm this has happened too late during ALTER's execution, at the moment when all changes were already done and couldn't have been reverted. In the cases when "slow" algorithm, which copies data, is used such discrepancies are detected at the moment new table definition is opened implicitly when new version of table is created in storage engine. As result ALTER is aborted before any changes to table were done. This fix tries to address this issue by ensuring that "fast" algorithm behaves similarly to "slow" algorithm and checks compatibility between new definition and partitioning function by trying to open new definition after .FRM file for it has been created. Long term we probably should implement some way to check compatibility between partitioning function and new table definition which won't involve opening it, as this should allow much cleaner fix for this problem. mysql-test/r/partition_innodb.result: Added test for bug #57985 "ONLINE/FAST ALTER PARTITION can fail and leave the table unusable". mysql-test/t/partition_innodb.test: Added test for bug #57985 "ONLINE/FAST ALTER PARTITION can fail and leave the table unusable". sql/sql_table.cc: Ensure that in cases when .FRM for partitioned table is created without creating table in storage engine (e.g. during "fast" ALTER TABLE) we still open table definition. This allows to check that definition of created table/.FRM is compatible with its partitioning function.
602a2225