List:Commits« Previous MessageNext Message »
From:eugene Date:June 1 2007 7:56pm
Subject:bk commit into 5.1 tree (evgen:1.2518) BUG#28427
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of evgen. When evgen does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2007-06-01 23:56:45+04:00, evgen@stripped +3 -0
  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 changes requres only .frm to be modified then the actual data isn't copied.
  To detects changed types, null/not null and other columns attributes but
  names are compared. If a column was moved and has replaced another column
  with all the same attributes except name then the mysql_alter_table() function
  would wrongly decide that two fields were renamed instead of one column moved.
  This leads to avoiding of columns data copying and thus returning wrong data
  for the moved column and all columns after it.
  
  Now the mysql_alter_table() function forces table data copying by setting
  the need_copy_table flag when it finds a moved column at the stage of the
  modified fields list creation.  

  mysql-test/r/alter_table.result@stripped, 2007-06-01 23:54:02+04:00, evgen@stripped +14 -0
    Added a test case for the bug#28427: Columns were renamed instead of moving by ALTER TABLE.

  mysql-test/t/alter_table.test@stripped, 2007-06-01 23:53:36+04:00, evgen@stripped +12 -0
    Added a test case for the bug#28427: Columns were renamed instead of moving by ALTER TABLE.

  sql/sql_table.cc@stripped, 2007-06-01 23:54:07+04:00, evgen@stripped +4 -1
    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 at the stage of the
    modified fields list creation.  

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	evgen
# Host:	moonbone.local
# Root:	/mnt/gentoo64/work/28427-bug-5.1-opt-mysql

--- 1.419/sql/sql_table.cc	2007-06-01 08:20:08 +04:00
+++ 1.420/sql/sql_table.cc	2007-06-01 23:54:07 +04:00
@@ -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;
   }
 
   /*

--- 1.82/mysql-test/r/alter_table.result	2007-05-23 13:46:08 +04:00
+++ 1.83/mysql-test/r/alter_table.result	2007-06-01 23:54:02 +04:00
@@ -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;

--- 1.65/mysql-test/t/alter_table.test	2007-05-23 13:46:08 +04:00
+++ 1.66/mysql-test/t/alter_table.test	2007-06-01 23:53:36 +04:00
@@ -839,3 +839,15 @@ ALTER TABLE t2 MODIFY unsigned_int_field
 DESCRIBE t2;
 
 DROP TABLE t2;
+
+#
+# Bug#28427: Columns were renamed instead of moving by ALTER TABLE.
+#
+CREATE TABLE t1 (f1 INT, f2 INT, f3 INT);
+INSERT INTO t1 VALUES (1, 2, NULL);
+SELECT * FROM t1;
+ALTER TABLE t1 MODIFY COLUMN f3 INT AFTER f1;
+SELECT * FROM t1;
+ALTER TABLE t1 MODIFY COLUMN f3 INT AFTER f2;
+SELECT * FROM t1;
+DROP TABLE t1;
Thread
bk commit into 5.1 tree (evgen:1.2518) BUG#28427eugene1 Jun