summaryrefslogtreecommitdiff
path: root/mysql-test/suite/innodb/t/default_row_format_alter.test
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test/suite/innodb/t/default_row_format_alter.test')
-rw-r--r--mysql-test/suite/innodb/t/default_row_format_alter.test98
1 files changed, 98 insertions, 0 deletions
diff --git a/mysql-test/suite/innodb/t/default_row_format_alter.test b/mysql-test/suite/innodb/t/default_row_format_alter.test
new file mode 100644
index 00000000000..8f7217bcf0c
--- /dev/null
+++ b/mysql-test/suite/innodb/t/default_row_format_alter.test
@@ -0,0 +1,98 @@
+--source include/have_innodb.inc
+
+SET @row_format = @@GLOBAL.innodb_default_row_format;
+
+--echo ####################################
+--echo # Check if table rebuilding alter isn't affect if table is created
+--echo # with explicit row_format
+eval CREATE TABLE t1 (a INT PRIMARY KEY, b TEXT) ROW_FORMAT=COMPACT ENGINE=INNODB;
+INSERT INTO t1 VALUES (1, 'abc');
+--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 #
+SHOW TABLE STATUS LIKE 't1';
+
+SET GLOBAL innodb_default_row_format=DYNAMIC;
+ALTER TABLE t1 DROP PRIMARY KEY, ADD COLUMN c INT PRIMARY KEY;
+
+--echo # Here we expect COMPACT because it was explicitly specified at CREATE
+--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 #
+SHOW TABLE STATUS LIKE 't1';
+DROP TABLE t1;
+
+--echo ####################################
+--echo # Check if table rebuilding alter is affected when there is no
+--echo # row_format specified at CREATE TABLE.
+SET GLOBAL innodb_default_row_format = COMPACT;
+eval CREATE TABLE t1 (a INT PRIMARY KEY, b TEXT) ENGINE=INNODB;
+INSERT INTO t1 VALUES (1, 'abc');
+
+--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 #
+SHOW TABLE STATUS LIKE 't1';
+
+SET GLOBAL innodb_default_row_format = DYNAMIC;
+ALTER TABLE t1 DROP PRIMARY KEY, ADD COLUMN c INT PRIMARY KEY;
+
+--echo # Here we expect DYNAMIC because there is no explicit ROW_FORMAT and the
+--echo # default_row_format is changed to DYNAMIC just before ALTER
+--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 #
+SHOW TABLE STATUS LIKE 't1';
+DROP TABLE t1;
+
+--echo ####################################
+--echo # Check the row_format effect on ALTER, ALGORITHM=COPY
+SET GLOBAL innodb_default_row_format = REDUNDANT;
+eval CREATE TABLE t1 (a INT PRIMARY KEY, b TEXT) ENGINE=INNODB;
+INSERT INTO t1 VALUES (1, REPEAT('abc',1000));
+
+--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 #
+SHOW TABLE STATUS LIKE 't1';
+
+SET GLOBAL innoDB_default_row_format = COMPACT;
+ALTER TABLE t1 ADD COLUMN c2 BLOB, ALGORITHM=COPY;
+
+--echo # Because of ALGORITHM=COPY, there is TABLE REBUILD and the table isn't
+--echo # created with explicit row_format, so we expect ROW_FORMAT=COMPACT
+--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 #
+SHOW TABLE STATUS LIKE 't1';
+DROP TABLE t1;
+
+--echo
+--echo ###################################
+--echo # Check the row_format effect on ALTER, ALGORITH=COPY on
+--echo # create table with explicit row_format
+eval CREATE TABLE t1 (a INT PRIMARY KEY, b TEXT) ROW_FORMAT=REDUNDANT ENGINE=INNODB;
+INSERT INTO t1 VALUES (1, REPEAT('abc',1000));
+
+--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 #
+SHOW TABLE STATUS LIKE 't1';
+
+SET GLOBAL innoDB_default_row_format = COMPACT;
+ALTER TABLE t1 ADD COLUMN c2 BLOB, ALGORITHM=COPY;
+
+--echo # Because of ALGORITHM=COPY, there is TABLE REBUILD and the table is
+--echo # created with explicit row_format, so we expect original
+--echo # ROW_FORMAT=REDUNDANT
+--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 #
+SHOW TABLE STATUS LIKE 't1';
+DROP TABLE t1;
+
+--echo
+--echo ##################################
+--echo # Check row_format on ALTER ALGORITHM=INPLACE
+SET GLOBAL innodb_default_row_format=COMPACT;
+
+eval CREATE TABLE t1 (a INT PRIMARY KEY, b TEXT, KEY k1(b(10))) ENGINE=INNODB;
+INSERT INTO t1 VALUES (1, REPEAT('abc',1000));
+
+--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 #
+SHOW TABLE STATUS LIKE 't1';
+
+SET GLOBAL innodb_default_row_format=DYNAMIC;
+ALTER TABLE t1 DROP INDEX k1;
+
+--echo # Because it is in-place operation, there is no rebuild, so the
+--echo # original format has to be retained.
+--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 #
+SHOW TABLE STATUS LIKE 't1';
+DROP TABLE t1;
+
+SET GLOBAL innodb_default_row_format = @row_format;