summaryrefslogtreecommitdiff
path: root/mysql-test/r/alter_table.result
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
commitcfd1e67ae404887496682c74abb24a1adedab4e9 (patch)
tree405488e4121249e547e773c0c60fc6bb67cf41be /mysql-test/r/alter_table.result
parent77ea801dec71bcc7dcf188ff24ae15a488c6b015 (diff)
downloadmariadb-git-cfd1e67ae404887496682c74abb24a1adedab4e9.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 'mysql-test/r/alter_table.result')
-rw-r--r--mysql-test/r/alter_table.result14
1 files changed, 14 insertions, 0 deletions
diff --git a/mysql-test/r/alter_table.result b/mysql-test/r/alter_table.result
index 3fa12f2997a..c9e3655660b 100644
--- a/mysql-test/r/alter_table.result
+++ b/mysql-test/r/alter_table.result
@@ -1103,3 +1103,17 @@ Field Type Null Key Default Extra
unsigned_int_field bigint(20) unsigned NO MUL
char_field char(10) YES NULL
DROP TABLE t2;
+CREATE TABLE t1 (f1 INT, f2 INT, f3 INT);
+INSERT INTO t1 VALUES (1, 2, NULL);
+SELECT * FROM t1;
+f1 f2 f3
+1 2 NULL
+ALTER TABLE t1 MODIFY COLUMN f3 INT AFTER f1;
+SELECT * FROM t1;
+f1 f3 f2
+1 NULL 2
+ALTER TABLE t1 MODIFY COLUMN f3 INT AFTER f2;
+SELECT * FROM t1;
+f1 f2 f3
+1 2 NULL
+DROP TABLE t1;