Skip to content
Permalink
Browse files
MDEV-12836 Avoid table rebuild when removing of auto_increment settings
Field::is_equal(): treat old type and new one without AUTO_INCREMENT as equal

Closes #1208
  • Loading branch information
kevgs authored and vuvova committed Mar 20, 2019
1 parent 23a7693 commit 8dffaae
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
@@ -0,0 +1,21 @@
create table t(id int primary key, a int) engine=InnoDB;
insert into t (id, a) values (1, 1);
alter table t modify column id int auto_increment;
check table t;
Table Op Msg_type Msg_text
test.t check status OK
insert into t (a) values (2);
alter table t modify column id int, algorithm=instant;
check table t;
Table Op Msg_type Msg_text
test.t check status OK
insert into t (id, a) values (3, 3);
select * from t;
id a
1 1
2 2
3 3
check table t;
Table Op Msg_type Msg_text
test.t check status OK
drop table t;
@@ -0,0 +1,13 @@
--source include/have_innodb.inc

create table t(id int primary key, a int) engine=InnoDB;
insert into t (id, a) values (1, 1);
alter table t modify column id int auto_increment;
check table t;
insert into t (a) values (2);
alter table t modify column id int, algorithm=instant;
check table t;
insert into t (id, a) values (3, 3);
select * from t;
check table t;
drop table t;
@@ -3469,7 +3469,7 @@ uint Field_new_decimal::is_equal(Create_field *new_field)
return ((new_field->type_handler() == type_handler()) &&
((new_field->flags & UNSIGNED_FLAG) ==
(uint) (flags & UNSIGNED_FLAG)) &&
((new_field->flags & AUTO_INCREMENT_FLAG) ==
((new_field->flags & AUTO_INCREMENT_FLAG) <=
(uint) (flags & AUTO_INCREMENT_FLAG)) &&
(new_field->length == max_display_length()) &&
(new_field->decimals == dec));
@@ -9535,7 +9535,8 @@ bool Field_num::eq_def(const Field *field) const

uint Field_num::is_equal(Create_field *new_field)
{
if ((new_field->flags ^ flags) & (UNSIGNED_FLAG | AUTO_INCREMENT_FLAG))
if (((new_field->flags & UNSIGNED_FLAG) != (flags & UNSIGNED_FLAG)) ||
((new_field->flags & AUTO_INCREMENT_FLAG) > (flags & AUTO_INCREMENT_FLAG)))
return IS_EQUAL_NO;

const Type_handler *th= type_handler(), *new_th = new_field->type_handler();

0 comments on commit 8dffaae

Please sign in to comment.