summaryrefslogtreecommitdiff
path: root/sql/sql_table.cc
diff options
context:
space:
mode:
authorunknown <evgen@moonbone.local>2007-06-02 01:21:18 +0400
committerunknown <evgen@moonbone.local>2007-06-02 01:21:18 +0400
commitb16765156ab1d92950463f0009c53283cd8aa0cc (patch)
tree405488e4121249e547e773c0c60fc6bb67cf41be /sql/sql_table.cc
parentdc7c5c46005ce006725001ca8e1ca8a88f5abd9a (diff)
downloadmariadb-git-b16765156ab1d92950463f0009c53283cd8aa0cc.tar.gz
Bug#28427: Columns were renamed instead of moving by ALTER TABLE.
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.
Diffstat (limited to 'sql/sql_table.cc')
-rw-r--r--sql/sql_table.cc5
1 files changed, 4 insertions, 1 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 11d7d15c685..a77ed172478 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -5932,6 +5932,7 @@ view_err:
goto err;
}
find_it.after(def); // Put element after this
+ need_copy_table= ALTER_TABLE_DATA_CHANGED;
}
}
if (alter_info->alter_list.elements)
@@ -6170,12 +6171,14 @@ view_err:
(uint*) thd->alloc(sizeof(uint) * prepared_key_list.elements)))
goto err;
/* Check how much the tables differ. */
- need_copy_table= compare_tables(table, &prepared_create_list,
+ bool res= compare_tables(table, &prepared_create_list,
key_info_buffer, key_count,
create_info, alter_info, order_num,
index_drop_buffer, &index_drop_count,
index_add_buffer, &index_add_count,
varchar);
+ if (!need_copy_table)
+ need_copy_table= res;
}
/*