Skip to content

Commit

Permalink
MDEV-9103 Altering table comment does a full copy
Browse files Browse the repository at this point in the history
following InnoDB's logic, altering a comment or a default
field's value needs "NO_LOCK", not EXCLUSIVE
  • Loading branch information
vuvova committed Feb 15, 2016
1 parent 3c6b771 commit 38b89a6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
9 changes: 3 additions & 6 deletions mysql-test/r/alter_table_online.result
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,9 @@ drop table if exists t1,t2,t3;
create table t1 (a int not null primary key, b int, c varchar(80), e enum('a','b'));
insert into t1 (a) values (1),(2),(3);
alter online table t1 modify b int default 5;
ERROR 0A000: LOCK=NONE/SHARED is not supported for this operation. Try LOCK=EXCLUSIVE.
alter online table t1 change b new_name int;
ERROR 0A000: LOCK=NONE/SHARED is not supported for this operation. Try LOCK=EXCLUSIVE.
alter online table t1 modify e enum('a','b','c');
ERROR 0A000: LOCK=NONE/SHARED is not supported for this operation. Try LOCK=EXCLUSIVE.
alter online table t1 comment "new comment";
ERROR 0A000: LOCK=NONE/SHARED is not supported for this operation. Try LOCK=EXCLUSIVE.
alter online table t1 rename to t2;
ERROR 0A000: LOCK=NONE/SHARED is not supported for this operation. Try LOCK=EXCLUSIVE.
alter online table t1 algorithm=INPLACE, lock=NONE;
alter online table t1;
alter table t1 algorithm=INPLACE;
Expand Down Expand Up @@ -40,10 +34,13 @@ alter online table t1 add f int;
ERROR 0A000: LOCK=NONE is not supported for this operation. Try LOCK=SHARED.
alter online table t1 engine=memory;
ERROR 0A000: LOCK=NONE is not supported. Reason: COPY algorithm requires a lock. Try LOCK=SHARED.
alter online table t1 rename to t2;
ERROR 0A000: LOCK=NONE/SHARED is not supported for this operation. Try LOCK=EXCLUSIVE.
alter table t1 engine=innodb;
alter table t1 add index (b);
alter online table t1 add index c (c);
alter online table t1 drop index b;
alter online table t1 comment "new comment";
drop table t1;
create temporary table t1 (a int not null primary key, b int, c varchar(80), e enum('a','b'));
insert into t1 (a) values (1),(2),(3);
Expand Down
11 changes: 4 additions & 7 deletions mysql-test/t/alter_table_online.test
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,16 @@
drop table if exists t1,t2,t3;
--enable_warnings
#
# Test of things that can not be done online
# Test of things that can be done online
#

create table t1 (a int not null primary key, b int, c varchar(80), e enum('a','b'));
insert into t1 (a) values (1),(2),(3);

--error ER_ALTER_OPERATION_NOT_SUPPORTED
alter online table t1 modify b int default 5;
--error ER_ALTER_OPERATION_NOT_SUPPORTED
alter online table t1 change b new_name int;
--error ER_ALTER_OPERATION_NOT_SUPPORTED
alter online table t1 modify e enum('a','b','c');
--error ER_ALTER_OPERATION_NOT_SUPPORTED
alter online table t1 comment "new comment";
--error ER_ALTER_OPERATION_NOT_SUPPORTED
alter online table t1 rename to t2;

# No OPs

Expand Down Expand Up @@ -68,11 +62,14 @@ alter online table t1 modify c varchar(100);
alter online table t1 add f int;
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
alter online table t1 engine=memory;
--error ER_ALTER_OPERATION_NOT_SUPPORTED
alter online table t1 rename to t2;

alter table t1 engine=innodb;
alter table t1 add index (b);
alter online table t1 add index c (c);
alter online table t1 drop index b;
alter online table t1 comment "new comment";
drop table t1;

create temporary table t1 (a int not null primary key, b int, c varchar(80), e enum('a','b'));
Expand Down
2 changes: 1 addition & 1 deletion sql/handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4236,7 +4236,7 @@ handler::check_if_supported_inplace_alter(TABLE *altered_table,
IS_EQUAL_PACK_LENGTH : IS_EQUAL_YES;
if (table->file->check_if_incompatible_data(create_info, table_changes)
== COMPATIBLE_DATA_YES)
DBUG_RETURN(HA_ALTER_INPLACE_EXCLUSIVE_LOCK);
DBUG_RETURN(HA_ALTER_INPLACE_NO_LOCK);

DBUG_RETURN(HA_ALTER_INPLACE_NOT_SUPPORTED);
}
Expand Down

0 comments on commit 38b89a6

Please sign in to comment.