-
unknown authored
To avoid unnecessary work the mysql_alter_table function takes the list of table fields and applies all changes to it (drops/moves/renames/etc). Then this function compares the new list and the old one. If the changes require only .frm to be modified then the actual data isn't copied. To detect changes all columns attributes but names are compared. When a column has been moved and has replaced another column with the same attributes except name the mysql_alter_table function wrongly decides that two fields has been just renamed. As a result the data from the moved column and from all columns after it is not copied. Now the mysql_alter_table function forces table data copying by setting the need_copy_table flag when it finds a moved column. The flag is set at the stage when the modified fields are created. sql/sql_table.cc: Bug#28427: Columns were renamed instead of moving by ALTER TABLE. Now the mysql_alter_table function forces table data copying by setting the need_copy_table flag when it finds a moved column. The flag is set at the stage when the modified fields are created. mysql-test/r/alter_table.result: Added a test case for the bug#28427: Columns were renamed instead of moving by ALTER TABLE. mysql-test/t/alter_table.test: Added a test case for the bug#28427: Columns were renamed instead of moving by ALTER TABLE.
b1676515