summaryrefslogtreecommitdiff
path: root/mysql-test/t/alter_table_online.test
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test/t/alter_table_online.test')
-rw-r--r--mysql-test/t/alter_table_online.test79
1 files changed, 47 insertions, 32 deletions
diff --git a/mysql-test/t/alter_table_online.test b/mysql-test/t/alter_table_online.test
index 19096efe0fa..d9c2a2c4d4f 100644
--- a/mysql-test/t/alter_table_online.test
+++ b/mysql-test/t/alter_table_online.test
@@ -1,11 +1,9 @@
#
-# Test of alter online table
+# Test of ALTER ONLINE TABLE syntax
#
--source include/have_innodb.inc
---disable_warnings
-drop table if exists t1,t2,t3;
---enable_warnings
+--source include/have_partition.inc
#
# Test of things that can be done online
#
@@ -17,30 +15,29 @@ alter online table t1 modify b int default 5;
alter online table t1 change b new_name int;
alter online table t1 modify e enum('a','b','c');
alter online table t1 comment "new comment";
-alter online table t1 rename to t2;
-alter online table t2 rename to t1;
+
+# No OPs
+
+alter online table t1 algorithm=INPLACE, lock=NONE;
+alter online table t1;
+alter table t1 algorithm=INPLACE;
+alter table t1 lock=NONE;
drop table t1;
#
-# temporary tables always require a copy
+# everything with temporary tables is "online", i.e. without locks
#
-
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);
---error ER_CANT_DO_ONLINE
alter online table t1 modify b int default 5;
---error ER_CANT_DO_ONLINE
alter online table t1 change b new_name int;
---error ER_CANT_DO_ONLINE
alter online table t1 modify e enum('a','b','c');
---error ER_CANT_DO_ONLINE
alter online table t1 comment "new comment";
---error ER_CANT_DO_ONLINE
alter online table t1 rename to t2;
-drop table t1;
+drop table t2;
#
# Test of things that is not possible to do online
@@ -49,52 +46,47 @@ drop table t1;
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_CANT_DO_ONLINE
+--error ER_ALTER_OPERATION_NOT_SUPPORTED
alter online table t1 drop column b, add b int;
---error ER_CANT_DO_ONLINE
+--error ER_ALTER_OPERATION_NOT_SUPPORTED
alter online table t1 modify b bigint;
---error ER_CANT_DO_ONLINE
+--error ER_ALTER_OPERATION_NOT_SUPPORTED
alter online table t1 modify e enum('c','a','b');
---error ER_CANT_DO_ONLINE
+--error ER_ALTER_OPERATION_NOT_SUPPORTED
alter online table t1 modify c varchar(50);
---error ER_CANT_DO_ONLINE
+--error ER_ALTER_OPERATION_NOT_SUPPORTED
alter online table t1 modify c varchar(100);
---error ER_CANT_DO_ONLINE
+--error ER_ALTER_OPERATION_NOT_SUPPORTED
alter online table t1 add f int;
---error ER_CANT_DO_ONLINE
+--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);
---error ER_CANT_DO_ONLINE
alter online table t1 add index c (c);
---error ER_CANT_DO_ONLINE
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);
---error ER_CANT_DO_ONLINE
+#
+# everything with temporary tables is "online", i.e. without locks
+#
alter online table t1 drop column b, add b int;
---error ER_CANT_DO_ONLINE
alter online table t1 modify b bigint;
---error ER_CANT_DO_ONLINE
alter online table t1 modify e enum('c','a','b');
---error ER_CANT_DO_ONLINE
alter online table t1 modify c varchar(50);
---error ER_CANT_DO_ONLINE
alter online table t1 modify c varchar(100);
---error ER_CANT_DO_ONLINE
alter online table t1 add f int;
---error ER_CANT_DO_ONLINE
alter online table t1 engine=memory;
alter table t1 engine=innodb;
alter table t1 add index (b);
---error ER_CANT_DO_ONLINE
alter online table t1 add index c (c);
---error ER_CANT_DO_ONLINE
alter online table t1 drop index b;
drop table t1;
@@ -104,5 +96,28 @@ drop table t1;
create table t1 (a int not null primary key, b int, c varchar(80));
create table t2 (a int not null primary key, b int, c varchar(80));
create table t3 (a int not null primary key, b int, c varchar(80)) engine=merge UNION=(t1);
+--error ER_ALTER_OPERATION_NOT_SUPPORTED
alter online table t3 union=(t1,t2);
drop table t1,t2,t3;
+
+#
+# MDEV-9868 Altering a partitioned table comment does a full copy
+#
+create table t1 (i int) partition by hash(i) partitions 2;
+alter online table t1 comment 'test';
+drop table t1;
+
+#
+# MDEV-9168 altering a column comment does a full copy
+#
+create table t1 (a int);
+alter online table t1 modify a int comment 'test';
+drop table t1;
+
+create table t1 (a int) engine=innodb;
+alter online table t1 modify a int comment 'test';
+drop table t1;
+
+create table t1 (a int) partition by hash(a) partitions 2;
+alter online table t1 modify a int comment 'test';
+drop table t1;