Below is the list of changes that have just been committed into a local
5.0 repository of msvensson. When msvensson 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-03-01 13:43:04+01:00, msvensson@stripped +3 -0
Bug#25262 Auto Increment lost when changing Engine type
- Try to copy the autoincrement value when altering the table
mysql-test/r/alter_table.result@stripped, 2007-03-01 13:42:39+01:00,
msvensson@stripped +24 -0
Update test result
mysql-test/t/alter_table.test@stripped, 2007-03-01 13:43:03+01:00, msvensson@stripped
+28 -0
Add test case as described in bug report
sql/sql_table.cc@stripped, 2007-03-01 13:43:03+01:00, msvensson@stripped +6 -0
Try to copy the autoincrement value when altering the table
# 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: msvensson
# Host: pilot.blaudden
# Root: /home/msvensson/mysql/bug25262/my50-bug25262
--- 1.333/sql/sql_table.cc 2007-01-26 13:36:47 +01:00
+++ 1.334/sql/sql_table.cc 2007-03-01 13:43:03 +01:00
@@ -3274,6 +3274,12 @@ view_err:
create_info->avg_row_length= table->s->avg_row_length;
if (!(used_fields & HA_CREATE_USED_DEFAULT_CHARSET))
create_info->default_table_charset= table->s->table_charset;
+ if (!(used_fields & HA_CREATE_USED_AUTO) &&
table->found_next_number_field)
+ {
+ /* Table has an autoincrement, copy value to new table */
+ table->file->info(HA_STATUS_AUTO);
+ create_info->auto_increment_value= table->file->auto_increment_value;
+ }
restore_record(table, s->default_values); // Empty record for DEFAULT
List_iterator<Alter_drop> drop_it(alter_info->drop_list);
--- 1.62/mysql-test/r/alter_table.result 2007-01-19 02:37:49 +01:00
+++ 1.63/mysql-test/r/alter_table.result 2007-03-01 13:42:39 +01:00
@@ -826,3 +826,27 @@ create table t1 (t varchar(255) default
engine=myisam default charset=latin1;
alter table t1 change t t text;
drop table t1;
+create table t1(id int(8) primary key auto_increment) engine=heap;
+insert into t1 values (null);
+insert into t1 values (null);
+select * from t1;
+id
+1
+2
+alter table t1 auto_increment = 50;
+alter table t1 engine = myisam;
+insert into t1 values (null);
+select * from t1;
+id
+1
+2
+50
+alter table t1 engine = heap;
+insert into t1 values (null);
+select * from t1;
+id
+1
+2
+50
+51
+drop table t1;
--- 1.49/mysql-test/t/alter_table.test 2007-01-19 02:37:49 +01:00
+++ 1.50/mysql-test/t/alter_table.test 2007-03-01 13:43:03 +01:00
@@ -613,3 +613,31 @@ create table t1 (t varchar(255) default
engine=myisam default charset=latin1;
alter table t1 change t t text;
drop table t1;
+
+#
+# Bug#25262 Auto Increment lost when changing Engine type
+#
+
+create table t1(id int(8) primary key auto_increment) engine=heap;
+
+insert into t1 values (null);
+insert into t1 values (null);
+
+select * from t1;
+
+# Set auto increment to 50
+alter table t1 auto_increment = 50;
+
+# Alter to myisam
+alter table t1 engine = myisam;
+
+# This insert should get id 50
+insert into t1 values (null);
+select * from t1;
+
+# Alter to heap again
+alter table t1 engine = heap;
+insert into t1 values (null);
+select * from t1;
+
+drop table t1;
| Thread |
|---|
| • bk commit into 5.0 tree (msvensson:1.2407) BUG#25262 | msvensson | 1 Mar |