Commit 9248b580 authored by unknown's avatar unknown

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:
  Update test result
mysql-test/t/alter_table.test:
  Add test case as described in bug report
sql/sql_table.cc:
  Try to copy the autoincrement value when altering the table
parent b3d96f79
......@@ -826,3 +826,27 @@ create table t1 (t varchar(255) default null, key t (t(80)))
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;
set autocommit=1;
reset master;
create table bug16206 (a int);
insert into bug16206 values(1);
start transaction;
insert into bug16206 values(2);
commit;
show binlog events;
Log_name Pos Event_type Server_id End_log_pos Info
f n Format_desc 1 n Server ver: VERSION, Binlog ver: 4
f n Query 1 n use `test`; create table bug16206 (a int)
f n Query 1 n use `test`; insert into bug16206 values(1)
f n Query 1 n use `test`; insert into bug16206 values(2)
drop table bug16206;
reset master;
create table bug16206 (a int) engine= bdb;
insert into bug16206 values(0);
insert into bug16206 values(1);
start transaction;
insert into bug16206 values(2);
commit;
insert into bug16206 values(3);
show binlog events;
Log_name Pos Event_type Server_id End_log_pos Info
f n Format_desc 1 n Server ver: VERSION, Binlog ver: 4
f n Query 1 n use `test`; create table bug16206 (a int) engine= bdb
f n Query 1 n use `test`; insert into bug16206 values(0)
f n Query 1 n use `test`; insert into bug16206 values(1)
f n Query 1 n use `test`; BEGIN
f n Query 1 n use `test`; insert into bug16206 values(2)
f n Query 1 n use `test`; COMMIT
f n Query 1 n use `test`; insert into bug16206 values(3)
drop table bug16206;
set autocommit=0;
End of 5.0 tests
......@@ -613,3 +613,31 @@ create table t1 (t varchar(255) default null, key t (t(80)))
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;
-- source include/not_embedded.inc
-- source include/have_bdb.inc
#
# Bug #16206: Superfluous COMMIT event in binlog when updating BDB in autocommit mode
#
set autocommit=1;
let $VERSION=`select version()`;
reset master;
create table bug16206 (a int);
insert into bug16206 values(1);
start transaction;
insert into bug16206 values(2);
commit;
--replace_result $VERSION VERSION
--replace_column 1 f 2 n 5 n
show binlog events;
drop table bug16206;
reset master;
create table bug16206 (a int) engine= bdb;
insert into bug16206 values(0);
insert into bug16206 values(1);
start transaction;
insert into bug16206 values(2);
commit;
insert into bug16206 values(3);
--replace_result $VERSION VERSION
--replace_column 1 f 2 n 5 n
show binlog events;
drop table bug16206;
set autocommit=0;
--echo End of 5.0 tests
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment