summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <msvensson@pilot.blaudden>2007-04-25 12:08:39 +0200
committerunknown <msvensson@pilot.blaudden>2007-04-25 12:08:39 +0200
commit5bb54e514f74c72502d4acb4af323277fa3eb3d1 (patch)
treebf16821f4c9e415daa1d1cc4b59a6350baab50fe
parentf692f710b759cc697176405aedd39bf094240269 (diff)
parent9248b580b96ba9246169b80ea0ea53be5137f6b0 (diff)
downloadmariadb-git-5bb54e514f74c72502d4acb4af323277fa3eb3d1.tar.gz
Merge pilot.blaudden:/home/msvensson/mysql/bug25262/my50-bug25262
into pilot.blaudden:/home/msvensson/mysql/mysql-5.0-maint sql/sql_table.cc: Auto merged mysql-test/r/alter_table.result: Merge tests mysql-test/t/alter_table.test: Merge tests
-rw-r--r--mysql-test/r/alter_table.result24
-rw-r--r--mysql-test/t/alter_table.test26
-rw-r--r--sql/sql_table.cc6
3 files changed, 56 insertions, 0 deletions
diff --git a/mysql-test/r/alter_table.result b/mysql-test/r/alter_table.result
index 82c35ff963a..280cedb8b89 100644
--- a/mysql-test/r/alter_table.result
+++ b/mysql-test/r/alter_table.result
@@ -860,3 +860,27 @@ ALTER TABLE t1 ADD d INT;
ALTER TABLE t1 ADD KEY (d(20));
ERROR HY000: Incorrect sub part key; the used key part isn't a string, the used length is longer than the key part, or the storage engine doesn't support unique sub keys
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;
diff --git a/mysql-test/t/alter_table.test b/mysql-test/t/alter_table.test
index 307138added..83686f31e9e 100644
--- a/mysql-test/t/alter_table.test
+++ b/mysql-test/t/alter_table.test
@@ -636,3 +636,29 @@ ALTER TABLE t1 ADD d INT;
ALTER TABLE t1 ADD KEY (d(20));
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;
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 6f953349c03..f7478691293 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -3316,6 +3316,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);