summaryrefslogtreecommitdiff
path: root/mysql-test/t/alter_table_online.test
diff options
context:
space:
mode:
authorMichael Widenius <monty@askmonty.org>2011-04-28 19:56:10 +0300
committerMichael Widenius <monty@askmonty.org>2011-04-28 19:56:10 +0300
commit2721e912ba45f42f3ddf7c8366f6abbeef060833 (patch)
tree80c1fc27d71fa58e963c729657e383cf4b4d2c86 /mysql-test/t/alter_table_online.test
parent6da8ac5f71a6501cb0fb1304ff144ec41b4d9389 (diff)
downloadmariadb-git-2721e912ba45f42f3ddf7c8366f6abbeef060833.tar.gz
Added ALTER ONLINE TABLE, which will give an error if the change can't be done 'instantly' (without a table copy)
mysql-test/r/alter_table_online.result: Test new feature mysql-test/t/alter_table_online.test: Test new feature sql/handler.cc: Added comment sql/lex.h: Added ONLINE keyword sql/mysql_priv.h: Added option to alter table to require online operation sql/share/errmsg.txt: Added error message if ONLINE can't be done sql/sql_lex.h: Added online option sql/sql_parse.cc: Added online option to mysql_alter_table() sql/sql_table.cc: Added test that gives error if table can't be done instantly when requsted to be online. Fixed wrong test if table includes a VARCHAR Fixed wrong (but unlikely) handling of error conditions in ALTER table sql/sql_yacc.yy: Added ALTER ONLINE TABLE syntax storage/maria/ha_maria.cc: Fixed bug where 'start_bulk_insert' used too small buffer if used with unknown number of rows
Diffstat (limited to 'mysql-test/t/alter_table_online.test')
-rw-r--r--mysql-test/t/alter_table_online.test108
1 files changed, 108 insertions, 0 deletions
diff --git a/mysql-test/t/alter_table_online.test b/mysql-test/t/alter_table_online.test
new file mode 100644
index 00000000000..19096efe0fa
--- /dev/null
+++ b/mysql-test/t/alter_table_online.test
@@ -0,0 +1,108 @@
+#
+# Test of alter online table
+#
+
+--source include/have_innodb.inc
+--disable_warnings
+drop table if exists t1,t2,t3;
+--enable_warnings
+#
+# 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);
+
+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;
+
+drop table t1;
+
+#
+# temporary tables always require a copy
+#
+
+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;
+
+#
+# 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);
+
+--error ER_CANT_DO_ONLINE
+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;
+
+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 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;
+
+#
+# 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);
+alter online table t3 union=(t1,t2);
+drop table t1,t2,t3;