2011-04-28 18:56:10 +02:00
|
|
|
#
|
2013-07-10 12:48:56 +02:00
|
|
|
# Test of ALTER ONLINE TABLE syntax
|
2011-04-28 18:56:10 +02:00
|
|
|
#
|
|
|
|
|
|
|
|
--source include/have_innodb.inc
|
|
|
|
--disable_warnings
|
|
|
|
drop table if exists t1,t2,t3;
|
|
|
|
--enable_warnings
|
|
|
|
#
|
2016-02-11 12:25:23 +01:00
|
|
|
# Test of things that can be done online
|
2011-04-28 18:56:10 +02:00
|
|
|
#
|
|
|
|
|
|
|
|
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;
|
|
|
|
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";
|
|
|
|
|
2015-03-11 21:08:31 +01:00
|
|
|
# No OPs
|
|
|
|
|
|
|
|
alter online table t1 algorithm=INPLACE, lock=NONE;
|
2015-05-03 11:31:04 +02:00
|
|
|
alter online table t1;
|
|
|
|
alter table t1 algorithm=INPLACE;
|
|
|
|
alter table t1 lock=NONE;
|
2015-03-11 21:08:31 +01:00
|
|
|
|
2011-04-28 18:56:10 +02:00
|
|
|
drop table t1;
|
|
|
|
|
|
|
|
#
|
2013-09-25 19:42:12 +02:00
|
|
|
# everything with temporary tables is "online", i.e. without locks
|
2011-04-28 18:56:10 +02:00
|
|
|
#
|
|
|
|
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);
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2013-09-25 19:42:12 +02:00
|
|
|
drop table t2;
|
2011-04-28 18:56:10 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# Test of things that is not possible to do 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);
|
|
|
|
|
2013-07-10 12:48:56 +02:00
|
|
|
--error ER_ALTER_OPERATION_NOT_SUPPORTED
|
2011-04-28 18:56:10 +02:00
|
|
|
alter online table t1 drop column b, add b int;
|
2013-07-10 12:48:56 +02:00
|
|
|
--error ER_ALTER_OPERATION_NOT_SUPPORTED
|
2011-04-28 18:56:10 +02:00
|
|
|
alter online table t1 modify b bigint;
|
2013-07-10 12:48:56 +02:00
|
|
|
--error ER_ALTER_OPERATION_NOT_SUPPORTED
|
2011-04-28 18:56:10 +02:00
|
|
|
alter online table t1 modify e enum('c','a','b');
|
2013-07-10 12:48:56 +02:00
|
|
|
--error ER_ALTER_OPERATION_NOT_SUPPORTED
|
2011-04-28 18:56:10 +02:00
|
|
|
alter online table t1 modify c varchar(50);
|
2013-07-10 12:48:56 +02:00
|
|
|
--error ER_ALTER_OPERATION_NOT_SUPPORTED
|
2011-04-28 18:56:10 +02:00
|
|
|
alter online table t1 modify c varchar(100);
|
2013-07-10 12:48:56 +02:00
|
|
|
--error ER_ALTER_OPERATION_NOT_SUPPORTED
|
2011-04-28 18:56:10 +02:00
|
|
|
alter online table t1 add f int;
|
2013-09-25 19:42:12 +02:00
|
|
|
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
|
2011-04-28 18:56:10 +02:00
|
|
|
alter online table t1 engine=memory;
|
2016-02-11 12:25:23 +01:00
|
|
|
--error ER_ALTER_OPERATION_NOT_SUPPORTED
|
|
|
|
alter online table t1 rename to t2;
|
2011-04-28 18:56:10 +02:00
|
|
|
|
|
|
|
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;
|
2016-02-11 12:25:23 +01:00
|
|
|
alter online table t1 comment "new comment";
|
2011-04-28 18:56:10 +02:00
|
|
|
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);
|
|
|
|
|
2013-09-25 19:42:12 +02:00
|
|
|
#
|
|
|
|
# everything with temporary tables is "online", i.e. without locks
|
|
|
|
#
|
2011-04-28 18:56:10 +02:00
|
|
|
alter online table t1 drop column b, add b int;
|
|
|
|
alter online table t1 modify b bigint;
|
|
|
|
alter online table t1 modify e enum('c','a','b');
|
|
|
|
alter online table t1 modify c varchar(50);
|
|
|
|
alter online table t1 modify c varchar(100);
|
|
|
|
alter online table t1 add f int;
|
|
|
|
alter online table t1 engine=memory;
|
|
|
|
|
|
|
|
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;
|
|
|
|
drop table t1;
|
|
|
|
|
|
|
|
#
|
|
|
|
# Test merge tables
|
|
|
|
#
|
|
|
|
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);
|
2013-09-25 19:42:12 +02:00
|
|
|
--error ER_ALTER_OPERATION_NOT_SUPPORTED
|
2011-04-28 18:56:10 +02:00
|
|
|
alter online table t3 union=(t1,t2);
|
|
|
|
drop table t1,t2,t3;
|
2015-10-15 16:25:54 +02:00
|
|
|
|
|
|
|
--echo #
|
|
|
|
--echo # MDEV-8948 ALTER ... INPLACE does work for BINARY, BLOB
|
|
|
|
--echo #
|
|
|
|
#
|
|
|
|
# ALTER to the same [VAR]BINARY type
|
|
|
|
#
|
|
|
|
CREATE TABLE t1 (a BINARY(10));
|
|
|
|
ALTER TABLE t1 MODIFY a BINARY(10), ALGORITHM=INPLACE;
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
|
|
|
CREATE TABLE t1 (a VARBINARY(10));
|
|
|
|
ALTER TABLE t1 MODIFY a VARBINARY(10), ALGORITHM=INPLACE;
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
|
|
|
#
|
|
|
|
# ALTER to the same BLOB variant
|
|
|
|
#
|
|
|
|
CREATE TABLE t1 (a TINYBLOB);
|
|
|
|
ALTER TABLE t1 MODIFY a TINYBLOB, ALGORITHM=INPLACE;
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
|
|
|
CREATE TABLE t1 (a MEDIUMBLOB);
|
|
|
|
ALTER TABLE t1 MODIFY a MEDIUMBLOB, ALGORITHM=INPLACE;
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
|
|
|
CREATE TABLE t1 (a BLOB);
|
|
|
|
ALTER TABLE t1 MODIFY a BLOB, ALGORITHM=INPLACE;
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
|
|
|
CREATE TABLE t1 (a LONGBLOB);
|
|
|
|
ALTER TABLE t1 MODIFY a LONGBLOB, ALGORITHM=INPLACE;
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
|
|
|
#
|
|
|
|
# ALTER to the same [VAR]CHAR type
|
|
|
|
#
|
|
|
|
CREATE TABLE t1 (a CHAR(10));
|
|
|
|
ALTER TABLE t1 MODIFY a CHAR(10), ALGORITHM=INPLACE;
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
|
|
|
CREATE TABLE t1 (a VARCHAR(10));
|
|
|
|
ALTER TABLE t1 MODIFY a VARCHAR(10), ALGORITHM=INPLACE;
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# ALTER to the same TEXT variant
|
|
|
|
#
|
|
|
|
CREATE TABLE t1 (a TINYTEXT);
|
|
|
|
ALTER TABLE t1 MODIFY a TINYTEXT, ALGORITHM=INPLACE;
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
|
|
|
CREATE TABLE t1 (a MEDIUMTEXT);
|
|
|
|
ALTER TABLE t1 MODIFY a MEDIUMTEXT, ALGORITHM=INPLACE;
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
|
|
|
CREATE TABLE t1 (a TEXT);
|
|
|
|
ALTER TABLE t1 MODIFY a TEXT, ALGORITHM=INPLACE;
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
|
|
|
CREATE TABLE t1 (a LONGTEXT);
|
|
|
|
ALTER TABLE t1 MODIFY a LONGTEXT, ALGORITHM=INPLACE;
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
|
|
|
#
|
|
|
|
# ALTER from a non-binary to a binary collation
|
|
|
|
#
|
|
|
|
CREATE TABLE t1 (a CHAR(10));
|
|
|
|
--error ER_ALTER_OPERATION_NOT_SUPPORTED
|
|
|
|
ALTER TABLE t1 MODIFY a CHAR(10) COLLATE latin1_bin, ALGORITHM=INPLACE;
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
|
|
|
CREATE TABLE t1 (a VARCHAR(10));
|
|
|
|
--error ER_ALTER_OPERATION_NOT_SUPPORTED
|
|
|
|
ALTER TABLE t1 MODIFY a VARCHAR(10) COLLATE latin1_bin, ALGORITHM=INPLACE;
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
|
|
|
CREATE TABLE t1 (a TINYTEXT);
|
|
|
|
--error ER_ALTER_OPERATION_NOT_SUPPORTED
|
|
|
|
ALTER TABLE t1 MODIFY a TINYTEXT COLLATE latin1_bin, ALGORITHM=INPLACE;
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
|
|
|
CREATE TABLE t1 (a MEDIUMTEXT);
|
|
|
|
--error ER_ALTER_OPERATION_NOT_SUPPORTED
|
|
|
|
ALTER TABLE t1 MODIFY a MEDIUMTEXT COLLATE latin1_bin, ALGORITHM=INPLACE;
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
|
|
|
CREATE TABLE t1 (a TEXT);
|
|
|
|
--error ER_ALTER_OPERATION_NOT_SUPPORTED
|
|
|
|
ALTER TABLE t1 MODIFY a TEXT COLLATE latin1_bin, ALGORITHM=INPLACE;
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
|
|
|
CREATE TABLE t1 (a LONGTEXT);
|
|
|
|
--error ER_ALTER_OPERATION_NOT_SUPPORTED
|
|
|
|
ALTER TABLE t1 MODIFY a LONGTEXT COLLATE latin1_bin, ALGORITHM=INPLACE;
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
|
|
|
#
|
|
|
|
# ALTER from a binary to a non-binary collation
|
|
|
|
#
|
|
|
|
CREATE TABLE t1 (a CHAR(10) COLLATE latin1_bin);
|
|
|
|
--error ER_ALTER_OPERATION_NOT_SUPPORTED
|
|
|
|
ALTER TABLE t1 MODIFY a CHAR(10) COLLATE latin1_swedish_ci, ALGORITHM=INPLACE;
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
|
|
|
CREATE TABLE t1 (a VARCHAR(10) COLLATE latin1_bin);
|
|
|
|
--error ER_ALTER_OPERATION_NOT_SUPPORTED
|
|
|
|
ALTER TABLE t1 MODIFY a VARCHAR(10) COLLATE latin1_swedish_ci, ALGORITHM=INPLACE;
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
|
|
|
CREATE TABLE t1 (a TINYTEXT COLLATE latin1_bin);
|
|
|
|
--error ER_ALTER_OPERATION_NOT_SUPPORTED
|
|
|
|
ALTER TABLE t1 MODIFY a TINYTEXT COLLATE latin1_swedish_ci, ALGORITHM=INPLACE;
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
|
|
|
CREATE TABLE t1 (a MEDIUMTEXT COLLATE latin1_bin);
|
|
|
|
--error ER_ALTER_OPERATION_NOT_SUPPORTED
|
|
|
|
ALTER TABLE t1 MODIFY a MEDIUMTEXT COLLATE latin1_swedish_ci, ALGORITHM=INPLACE;
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
|
|
|
CREATE TABLE t1 (a TEXT COLLATE latin1_bin);
|
|
|
|
--error ER_ALTER_OPERATION_NOT_SUPPORTED
|
|
|
|
ALTER TABLE t1 MODIFY a TEXT COLLATE latin1_swedish_ci, ALGORITHM=INPLACE;
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
|
|
|
CREATE TABLE t1 (a LONGTEXT COLLATE latin1_bin);
|
|
|
|
--error ER_ALTER_OPERATION_NOT_SUPPORTED
|
|
|
|
ALTER TABLE t1 MODIFY a LONGTEXT COLLATE latin1_swedish_ci, ALGORITHM=INPLACE;
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
|
|
|
#
|
|
|
|
# ALTER from a non-binary collation to another non-binary collation
|
|
|
|
#
|
|
|
|
CREATE TABLE t1 (a CHAR(10) COLLATE latin1_general_ci);
|
|
|
|
--error ER_ALTER_OPERATION_NOT_SUPPORTED
|
|
|
|
ALTER TABLE t1 MODIFY a CHAR(10) COLLATE latin1_swedish_ci, ALGORITHM=INPLACE;
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
|
|
|
CREATE TABLE t1 (a VARCHAR(10) COLLATE latin1_general_ci);
|
|
|
|
--error ER_ALTER_OPERATION_NOT_SUPPORTED
|
|
|
|
ALTER TABLE t1 MODIFY a VARCHAR(10) COLLATE latin1_swedish_ci, ALGORITHM=INPLACE;
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
|
|
|
CREATE TABLE t1 (a TINYTEXT COLLATE latin1_general_ci);
|
|
|
|
--error ER_ALTER_OPERATION_NOT_SUPPORTED
|
|
|
|
ALTER TABLE t1 MODIFY a TINYTEXT COLLATE latin1_swedish_ci, ALGORITHM=INPLACE;
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
|
|
|
CREATE TABLE t1 (a MEDIUMTEXT COLLATE latin1_general_ci);
|
|
|
|
--error ER_ALTER_OPERATION_NOT_SUPPORTED
|
|
|
|
ALTER TABLE t1 MODIFY a MEDIUMTEXT COLLATE latin1_swedish_ci, ALGORITHM=INPLACE;
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
|
|
|
CREATE TABLE t1 (a TEXT COLLATE latin1_general_ci);
|
|
|
|
--error ER_ALTER_OPERATION_NOT_SUPPORTED
|
|
|
|
ALTER TABLE t1 MODIFY a TEXT COLLATE latin1_swedish_ci, ALGORITHM=INPLACE;
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
|
|
|
CREATE TABLE t1 (a LONGTEXT COLLATE latin1_general_ci);
|
|
|
|
--error ER_ALTER_OPERATION_NOT_SUPPORTED
|
|
|
|
ALTER TABLE t1 MODIFY a LONGTEXT COLLATE latin1_swedish_ci, ALGORITHM=INPLACE;
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
|
|
|
--echo #
|
|
|
|
--echo # End of MDEV-8948 ALTER ... INPLACE does work for BINARY, BLOB
|
|
|
|
--echo #
|