summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2018-09-17 14:22:30 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2018-09-17 14:37:39 +0300
commitac24289e6600403155127b1a36788ad8b4ead500 (patch)
tree25f2a266ee180d452c4e654ab70d0a62c811d581
parentc5a9a63293f868f074def37c985fe23a9c01c276 (diff)
downloadmariadb-git-ac24289e6600403155127b1a36788ad8b4ead500.tar.gz
MDEV-16328 ALTER TABLE…page_compression_level should not rebuild table
The table option page_compression_level is something that only affects future writes, not actually the data format. Therefore, we can allow instant changes of this option. Similarly, the table option page_compressed can be set on a previously uncompressed table without rebuilding the table, because an uncompressed page would be considered valid when reading a page_compressed table. Removing the page_compressed option will continue to require the table to be rebuilt. ha_innobase_inplace_ctx::page_compression_level: The requested page_compression_level at the start of ALTER TABLE, or 0 if page_compressed=OFF. alter_options_need_rebuild(): Renamed from create_option_need_rebuild(). Allow page_compression_level and page_compressed to be changed as above, without rebuilding the table. ha_innobase::check_if_supported_inplace_alter(): Allow ALGORITHM=INSTANT for ALTER_OPTIONS if the table is not to be rebuilt. If rebuild is needed, set ha_alter_info->unsupported_reason. innobase_page_compression_try(): Update SYS_TABLES.TYPE according to the table flags, for an instant change of page_compression_level or page_compressed. commit_cache_norebuild(): Adjust dict_table_t::flags, fil_space_t::flags and (if needed) FSP_SPACE_FLAGS if page_compression_level was specified.
-rw-r--r--mysql-test/suite/innodb/r/alter_algorithm,COPY.rdiff92
-rw-r--r--mysql-test/suite/innodb/r/alter_algorithm,INPLACE.rdiff67
-rw-r--r--mysql-test/suite/innodb/r/alter_algorithm,INSTANT.rdiff59
-rw-r--r--mysql-test/suite/innodb/r/alter_algorithm,NOCOPY.rdiff92
-rw-r--r--mysql-test/suite/innodb/r/alter_algorithm.result51
-rw-r--r--mysql-test/suite/innodb/r/innodb-page_compression_bzip2.result8
-rw-r--r--mysql-test/suite/innodb/r/innodb-page_compression_lz4.result7
-rw-r--r--mysql-test/suite/innodb/r/innodb-page_compression_lzma.result8
-rw-r--r--mysql-test/suite/innodb/r/innodb-page_compression_lzo.result8
-rw-r--r--mysql-test/suite/innodb/r/innodb-page_compression_tables.result8
-rw-r--r--mysql-test/suite/innodb/r/innodb-page_compression_zip.result7
-rw-r--r--mysql-test/suite/innodb/t/alter_algorithm.test2
-rw-r--r--mysql-test/suite/innodb/t/innodb-page_compression_bzip2.test15
-rw-r--r--mysql-test/suite/innodb/t/innodb-page_compression_lz4.test14
-rw-r--r--mysql-test/suite/innodb/t/innodb-page_compression_lzma.test15
-rw-r--r--mysql-test/suite/innodb/t/innodb-page_compression_lzo.test15
-rw-r--r--mysql-test/suite/innodb/t/innodb-page_compression_tables.test8
-rw-r--r--mysql-test/suite/innodb/t/innodb-page_compression_zip.test14
-rw-r--r--sql/share/errmsg-utf8.txt2
-rw-r--r--storage/innobase/handler/handler0alter.cc197
20 files changed, 450 insertions, 239 deletions
diff --git a/mysql-test/suite/innodb/r/alter_algorithm,COPY.rdiff b/mysql-test/suite/innodb/r/alter_algorithm,COPY.rdiff
deleted file mode 100644
index be71e125e22..00000000000
--- a/mysql-test/suite/innodb/r/alter_algorithm,COPY.rdiff
+++ /dev/null
@@ -1,92 +0,0 @@
---- alter_algorithm.result 2018-05-06 23:42:08.022302601 +0530
-+++ alter_algorithm.reject 2018-05-06 23:42:16.382634082 +0530
-@@ -7,35 +7,44 @@
- INSERT INTO t1(f1, f2, f3) VALUES(1, 1, 1);
- SELECT @@alter_algorithm;
- @@alter_algorithm
--NOCOPY
-+COPY
- # All the following cases needs table rebuild
- # Add and Drop primary key
- ALTER TABLE t1 ADD COLUMN col1 INT NOT NULL,DROP PRIMARY KEY,ADD PRIMARY KEY(col1);
--ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE
-+affected rows: 1
-+info: Records: 1 Duplicates: 0 Warnings: 0
- # Make existing column NULLABLE
- ALTER TABLE t1 MODIFY f2 INT;
--ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE
-+affected rows: 1
-+info: Records: 1 Duplicates: 0 Warnings: 0
- # Make existing column NON-NULLABLE
- ALTER TABLE t1 MODIFY f3 INT NOT NULL;
--ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE
-+affected rows: 1
-+info: Records: 1 Duplicates: 0 Warnings: 0
- # Drop Stored Column
- ALTER TABLE t1 DROP COLUMN f5;
--ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE
-+affected rows: 1
-+info: Records: 1 Duplicates: 0 Warnings: 0
- # Add base non-generated column as a last column in the compressed table
- ALTER TABLE t1 ADD COLUMN f6 INT NOT NULL;
--ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE
-+affected rows: 1
-+info: Records: 1 Duplicates: 0 Warnings: 0
- # Add base non-generated column but not in the last position
- ALTER TABLE t1 ADD COLUMN f7 INT NOT NULL after f3;
--ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE
-+affected rows: 1
-+info: Records: 1 Duplicates: 0 Warnings: 0
- # Force the table to rebuild
- ALTER TABLE t1 FORCE;
--ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE
-+affected rows: 1
-+info: Records: 1 Duplicates: 0 Warnings: 0
- # Row format changes
- ALTER TABLE t1 ROW_FORMAT=COMPRESSED;
--ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE
-+affected rows: 1
-+info: Records: 1 Duplicates: 0 Warnings: 0
- # Engine table
- ALTER TABLE t1 ENGINE=INNODB;
--ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE
-+affected rows: 1
-+info: Records: 1 Duplicates: 0 Warnings: 0
- DROP TABLE t1;
- affected rows: 0
- CREATE TABLE t1(f1 INT PRIMARY KEY, f2 INT NOT NULL,
-@@ -49,23 +58,23 @@
- INSERT INTO t1(f1, f2, f4, f5) VALUES(1, 2, 3, 4);
- SELECT @@alter_algorithm;
- @@alter_algorithm
--NOCOPY
-+COPY
- ALTER TABLE t1 ADD INDEX idx1(f4);
--affected rows: 0
--info: Records: 0 Duplicates: 0 Warnings: 0
-+affected rows: 1
-+info: Records: 1 Duplicates: 0 Warnings: 0
- ALTER TABLE t1 DROP INDEX idx;
--affected rows: 0
--info: Records: 0 Duplicates: 0 Warnings: 0
-+affected rows: 1
-+info: Records: 1 Duplicates: 0 Warnings: 0
- ALTER TABLE t1 ADD UNIQUE INDEX u1(f2);
--affected rows: 0
--info: Records: 0 Duplicates: 0 Warnings: 0
-+affected rows: 1
-+info: Records: 1 Duplicates: 0 Warnings: 0
- ALTER TABLE t1 DROP INDEX f4;
--affected rows: 0
--info: Records: 0 Duplicates: 0 Warnings: 0
-+affected rows: 1
-+info: Records: 1 Duplicates: 0 Warnings: 0
- SET foreign_key_checks = 0;
- affected rows: 0
- ALTER TABLE t1 ADD FOREIGN KEY(f5) REFERENCES t2(f1);
--affected rows: 0
--info: Records: 0 Duplicates: 0 Warnings: 0
-+affected rows: 1
-+info: Records: 1 Duplicates: 0 Warnings: 0
- DROP TABLE t2, t1;
- affected rows: 0
diff --git a/mysql-test/suite/innodb/r/alter_algorithm,INPLACE.rdiff b/mysql-test/suite/innodb/r/alter_algorithm,INPLACE.rdiff
index 71891bbf473..e9a24820a50 100644
--- a/mysql-test/suite/innodb/r/alter_algorithm,INPLACE.rdiff
+++ b/mysql-test/suite/innodb/r/alter_algorithm,INPLACE.rdiff
@@ -1,66 +1,101 @@
---- alter_algorithm.result 2018-05-06 23:42:08.022302601 +0530
-+++ alter_algorithm.reject 2018-05-06 23:45:23.813346814 +0530
-@@ -7,35 +7,44 @@
+--- alter_algorithm.result
++++ alter_algorithm.reject
+@@ -7,44 +7,44 @@
INSERT INTO t1(f1, f2, f3) VALUES(1, 1, 1);
SELECT @@alter_algorithm;
@@alter_algorithm
--NOCOPY
+-COPY
+INPLACE
# All the following cases needs table rebuild
# Add and Drop primary key
ALTER TABLE t1 ADD COLUMN col1 INT NOT NULL,DROP PRIMARY KEY,ADD PRIMARY KEY(col1);
--ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE
+-affected rows: 1
+-info: Records: 1 Duplicates: 0 Warnings: 0
+affected rows: 0
+info: Records: 0 Duplicates: 0 Warnings: 0
# Make existing column NULLABLE
ALTER TABLE t1 MODIFY f2 INT;
--ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE
+-affected rows: 1
+-info: Records: 1 Duplicates: 0 Warnings: 0
+affected rows: 0
+info: Records: 0 Duplicates: 0 Warnings: 0
# Make existing column NON-NULLABLE
ALTER TABLE t1 MODIFY f3 INT NOT NULL;
--ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE
+-affected rows: 1
+-info: Records: 1 Duplicates: 0 Warnings: 0
+affected rows: 0
+info: Records: 0 Duplicates: 0 Warnings: 0
# Drop Stored Column
ALTER TABLE t1 DROP COLUMN f5;
--ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE
+-affected rows: 1
+-info: Records: 1 Duplicates: 0 Warnings: 0
+affected rows: 0
+info: Records: 0 Duplicates: 0 Warnings: 0
# Add base non-generated column as a last column in the compressed table
ALTER TABLE t1 ADD COLUMN f6 INT NOT NULL;
--ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE
+-affected rows: 1
+-info: Records: 1 Duplicates: 0 Warnings: 0
+affected rows: 0
+info: Records: 0 Duplicates: 0 Warnings: 0
# Add base non-generated column but not in the last position
ALTER TABLE t1 ADD COLUMN f7 INT NOT NULL after f3;
--ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE
+-affected rows: 1
+-info: Records: 1 Duplicates: 0 Warnings: 0
+affected rows: 0
+info: Records: 0 Duplicates: 0 Warnings: 0
# Force the table to rebuild
ALTER TABLE t1 FORCE;
--ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE
+-affected rows: 1
+-info: Records: 1 Duplicates: 0 Warnings: 0
+affected rows: 0
+info: Records: 0 Duplicates: 0 Warnings: 0
# Row format changes
ALTER TABLE t1 ROW_FORMAT=COMPRESSED;
--ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE
+-affected rows: 1
+-info: Records: 1 Duplicates: 0 Warnings: 0
+affected rows: 0
+info: Records: 0 Duplicates: 0 Warnings: 0
# Engine table
ALTER TABLE t1 ENGINE=INNODB;
--ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE
+-affected rows: 1
+-info: Records: 1 Duplicates: 0 Warnings: 0
+affected rows: 0
+info: Records: 0 Duplicates: 0 Warnings: 0
DROP TABLE t1;
affected rows: 0
CREATE TABLE t1(f1 INT PRIMARY KEY, f2 INT NOT NULL,
-@@ -49,7 +58,7 @@
+@@ -58,23 +58,23 @@
INSERT INTO t1(f1, f2, f4, f5) VALUES(1, 2, 3, 4);
SELECT @@alter_algorithm;
@@alter_algorithm
--NOCOPY
+-COPY
+INPLACE
ALTER TABLE t1 ADD INDEX idx1(f4);
+-affected rows: 1
+-info: Records: 1 Duplicates: 0 Warnings: 0
++affected rows: 0
++info: Records: 0 Duplicates: 0 Warnings: 0
+ ALTER TABLE t1 DROP INDEX idx;
+-affected rows: 1
+-info: Records: 1 Duplicates: 0 Warnings: 0
++affected rows: 0
++info: Records: 0 Duplicates: 0 Warnings: 0
+ ALTER TABLE t1 ADD UNIQUE INDEX u1(f2);
+-affected rows: 1
+-info: Records: 1 Duplicates: 0 Warnings: 0
++affected rows: 0
++info: Records: 0 Duplicates: 0 Warnings: 0
+ ALTER TABLE t1 DROP INDEX f4;
+-affected rows: 1
+-info: Records: 1 Duplicates: 0 Warnings: 0
++affected rows: 0
++info: Records: 0 Duplicates: 0 Warnings: 0
+ SET foreign_key_checks = 0;
+ affected rows: 0
+ ALTER TABLE t1 ADD FOREIGN KEY(f5) REFERENCES t2(f1);
+-affected rows: 1
+-info: Records: 1 Duplicates: 0 Warnings: 0
++affected rows: 0
++info: Records: 0 Duplicates: 0 Warnings: 0
+ DROP TABLE t2, t1;
affected rows: 0
- info: Records: 0 Duplicates: 0 Warnings: 0
diff --git a/mysql-test/suite/innodb/r/alter_algorithm,INSTANT.rdiff b/mysql-test/suite/innodb/r/alter_algorithm,INSTANT.rdiff
index 6e12b78fb9d..c432494dd53 100644
--- a/mysql-test/suite/innodb/r/alter_algorithm,INSTANT.rdiff
+++ b/mysql-test/suite/innodb/r/alter_algorithm,INSTANT.rdiff
@@ -1,78 +1,87 @@
---- alter_algorithm.result 2018-05-06 23:42:08.022302601 +0530
-+++ alter_algorithm.reject 2018-05-06 23:46:08.482772800 +0530
-@@ -7,35 +7,35 @@
+--- alter_algorithm.result
++++ alter_algorithm.reject
+@@ -7,44 +7,35 @@
INSERT INTO t1(f1, f2, f3) VALUES(1, 1, 1);
SELECT @@alter_algorithm;
@@alter_algorithm
--NOCOPY
+-COPY
+INSTANT
# All the following cases needs table rebuild
# Add and Drop primary key
ALTER TABLE t1 ADD COLUMN col1 INT NOT NULL,DROP PRIMARY KEY,ADD PRIMARY KEY(col1);
--ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE
+-affected rows: 1
+-info: Records: 1 Duplicates: 0 Warnings: 0
+Got one of the listed errors
# Make existing column NULLABLE
ALTER TABLE t1 MODIFY f2 INT;
--ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE
+-affected rows: 1
+-info: Records: 1 Duplicates: 0 Warnings: 0
+Got one of the listed errors
# Make existing column NON-NULLABLE
ALTER TABLE t1 MODIFY f3 INT NOT NULL;
--ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE
+-affected rows: 1
+-info: Records: 1 Duplicates: 0 Warnings: 0
+Got one of the listed errors
# Drop Stored Column
ALTER TABLE t1 DROP COLUMN f5;
--ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE
+-affected rows: 1
+-info: Records: 1 Duplicates: 0 Warnings: 0
+Got one of the listed errors
# Add base non-generated column as a last column in the compressed table
ALTER TABLE t1 ADD COLUMN f6 INT NOT NULL;
--ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE
+-affected rows: 1
+-info: Records: 1 Duplicates: 0 Warnings: 0
+Got one of the listed errors
# Add base non-generated column but not in the last position
ALTER TABLE t1 ADD COLUMN f7 INT NOT NULL after f3;
--ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE
+-affected rows: 1
+-info: Records: 1 Duplicates: 0 Warnings: 0
+Got one of the listed errors
# Force the table to rebuild
ALTER TABLE t1 FORCE;
--ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE
+-affected rows: 1
+-info: Records: 1 Duplicates: 0 Warnings: 0
+Got one of the listed errors
# Row format changes
ALTER TABLE t1 ROW_FORMAT=COMPRESSED;
--ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE
+-affected rows: 1
+-info: Records: 1 Duplicates: 0 Warnings: 0
+Got one of the listed errors
# Engine table
ALTER TABLE t1 ENGINE=INNODB;
--ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE
+-affected rows: 1
+-info: Records: 1 Duplicates: 0 Warnings: 0
+Got one of the listed errors
DROP TABLE t1;
affected rows: 0
CREATE TABLE t1(f1 INT PRIMARY KEY, f2 INT NOT NULL,
-@@ -49,23 +49,18 @@
+@@ -58,23 +49,18 @@
INSERT INTO t1(f1, f2, f4, f5) VALUES(1, 2, 3, 4);
SELECT @@alter_algorithm;
@@alter_algorithm
--NOCOPY
+-COPY
+INSTANT
ALTER TABLE t1 ADD INDEX idx1(f4);
--affected rows: 0
--info: Records: 0 Duplicates: 0 Warnings: 0
+-affected rows: 1
+-info: Records: 1 Duplicates: 0 Warnings: 0
+ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: ADD INDEX. Try ALGORITHM=NOCOPY
ALTER TABLE t1 DROP INDEX idx;
--affected rows: 0
--info: Records: 0 Duplicates: 0 Warnings: 0
+-affected rows: 1
+-info: Records: 1 Duplicates: 0 Warnings: 0
+ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: DROP INDEX. Try ALGORITHM=NOCOPY
ALTER TABLE t1 ADD UNIQUE INDEX u1(f2);
--affected rows: 0
--info: Records: 0 Duplicates: 0 Warnings: 0
+-affected rows: 1
+-info: Records: 1 Duplicates: 0 Warnings: 0
+ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: ADD INDEX. Try ALGORITHM=NOCOPY
ALTER TABLE t1 DROP INDEX f4;
--affected rows: 0
--info: Records: 0 Duplicates: 0 Warnings: 0
+-affected rows: 1
+-info: Records: 1 Duplicates: 0 Warnings: 0
+ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: DROP INDEX. Try ALGORITHM=NOCOPY
SET foreign_key_checks = 0;
affected rows: 0
ALTER TABLE t1 ADD FOREIGN KEY(f5) REFERENCES t2(f1);
--affected rows: 0
--info: Records: 0 Duplicates: 0 Warnings: 0
+-affected rows: 1
+-info: Records: 1 Duplicates: 0 Warnings: 0
+ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: ADD INDEX. Try ALGORITHM=NOCOPY
DROP TABLE t2, t1;
affected rows: 0
diff --git a/mysql-test/suite/innodb/r/alter_algorithm,NOCOPY.rdiff b/mysql-test/suite/innodb/r/alter_algorithm,NOCOPY.rdiff
new file mode 100644
index 00000000000..3ec1eed2e3b
--- /dev/null
+++ b/mysql-test/suite/innodb/r/alter_algorithm,NOCOPY.rdiff
@@ -0,0 +1,92 @@
+--- alter_algorithm.result
++++ alter_algorithm.reject
+@@ -7,44 +7,35 @@
+ INSERT INTO t1(f1, f2, f3) VALUES(1, 1, 1);
+ SELECT @@alter_algorithm;
+ @@alter_algorithm
+-COPY
++NOCOPY
+ # All the following cases needs table rebuild
+ # Add and Drop primary key
+ ALTER TABLE t1 ADD COLUMN col1 INT NOT NULL,DROP PRIMARY KEY,ADD PRIMARY KEY(col1);
+-affected rows: 1
+-info: Records: 1 Duplicates: 0 Warnings: 0
++Got one of the listed errors
+ # Make existing column NULLABLE
+ ALTER TABLE t1 MODIFY f2 INT;
+-affected rows: 1
+-info: Records: 1 Duplicates: 0 Warnings: 0
++Got one of the listed errors
+ # Make existing column NON-NULLABLE
+ ALTER TABLE t1 MODIFY f3 INT NOT NULL;
+-affected rows: 1
+-info: Records: 1 Duplicates: 0 Warnings: 0
++Got one of the listed errors
+ # Drop Stored Column
+ ALTER TABLE t1 DROP COLUMN f5;
+-affected rows: 1
+-info: Records: 1 Duplicates: 0 Warnings: 0
++Got one of the listed errors
+ # Add base non-generated column as a last column in the compressed table
+ ALTER TABLE t1 ADD COLUMN f6 INT NOT NULL;
+-affected rows: 1
+-info: Records: 1 Duplicates: 0 Warnings: 0
++Got one of the listed errors
+ # Add base non-generated column but not in the last position
+ ALTER TABLE t1 ADD COLUMN f7 INT NOT NULL after f3;
+-affected rows: 1
+-info: Records: 1 Duplicates: 0 Warnings: 0
++Got one of the listed errors
+ # Force the table to rebuild
+ ALTER TABLE t1 FORCE;
+-affected rows: 1
+-info: Records: 1 Duplicates: 0 Warnings: 0
++Got one of the listed errors
+ # Row format changes
+ ALTER TABLE t1 ROW_FORMAT=COMPRESSED;
+-affected rows: 1
+-info: Records: 1 Duplicates: 0 Warnings: 0
++Got one of the listed errors
+ # Engine table
+ ALTER TABLE t1 ENGINE=INNODB;
+-affected rows: 1
+-info: Records: 1 Duplicates: 0 Warnings: 0
++Got one of the listed errors
+ DROP TABLE t1;
+ affected rows: 0
+ CREATE TABLE t1(f1 INT PRIMARY KEY, f2 INT NOT NULL,
+@@ -58,23 +49,23 @@
+ INSERT INTO t1(f1, f2, f4, f5) VALUES(1, 2, 3, 4);
+ SELECT @@alter_algorithm;
+ @@alter_algorithm
+-COPY
++NOCOPY
+ ALTER TABLE t1 ADD INDEX idx1(f4);
+-affected rows: 1
+-info: Records: 1 Duplicates: 0 Warnings: 0
++affected rows: 0
++info: Records: 0 Duplicates: 0 Warnings: 0
+ ALTER TABLE t1 DROP INDEX idx;
+-affected rows: 1
+-info: Records: 1 Duplicates: 0 Warnings: 0
++affected rows: 0
++info: Records: 0 Duplicates: 0 Warnings: 0
+ ALTER TABLE t1 ADD UNIQUE INDEX u1(f2);
+-affected rows: 1
+-info: Records: 1 Duplicates: 0 Warnings: 0
++affected rows: 0
++info: Records: 0 Duplicates: 0 Warnings: 0
+ ALTER TABLE t1 DROP INDEX f4;
+-affected rows: 1
+-info: Records: 1 Duplicates: 0 Warnings: 0
++affected rows: 0
++info: Records: 0 Duplicates: 0 Warnings: 0
+ SET foreign_key_checks = 0;
+ affected rows: 0
+ ALTER TABLE t1 ADD FOREIGN KEY(f5) REFERENCES t2(f1);
+-affected rows: 1
+-info: Records: 1 Duplicates: 0 Warnings: 0
++affected rows: 0
++info: Records: 0 Duplicates: 0 Warnings: 0
+ DROP TABLE t2, t1;
+ affected rows: 0
diff --git a/mysql-test/suite/innodb/r/alter_algorithm.result b/mysql-test/suite/innodb/r/alter_algorithm.result
index ee91159bf7a..9a031d9066a 100644
--- a/mysql-test/suite/innodb/r/alter_algorithm.result
+++ b/mysql-test/suite/innodb/r/alter_algorithm.result
@@ -7,35 +7,44 @@ PRIMARY KEY(f1))ROW_FORMAT=COMPRESSED, ENGINE=INNODB;
INSERT INTO t1(f1, f2, f3) VALUES(1, 1, 1);
SELECT @@alter_algorithm;
@@alter_algorithm
-NOCOPY
+COPY
# All the following cases needs table rebuild
# Add and Drop primary key
ALTER TABLE t1 ADD COLUMN col1 INT NOT NULL,DROP PRIMARY KEY,ADD PRIMARY KEY(col1);
-ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE
+affected rows: 1
+info: Records: 1 Duplicates: 0 Warnings: 0
# Make existing column NULLABLE
ALTER TABLE t1 MODIFY f2 INT;
-ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE
+affected rows: 1
+info: Records: 1 Duplicates: 0 Warnings: 0
# Make existing column NON-NULLABLE
ALTER TABLE t1 MODIFY f3 INT NOT NULL;
-ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE
+affected rows: 1
+info: Records: 1 Duplicates: 0 Warnings: 0
# Drop Stored Column
ALTER TABLE t1 DROP COLUMN f5;
-ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE
+affected rows: 1
+info: Records: 1 Duplicates: 0 Warnings: 0
# Add base non-generated column as a last column in the compressed table
ALTER TABLE t1 ADD COLUMN f6 INT NOT NULL;
-ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE
+affected rows: 1
+info: Records: 1 Duplicates: 0 Warnings: 0
# Add base non-generated column but not in the last position
ALTER TABLE t1 ADD COLUMN f7 INT NOT NULL after f3;
-ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE
+affected rows: 1
+info: Records: 1 Duplicates: 0 Warnings: 0
# Force the table to rebuild
ALTER TABLE t1 FORCE;
-ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE
+affected rows: 1
+info: Records: 1 Duplicates: 0 Warnings: 0
# Row format changes
ALTER TABLE t1 ROW_FORMAT=COMPRESSED;
-ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE
+affected rows: 1
+info: Records: 1 Duplicates: 0 Warnings: 0
# Engine table
ALTER TABLE t1 ENGINE=INNODB;
-ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE
+affected rows: 1
+info: Records: 1 Duplicates: 0 Warnings: 0
DROP TABLE t1;
affected rows: 0
CREATE TABLE t1(f1 INT PRIMARY KEY, f2 INT NOT NULL,
@@ -49,23 +58,23 @@ FOREIGN KEY `fidx` (f1) REFERENCES t1(f1))ENGINE=INNODB;
INSERT INTO t1(f1, f2, f4, f5) VALUES(1, 2, 3, 4);
SELECT @@alter_algorithm;
@@alter_algorithm
-NOCOPY
+COPY
ALTER TABLE t1 ADD INDEX idx1(f4);
-affected rows: 0
-info: Records: 0 Duplicates: 0 Warnings: 0
+affected rows: 1
+info: Records: 1 Duplicates: 0 Warnings: 0
ALTER TABLE t1 DROP INDEX idx;
-affected rows: 0
-info: Records: 0 Duplicates: 0 Warnings: 0
+affected rows: 1
+info: Records: 1 Duplicates: 0 Warnings: 0
ALTER TABLE t1 ADD UNIQUE INDEX u1(f2);
-affected rows: 0
-info: Records: 0 Duplicates: 0 Warnings: 0
+affected rows: 1
+info: Records: 1 Duplicates: 0 Warnings: 0
ALTER TABLE t1 DROP INDEX f4;
-affected rows: 0
-info: Records: 0 Duplicates: 0 Warnings: 0
+affected rows: 1
+info: Records: 1 Duplicates: 0 Warnings: 0
SET foreign_key_checks = 0;
affected rows: 0
ALTER TABLE t1 ADD FOREIGN KEY(f5) REFERENCES t2(f1);
-affected rows: 0
-info: Records: 0 Duplicates: 0 Warnings: 0
+affected rows: 1
+info: Records: 1 Duplicates: 0 Warnings: 0
DROP TABLE t2, t1;
affected rows: 0
diff --git a/mysql-test/suite/innodb/r/innodb-page_compression_bzip2.result b/mysql-test/suite/innodb/r/innodb-page_compression_bzip2.result
index 61507ddbe5c..5411f5149d1 100644
--- a/mysql-test/suite/innodb/r/innodb-page_compression_bzip2.result
+++ b/mysql-test/suite/innodb/r/innodb-page_compression_bzip2.result
@@ -147,7 +147,8 @@ count(*)
select count(*) from innodb_page_compressed9 where c1 < 500000;
count(*)
5000
-alter table innodb_normal page_compressed=1 page_compression_level=8;
+alter table innodb_normal page_compressed=1 page_compression_level=8,
+algorithm=instant;
show warnings;
Level Code Message
show create table innodb_normal;
@@ -156,6 +157,10 @@ innodb_normal CREATE TABLE `innodb_normal` (
`c1` int(11) DEFAULT NULL,
`b` char(20) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 `page_compressed`=1 `page_compression_level`=8
+alter table innodb_compressed row_format=default page_compressed=1 page_compression_level=8 key_block_size=0, algorithm=instant;
+ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: Changing table options requires the table to be rebuilt. Try ALGORITHM=INPLACE
+alter table innodb_compressed row_format=default page_compressed=1 page_compression_level=8 key_block_size=0, algorithm=nocopy;
+ERROR 0A000: ALGORITHM=NOCOPY is not supported. Reason: Changing table options requires the table to be rebuilt. Try ALGORITHM=INPLACE
alter table innodb_compressed row_format=default page_compressed=1 page_compression_level=8 key_block_size=0;
show warnings;
Level Code Message
@@ -174,6 +179,7 @@ update innodb_page_compressed6 set c1 = c1 + 1;
update innodb_page_compressed7 set c1 = c1 + 1;
update innodb_page_compressed8 set c1 = c1 + 1;
update innodb_page_compressed9 set c1 = c1 + 1;
+commit;
select count(*) from innodb_compressed;
count(*)
5000
diff --git a/mysql-test/suite/innodb/r/innodb-page_compression_lz4.result b/mysql-test/suite/innodb/r/innodb-page_compression_lz4.result
index 6cef1978ca0..aefb5c8a0be 100644
--- a/mysql-test/suite/innodb/r/innodb-page_compression_lz4.result
+++ b/mysql-test/suite/innodb/r/innodb-page_compression_lz4.result
@@ -147,7 +147,8 @@ count(*)
select count(*) from innodb_page_compressed9 where c1 < 500000;
count(*)
5000
-alter table innodb_normal page_compressed=1 page_compression_level=8;
+alter table innodb_normal page_compressed=1 page_compression_level=8,
+algorithm=instant;
show warnings;
Level Code Message
show create table innodb_normal;
@@ -156,6 +157,10 @@ innodb_normal CREATE TABLE `innodb_normal` (
`c1` int(11) DEFAULT NULL,
`b` char(20) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 `page_compressed`=1 `page_compression_level`=8
+alter table innodb_compressed row_format=default page_compressed=1 page_compression_level=8 key_block_size=0, algorithm=instant;
+ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: Changing table options requires the table to be rebuilt. Try ALGORITHM=INPLACE
+alter table innodb_compressed row_format=default page_compressed=1 page_compression_level=8 key_block_size=0, algorithm=nocopy;
+ERROR 0A000: ALGORITHM=NOCOPY is not supported. Reason: Changing table options requires the table to be rebuilt. Try ALGORITHM=INPLACE
alter table innodb_compressed row_format=default page_compressed=1 page_compression_level=8 key_block_size=0;
show warnings;
Level Code Message
diff --git a/mysql-test/suite/innodb/r/innodb-page_compression_lzma.result b/mysql-test/suite/innodb/r/innodb-page_compression_lzma.result
index c7ab859e102..606de870d7c 100644
--- a/mysql-test/suite/innodb/r/innodb-page_compression_lzma.result
+++ b/mysql-test/suite/innodb/r/innodb-page_compression_lzma.result
@@ -147,7 +147,8 @@ count(*)
select count(*) from innodb_page_compressed9 where c1 < 500000;
count(*)
5000
-alter table innodb_normal page_compressed=1 page_compression_level=8;
+alter table innodb_normal page_compressed=1 page_compression_level=8,
+algorithm=instant;
show warnings;
Level Code Message
show create table innodb_normal;
@@ -156,6 +157,10 @@ innodb_normal CREATE TABLE `innodb_normal` (
`c1` int(11) DEFAULT NULL,
`b` char(20) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 `page_compressed`=1 `page_compression_level`=8
+alter table innodb_compressed row_format=default page_compressed=1 page_compression_level=8 key_block_size=0, algorithm=instant;
+ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: Changing table options requires the table to be rebuilt. Try ALGORITHM=INPLACE
+alter table innodb_compressed row_format=default page_compressed=1 page_compression_level=8 key_block_size=0, algorithm=nocopy;
+ERROR 0A000: ALGORITHM=NOCOPY is not supported. Reason: Changing table options requires the table to be rebuilt. Try ALGORITHM=INPLACE
alter table innodb_compressed row_format=default page_compressed=1 page_compression_level=8 key_block_size=0;
show warnings;
Level Code Message
@@ -174,6 +179,7 @@ update innodb_page_compressed6 set c1 = c1 + 1;
update innodb_page_compressed7 set c1 = c1 + 1;
update innodb_page_compressed8 set c1 = c1 + 1;
update innodb_page_compressed9 set c1 = c1 + 1;
+commit;
select count(*) from innodb_compressed;
count(*)
5000
diff --git a/mysql-test/suite/innodb/r/innodb-page_compression_lzo.result b/mysql-test/suite/innodb/r/innodb-page_compression_lzo.result
index 379abcc9968..66783c35d6c 100644
--- a/mysql-test/suite/innodb/r/innodb-page_compression_lzo.result
+++ b/mysql-test/suite/innodb/r/innodb-page_compression_lzo.result
@@ -147,7 +147,8 @@ count(*)
select count(*) from innodb_page_compressed9 where c1 < 500000;
count(*)
5000
-alter table innodb_normal page_compressed=1 page_compression_level=8;
+alter table innodb_normal page_compressed=1 page_compression_level=8,
+algorithm=instant;
show warnings;
Level Code Message
show create table innodb_normal;
@@ -156,6 +157,10 @@ innodb_normal CREATE TABLE `innodb_normal` (
`c1` int(11) DEFAULT NULL,
`b` char(20) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 `page_compressed`=1 `page_compression_level`=8
+alter table innodb_compressed row_format=default page_compressed=1 page_compression_level=8 key_block_size=0, algorithm=instant;
+ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: Changing table options requires the table to be rebuilt. Try ALGORITHM=INPLACE
+alter table innodb_compressed row_format=default page_compressed=1 page_compression_level=8 key_block_size=0, algorithm=nocopy;
+ERROR 0A000: ALGORITHM=NOCOPY is not supported. Reason: Changing table options requires the table to be rebuilt. Try ALGORITHM=INPLACE
alter table innodb_compressed row_format=default page_compressed=1 page_compression_level=8 key_block_size=0;
show warnings;
Level Code Message
@@ -174,6 +179,7 @@ update innodb_page_compressed6 set c1 = c1 + 1;
update innodb_page_compressed7 set c1 = c1 + 1;
update innodb_page_compressed8 set c1 = c1 + 1;
update innodb_page_compressed9 set c1 = c1 + 1;
+commit;
select count(*) from innodb_compressed;
count(*)
5000
diff --git a/mysql-test/suite/innodb/r/innodb-page_compression_tables.result b/mysql-test/suite/innodb/r/innodb-page_compression_tables.result
index 33b36428040..439f409ea59 100644
--- a/mysql-test/suite/innodb/r/innodb-page_compression_tables.result
+++ b/mysql-test/suite/innodb/r/innodb-page_compression_tables.result
@@ -88,8 +88,12 @@ select count(*) from innodb_dynamic where c1 < 1500000;
count(*)
5000
set global innodb_compression_algorithm = 0;
-alter table innodb_compact engine=innodb page_compressed=DEFAULT;
-alter table innodb_dynamic engine=innodb page_compressed=DEFAULT;
+alter table innodb_compact page_compressed=DEFAULT, algorithm=instant;
+ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: Changing table options requires the table to be rebuilt. Try ALGORITHM=INPLACE
+alter table innodb_compact page_compressed=DEFAULT;
+alter table innodb_dynamic page_compressed=DEFAULT, algorithm=instant;
+ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: Changing table options requires the table to be rebuilt. Try ALGORITHM=INPLACE
+alter table innodb_dynamic page_compressed=DEFAULT;
show create table innodb_compact;
Table Create Table
innodb_compact CREATE TABLE `innodb_compact` (
diff --git a/mysql-test/suite/innodb/r/innodb-page_compression_zip.result b/mysql-test/suite/innodb/r/innodb-page_compression_zip.result
index bb9ceb29e17..9dcf676cb3d 100644
--- a/mysql-test/suite/innodb/r/innodb-page_compression_zip.result
+++ b/mysql-test/suite/innodb/r/innodb-page_compression_zip.result
@@ -147,7 +147,8 @@ count(*)
select count(*) from innodb_page_compressed9 where c1 < 500000;
count(*)
5000
-alter table innodb_normal page_compressed=1 page_compression_level=8;
+alter table innodb_normal page_compressed=1 page_compression_level=8,
+algorithm=instant;
show warnings;
Level Code Message
show create table innodb_normal;
@@ -156,6 +157,10 @@ innodb_normal CREATE TABLE `innodb_normal` (
`c1` int(11) DEFAULT NULL,
`b` char(20) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 `page_compressed`=1 `page_compression_level`=8
+alter table innodb_compressed row_format=default page_compressed=1 page_compression_level=8 key_block_size=0, algorithm=instant;
+ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: Changing table options requires the table to be rebuilt. Try ALGORITHM=INPLACE
+alter table innodb_compressed row_format=default page_compressed=1 page_compression_level=8 key_block_size=0, algorithm=nocopy;
+ERROR 0A000: ALGORITHM=NOCOPY is not supported. Reason: Changing table options requires the table to be rebuilt. Try ALGORITHM=INPLACE
alter table innodb_compressed row_format=default page_compressed=1 page_compression_level=8 key_block_size=0;
show warnings;
Level Code Message
diff --git a/mysql-test/suite/innodb/t/alter_algorithm.test b/mysql-test/suite/innodb/t/alter_algorithm.test
index 5a720489281..23cddd46225 100644
--- a/mysql-test/suite/innodb/t/alter_algorithm.test
+++ b/mysql-test/suite/innodb/t/alter_algorithm.test
@@ -3,7 +3,7 @@ let $algorithm = `SELECT @@ALTER_ALGORITHM`;
let $error_code = 0;
if ($algorithm == "NOCOPY") {
- let $error_code = ER_ALTER_OPERATION_NOT_SUPPORTED;
+ let $error_code = ER_ALTER_OPERATION_NOT_SUPPORTED, ER_ALTER_OPERATION_NOT_SUPPORTED_REASON;
}
if ($algorithm == "INSTANT") {
diff --git a/mysql-test/suite/innodb/t/innodb-page_compression_bzip2.test b/mysql-test/suite/innodb/t/innodb-page_compression_bzip2.test
index 69a632d6010..2b4a9ea22a9 100644
--- a/mysql-test/suite/innodb/t/innodb-page_compression_bzip2.test
+++ b/mysql-test/suite/innodb/t/innodb-page_compression_bzip2.test
@@ -2,8 +2,6 @@
-- source include/have_innodb_bzip2.inc
-- source include/not_embedded.inc
-let $innodb_compression_algorithm_orig=`select @@innodb_compression_algorithm`;
-
# bzip2
set global innodb_compression_algorithm = 5;
@@ -79,9 +77,14 @@ select count(*) from innodb_page_compressed7 where c1 < 500000;
select count(*) from innodb_page_compressed8 where c1 < 500000;
select count(*) from innodb_page_compressed9 where c1 < 500000;
-alter table innodb_normal page_compressed=1 page_compression_level=8;
+alter table innodb_normal page_compressed=1 page_compression_level=8,
+algorithm=instant;
show warnings;
show create table innodb_normal;
+--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
+alter table innodb_compressed row_format=default page_compressed=1 page_compression_level=8 key_block_size=0, algorithm=instant;
+--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
+alter table innodb_compressed row_format=default page_compressed=1 page_compression_level=8 key_block_size=0, algorithm=nocopy;
alter table innodb_compressed row_format=default page_compressed=1 page_compression_level=8 key_block_size=0;
show warnings;
show create table innodb_compressed;
@@ -95,6 +98,7 @@ update innodb_page_compressed6 set c1 = c1 + 1;
update innodb_page_compressed7 set c1 = c1 + 1;
update innodb_page_compressed8 set c1 = c1 + 1;
update innodb_page_compressed9 set c1 = c1 + 1;
+commit;
select count(*) from innodb_compressed;
select count(*) from innodb_page_compressed1;
select count(*) from innodb_page_compressed1 where c1 < 500000;
@@ -236,8 +240,3 @@ drop table innodb_page_compressed6;
drop table innodb_page_compressed7;
drop table innodb_page_compressed8;
drop table innodb_page_compressed9;
-
-# reset system
---disable_query_log
-EVAL SET GLOBAL innodb_compression_algorithm = $innodb_compression_algorithm_orig;
---enable_query_log
diff --git a/mysql-test/suite/innodb/t/innodb-page_compression_lz4.test b/mysql-test/suite/innodb/t/innodb-page_compression_lz4.test
index 1b1df674e3c..49255d3a1ac 100644
--- a/mysql-test/suite/innodb/t/innodb-page_compression_lz4.test
+++ b/mysql-test/suite/innodb/t/innodb-page_compression_lz4.test
@@ -2,8 +2,6 @@
-- source include/have_innodb_lz4.inc
-- source include/not_embedded.inc
-let $innodb_compression_algorithm_orig=`SELECT @@innodb_compression_algorithm`;
-
# lz4
set global innodb_compression_algorithm = 2;
@@ -79,9 +77,14 @@ select count(*) from innodb_page_compressed7 where c1 < 500000;
select count(*) from innodb_page_compressed8 where c1 < 500000;
select count(*) from innodb_page_compressed9 where c1 < 500000;
-alter table innodb_normal page_compressed=1 page_compression_level=8;
+alter table innodb_normal page_compressed=1 page_compression_level=8,
+algorithm=instant;
show warnings;
show create table innodb_normal;
+--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
+alter table innodb_compressed row_format=default page_compressed=1 page_compression_level=8 key_block_size=0, algorithm=instant;
+--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
+alter table innodb_compressed row_format=default page_compressed=1 page_compression_level=8 key_block_size=0, algorithm=nocopy;
alter table innodb_compressed row_format=default page_compressed=1 page_compression_level=8 key_block_size=0;
show warnings;
show create table innodb_compressed;
@@ -237,8 +240,3 @@ drop table innodb_page_compressed6;
drop table innodb_page_compressed7;
drop table innodb_page_compressed8;
drop table innodb_page_compressed9;
-
-# reset system
---disable_query_log
-EVAL SET GLOBAL innodb_compression_algorithm = $innodb_compression_algorithm_orig;
---enable_query_log
diff --git a/mysql-test/suite/innodb/t/innodb-page_compression_lzma.test b/mysql-test/suite/innodb/t/innodb-page_compression_lzma.test
index 9cec3e7a947..e05c08f7515 100644
--- a/mysql-test/suite/innodb/t/innodb-page_compression_lzma.test
+++ b/mysql-test/suite/innodb/t/innodb-page_compression_lzma.test
@@ -2,8 +2,6 @@
-- source include/have_innodb_lzma.inc
-- source include/not_embedded.inc
-let $innodb_compression_algorithm_orig=`SELECT @@innodb_compression_algorithm`;
-
# lzma
set global innodb_compression_algorithm = 4;
@@ -79,9 +77,14 @@ select count(*) from innodb_page_compressed7 where c1 < 500000;
select count(*) from innodb_page_compressed8 where c1 < 500000;
select count(*) from innodb_page_compressed9 where c1 < 500000;
-alter table innodb_normal page_compressed=1 page_compression_level=8;
+alter table innodb_normal page_compressed=1 page_compression_level=8,
+algorithm=instant;
show warnings;
show create table innodb_normal;
+--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
+alter table innodb_compressed row_format=default page_compressed=1 page_compression_level=8 key_block_size=0, algorithm=instant;
+--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
+alter table innodb_compressed row_format=default page_compressed=1 page_compression_level=8 key_block_size=0, algorithm=nocopy;
alter table innodb_compressed row_format=default page_compressed=1 page_compression_level=8 key_block_size=0;
show warnings;
show create table innodb_compressed;
@@ -95,6 +98,7 @@ update innodb_page_compressed6 set c1 = c1 + 1;
update innodb_page_compressed7 set c1 = c1 + 1;
update innodb_page_compressed8 set c1 = c1 + 1;
update innodb_page_compressed9 set c1 = c1 + 1;
+commit;
select count(*) from innodb_compressed;
select count(*) from innodb_page_compressed1;
select count(*) from innodb_page_compressed1 where c1 < 500000;
@@ -236,8 +240,3 @@ drop table innodb_page_compressed6;
drop table innodb_page_compressed7;
drop table innodb_page_compressed8;
drop table innodb_page_compressed9;
-
-# reset system
---disable_query_log
-EVAL SET GLOBAL innodb_compression_algorithm = $innodb_compression_algorithm_orig;
---enable_query_log
diff --git a/mysql-test/suite/innodb/t/innodb-page_compression_lzo.test b/mysql-test/suite/innodb/t/innodb-page_compression_lzo.test
index 65c7e5dd3d9..af831bd2467 100644
--- a/mysql-test/suite/innodb/t/innodb-page_compression_lzo.test
+++ b/mysql-test/suite/innodb/t/innodb-page_compression_lzo.test
@@ -2,8 +2,6 @@
-- source include/have_innodb_lzo.inc
-- source include/not_embedded.inc
-let $innodb_compression_algorithm_orig=`select @@innodb_compression_algorithm`;
-
# lzo
set global innodb_compression_algorithm = 3;
@@ -79,9 +77,14 @@ select count(*) from innodb_page_compressed7 where c1 < 500000;
select count(*) from innodb_page_compressed8 where c1 < 500000;
select count(*) from innodb_page_compressed9 where c1 < 500000;
-alter table innodb_normal page_compressed=1 page_compression_level=8;
+alter table innodb_normal page_compressed=1 page_compression_level=8,
+algorithm=instant;
show warnings;
show create table innodb_normal;
+--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
+alter table innodb_compressed row_format=default page_compressed=1 page_compression_level=8 key_block_size=0, algorithm=instant;
+--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
+alter table innodb_compressed row_format=default page_compressed=1 page_compression_level=8 key_block_size=0, algorithm=nocopy;
alter table innodb_compressed row_format=default page_compressed=1 page_compression_level=8 key_block_size=0;
show warnings;
show create table innodb_compressed;
@@ -95,6 +98,7 @@ update innodb_page_compressed6 set c1 = c1 + 1;
update innodb_page_compressed7 set c1 = c1 + 1;
update innodb_page_compressed8 set c1 = c1 + 1;
update innodb_page_compressed9 set c1 = c1 + 1;
+commit;
select count(*) from innodb_compressed;
select count(*) from innodb_page_compressed1;
select count(*) from innodb_page_compressed1 where c1 < 500000;
@@ -189,8 +193,3 @@ drop table innodb_page_compressed6;
drop table innodb_page_compressed7;
drop table innodb_page_compressed8;
drop table innodb_page_compressed9;
-
-# reset system
---disable_query_log
-eval set global innodb_compression_algorithm = $innodb_compression_algorithm_orig;
---enable_query_log
diff --git a/mysql-test/suite/innodb/t/innodb-page_compression_tables.test b/mysql-test/suite/innodb/t/innodb-page_compression_tables.test
index bf83ebf5e82..a51a697931a 100644
--- a/mysql-test/suite/innodb/t/innodb-page_compression_tables.test
+++ b/mysql-test/suite/innodb/t/innodb-page_compression_tables.test
@@ -70,8 +70,12 @@ select count(*) from innodb_dynamic where c1 < 1500000;
# none
set global innodb_compression_algorithm = 0;
-alter table innodb_compact engine=innodb page_compressed=DEFAULT;
-alter table innodb_dynamic engine=innodb page_compressed=DEFAULT;
+--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
+alter table innodb_compact page_compressed=DEFAULT, algorithm=instant;
+alter table innodb_compact page_compressed=DEFAULT;
+--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
+alter table innodb_dynamic page_compressed=DEFAULT, algorithm=instant;
+alter table innodb_dynamic page_compressed=DEFAULT;
show create table innodb_compact;
show create table innodb_dynamic;
diff --git a/mysql-test/suite/innodb/t/innodb-page_compression_zip.test b/mysql-test/suite/innodb/t/innodb-page_compression_zip.test
index 0c843314eee..45e62722972 100644
--- a/mysql-test/suite/innodb/t/innodb-page_compression_zip.test
+++ b/mysql-test/suite/innodb/t/innodb-page_compression_zip.test
@@ -1,8 +1,6 @@
--source include/have_innodb.inc
--source include/not_embedded.inc
-let $innodb_compression_algorithm_orig=`SELECT @@innodb_compression_algorithm`;
-
# zlib
set global innodb_compression_algorithm = 1;
@@ -78,9 +76,14 @@ select count(*) from innodb_page_compressed7 where c1 < 500000;
select count(*) from innodb_page_compressed8 where c1 < 500000;
select count(*) from innodb_page_compressed9 where c1 < 500000;
-alter table innodb_normal page_compressed=1 page_compression_level=8;
+alter table innodb_normal page_compressed=1 page_compression_level=8,
+algorithm=instant;
show warnings;
show create table innodb_normal;
+--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
+alter table innodb_compressed row_format=default page_compressed=1 page_compression_level=8 key_block_size=0, algorithm=instant;
+--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
+alter table innodb_compressed row_format=default page_compressed=1 page_compression_level=8 key_block_size=0, algorithm=nocopy;
alter table innodb_compressed row_format=default page_compressed=1 page_compression_level=8 key_block_size=0;
show warnings;
show create table innodb_compressed;
@@ -187,8 +190,3 @@ drop table innodb_page_compressed6;
drop table innodb_page_compressed7;
drop table innodb_page_compressed8;
drop table innodb_page_compressed9;
-
-# reset system
---disable_query_log
-EVAL SET GLOBAL innodb_compression_algorithm = $innodb_compression_algorithm_orig;
---enable_query_log
diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt
index 77347472521..a60ddeb3017 100644
--- a/sql/share/errmsg-utf8.txt
+++ b/sql/share/errmsg-utf8.txt
@@ -7919,3 +7919,5 @@ ER_VERS_QUERY_IN_PARTITION
eng "SYSTEM_TIME partitions in table %`s does not support historical query"
ER_KEY_DOESNT_SUPPORT
eng "%s index %`s does not support this operation"
+ER_ALTER_OPERATION_TABLE_OPTIONS_NEED_REBUILD
+ eng "Changing table options requires the table to be rebuilt"
diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc
index 6a3ad4bd2ab..1b1b8e4ffa8 100644
--- a/storage/innobase/handler/handler0alter.cc
+++ b/storage/innobase/handler/handler0alter.cc
@@ -78,7 +78,7 @@ static const alter_table_operations INNOBASE_ALTER_REBUILD
= ALTER_ADD_PK_INDEX
| ALTER_DROP_PK_INDEX
| ALTER_OPTIONS
- /* ALTER_OPTIONS needs to check create_option_need_rebuild() */
+ /* ALTER_OPTIONS needs to check alter_options_need_rebuild() */
| ALTER_COLUMN_NULLABLE
| INNOBASE_DEFAULTS
| ALTER_STORED_COLUMN_ORDER
@@ -210,6 +210,9 @@ struct ha_innobase_inplace_ctx : public inplace_alter_handler_ctx
(3) Allow the conversion only in non-strict mode. */
const bool allow_not_null;
+ /** The page_compression_level attribute, or 0 */
+ const uint page_compression_level;
+
ha_innobase_inplace_ctx(row_prebuilt_t*& prebuilt_arg,
dict_index_t** drop_arg,
ulint num_to_drop_arg,
@@ -226,7 +229,9 @@ struct ha_innobase_inplace_ctx : public inplace_alter_handler_ctx
ulint add_autoinc_arg,
ulonglong autoinc_col_min_value_arg,
ulonglong autoinc_col_max_value_arg,
- bool allow_not_null_flag) :
+ bool allow_not_null_flag,
+ bool page_compressed,
+ uint page_compression_level_arg) :
inplace_alter_handler_ctx(),
prebuilt (prebuilt_arg),
add_index (0), add_key_numbers (0), num_to_add_index (0),
@@ -254,9 +259,15 @@ struct ha_innobase_inplace_ctx : public inplace_alter_handler_ctx
old_n_cols(prebuilt_arg->table->n_cols),
old_cols(prebuilt_arg->table->cols),
old_col_names(prebuilt_arg->table->col_names),
- allow_not_null(allow_not_null_flag)
+ allow_not_null(allow_not_null_flag),
+ page_compression_level(page_compressed
+ ? (page_compression_level_arg
+ ? page_compression_level_arg
+ : page_zip_level)
+ : 0)
{
ut_ad(old_n_cols >= DATA_N_SYS_COLS);
+ ut_ad(page_compression_level <= 9);
#ifdef UNIV_DEBUG
for (ulint i = 0; i < num_to_add_index; i++) {
ut_ad(!add_index[i]->to_be_dropped);
@@ -490,11 +501,11 @@ innobase_spatial_exist(
return(false);
}
-/** Determine if CHANGE_CREATE_OPTION requires rebuilding the table.
+/** Determine if ALTER_OPTIONS requires rebuilding the table.
@param[in] ha_alter_info the ALTER TABLE operation
@param[in] table metadata before ALTER TABLE
@return whether it is mandatory to rebuild the table */
-static bool create_option_need_rebuild(
+static bool alter_options_need_rebuild(
const Alter_inplace_info* ha_alter_info,
const TABLE* table)
{
@@ -513,12 +524,12 @@ static bool create_option_need_rebuild(
}
const ha_table_option_struct& alt_opt=
- *ha_alter_info->create_info->option_struct;
+ *ha_alter_info->create_info->option_struct;
const ha_table_option_struct& opt= *table->s->option_struct;
- if (alt_opt.page_compressed != opt.page_compressed
- || alt_opt.page_compression_level
- != opt.page_compression_level
+ /* Allow an instant change to enable page_compressed,
+ and any change of page_compression_level. */
+ if ((!alt_opt.page_compressed && opt.page_compressed)
|| alt_opt.encryption != opt.encryption
|| alt_opt.encryption_key_id != opt.encryption_key_id) {
return(true);
@@ -541,7 +552,7 @@ innobase_need_rebuild(
if ((ha_alter_info->handler_flags & ~(INNOBASE_INPLACE_IGNORE
| INNOBASE_ALTER_INSTANT))
== ALTER_OPTIONS) {
- return create_option_need_rebuild(ha_alter_info, table);
+ return alter_options_need_rebuild(ha_alter_info, table);
}
return !!(ha_alter_info->handler_flags & INNOBASE_ALTER_REBUILD);
@@ -689,7 +700,7 @@ instant_alter_column_possible(
}
return !(ha_alter_info->handler_flags & ALTER_OPTIONS)
- || !create_option_need_rebuild(ha_alter_info, table);
+ || !alter_options_need_rebuild(ha_alter_info, table);
}
/** Check whether the non-const default value for the field
@@ -849,9 +860,11 @@ ha_innobase::check_if_supported_inplace_alter(
{
DBUG_ENTER("check_if_supported_inplace_alter");
- if ((table->versioned(VERS_TIMESTAMP)
- || altered_table->versioned(VERS_TIMESTAMP))
- && innobase_need_rebuild(ha_alter_info, table)) {
+ const bool need_rebuild = innobase_need_rebuild(ha_alter_info, table);
+
+ if (need_rebuild
+ && (table->versioned(VERS_TIMESTAMP)
+ || altered_table->versioned(VERS_TIMESTAMP))) {
ha_alter_info->unsupported_reason =
"Not implemented for system-versioned tables";
DBUG_RETURN(HA_ALTER_INPLACE_NOT_SUPPORTED);
@@ -907,15 +920,15 @@ ha_innobase::check_if_supported_inplace_alter(
DBUG_RETURN(HA_ALTER_INPLACE_NOT_SUPPORTED);
}
-#if 0
- if (altered_table->file->ht != ht) {
- /* Non-native partitioning table engine. No longer supported,
- due to implementation of native InnoDB partitioning. */
- DBUG_RETURN(HA_ALTER_INPLACE_NOT_SUPPORTED);
- }
-#endif
-
- if (!(ha_alter_info->handler_flags & ~INNOBASE_INPLACE_IGNORE)) {
+ switch (ha_alter_info->handler_flags & ~INNOBASE_INPLACE_IGNORE) {
+ case ALTER_OPTIONS:
+ if (alter_options_need_rebuild(ha_alter_info, table)) {
+ ha_alter_info->unsupported_reason = my_get_err_msg(
+ ER_ALTER_OPERATION_TABLE_OPTIONS_NEED_REBUILD);
+ break;
+ }
+ /* fall through */
+ case 0:
DBUG_RETURN(HA_ALTER_INPLACE_INSTANT);
}
@@ -1294,9 +1307,8 @@ next_column:
if (!online) {
/* We already determined that only a non-locking
operation is possible. */
- } else if (((ha_alter_info->handler_flags
- & ALTER_ADD_PK_INDEX)
- || innobase_need_rebuild(ha_alter_info, table))
+ } else if ((need_rebuild || (ha_alter_info->handler_flags
+ & ALTER_ADD_PK_INDEX))
&& (innobase_fulltext_exist(altered_table)
|| innobase_spatial_exist(altered_table)
|| innobase_indexed_virtual_exist(altered_table))) {
@@ -1394,10 +1406,9 @@ cannot_create_many_fulltext_index:
}
// FIXME: implement Online DDL for system-versioned tables
- if ((table->versioned(VERS_TRX_ID)
- || altered_table->versioned(VERS_TRX_ID))
- && innobase_need_rebuild(ha_alter_info, table)) {
-
+ if (need_rebuild &&
+ (table->versioned(VERS_TRX_ID)
+ || altered_table->versioned(VERS_TRX_ID))) {
if (ha_alter_info->online) {
ha_alter_info->unsupported_reason =
"Not implemented for system-versioned tables";
@@ -1406,7 +1417,7 @@ cannot_create_many_fulltext_index:
online = false;
}
- if (fts_need_rebuild || innobase_need_rebuild(ha_alter_info, table)) {
+ if (need_rebuild || fts_need_rebuild) {
DBUG_RETURN(online
? HA_ALTER_INPLACE_COPY_NO_LOCK
: HA_ALTER_INPLACE_COPY_LOCK);
@@ -6827,11 +6838,14 @@ err_exit:
}
}
+ const ha_table_option_struct& alt_opt=
+ *ha_alter_info->create_info->option_struct;
+
if (!(ha_alter_info->handler_flags & INNOBASE_ALTER_DATA)
|| ((ha_alter_info->handler_flags & ~(INNOBASE_INPLACE_IGNORE
| INNOBASE_ALTER_INSTANT))
== ALTER_OPTIONS
- && !create_option_need_rebuild(ha_alter_info, table))) {
+ && !alter_options_need_rebuild(ha_alter_info, table))) {
if (heap) {
ha_alter_info->handler_ctx
@@ -6845,7 +6859,9 @@ err_exit:
heap, indexed_table,
col_names, ULINT_UNDEFINED, 0, 0,
(ha_alter_info->ignore
- || !thd_is_strict_mode(m_user_thd)));
+ || !thd_is_strict_mode(m_user_thd)),
+ alt_opt.page_compressed,
+ alt_opt.page_compression_level);
}
DBUG_ASSERT(m_prebuilt->trx->dict_operation_lock_mode == 0);
@@ -6974,7 +6990,8 @@ found_col:
add_autoinc_col_no,
ha_alter_info->create_info->auto_increment_value,
autoinc_col_max_value,
- ha_alter_info->ignore || !thd_is_strict_mode(m_user_thd));
+ ha_alter_info->ignore || !thd_is_strict_mode(m_user_thd),
+ alt_opt.page_compressed, alt_opt.page_compression_level);
DBUG_RETURN(prepare_inplace_alter_table_dict(
ha_alter_info, altered_table, table,
@@ -7113,7 +7130,7 @@ ok_exit:
if ((ha_alter_info->handler_flags & ~(INNOBASE_INPLACE_IGNORE
| INNOBASE_ALTER_INSTANT))
== ALTER_OPTIONS
- && !create_option_need_rebuild(ha_alter_info, table)) {
+ && !alter_options_need_rebuild(ha_alter_info, table)) {
goto ok_exit;
}
@@ -8824,6 +8841,58 @@ get_col_list_to_be_dropped(
}
}
+/** Change PAGE_COMPRESSED to ON or change the PAGE_COMPRESSION_LEVEL.
+@param[in] level PAGE_COMPRESSION_LEVEL
+@param[in] table table before the change
+@param[in,out] trx data dictionary transaction
+@param[in] table_name table name in MariaDB
+@return whether the operation succeeded */
+MY_ATTRIBUTE((nonnull, warn_unused_result))
+static
+bool
+innobase_page_compression_try(
+ uint level,
+ const dict_table_t* table,
+ trx_t* trx,
+ const char* table_name)
+{
+ DBUG_ENTER("innobase_page_compression_try");
+ DBUG_ASSERT(level >= 1);
+ DBUG_ASSERT(level <= 9);
+
+ unsigned flags = table->flags
+ & ~(0xFU << DICT_TF_POS_PAGE_COMPRESSION_LEVEL);
+ flags |= 1U << DICT_TF_POS_PAGE_COMPRESSION
+ | level << DICT_TF_POS_PAGE_COMPRESSION_LEVEL;
+
+ if (table->flags == flags) {
+ DBUG_RETURN(false);
+ }
+
+ pars_info_t* info = pars_info_create();
+
+ pars_info_add_ull_literal(info, "id", table->id);
+ pars_info_add_int4_literal(info, "type",
+ dict_tf_to_sys_tables_type(flags));
+
+ dberr_t error = que_eval_sql(info,
+ "PROCEDURE CHANGE_COMPRESSION () IS\n"
+ "BEGIN\n"
+ "UPDATE SYS_TABLES SET TYPE=:type\n"
+ "WHERE ID=:id;\n"
+ "END;\n",
+ false, trx);
+
+ if (error != DB_SUCCESS) {
+ my_error_innodb(error, table_name, 0);
+ trx->error_state = DB_SUCCESS;
+ trx->op_info = "";
+ DBUG_RETURN(true);
+ }
+
+ DBUG_RETURN(false);
+}
+
/** Commit the changes made during prepare_inplace_alter_table()
and inplace_alter_table() inside the data dictionary tables,
when not rebuilding the table.
@@ -8857,6 +8926,13 @@ commit_try_norebuild(
|| ctx->num_to_drop_vcol
== ha_alter_info->alter_info->drop_list.elements);
+ if (ctx->page_compression_level
+ && innobase_page_compression_try(ctx->page_compression_level,
+ ctx->new_table, trx,
+ table_name)) {
+ DBUG_RETURN(true);
+ }
+
for (ulint i = 0; i < ctx->num_to_add_index; i++) {
dict_index_t* index = ctx->add_index[i];
DBUG_ASSERT(dict_index_get_online_status(index)
@@ -9002,6 +9078,57 @@ commit_cache_norebuild(
{
DBUG_ENTER("commit_cache_norebuild");
DBUG_ASSERT(!ctx->need_rebuild());
+ DBUG_ASSERT(ctx->new_table->space != fil_system.temp_space);
+ DBUG_ASSERT(!ctx->new_table->is_temporary());
+
+ if (ctx->page_compression_level) {
+ DBUG_ASSERT(ctx->new_table->space != fil_system.sys_space);
+ ctx->new_table->flags &=
+ ~(0xFU << DICT_TF_POS_PAGE_COMPRESSION_LEVEL);
+ ctx->new_table->flags |= 1 << DICT_TF_POS_PAGE_COMPRESSION
+ | (ctx->page_compression_level
+ << DICT_TF_POS_PAGE_COMPRESSION_LEVEL);
+
+ if (fil_space_t* space = ctx->new_table->space) {
+ bool update = !(space->flags
+ & FSP_FLAGS_MASK_PAGE_COMPRESSION);
+ mutex_enter(&fil_system.mutex);
+ space->flags = (~FSP_FLAGS_MASK_MEM_COMPRESSION_LEVEL
+ & (space->flags
+ | FSP_FLAGS_MASK_PAGE_COMPRESSION))
+ | ctx->page_compression_level
+ << FSP_FLAGS_MEM_COMPRESSION_LEVEL;
+ mutex_exit(&fil_system.mutex);
+
+ if (update) {
+ /* Maybe we should introduce an undo
+ log record for updating tablespace
+ flags, and perform the update already
+ in innobase_page_compression_try().
+
+ If the server is killed before the
+ following mini-transaction commit
+ becomes durable, fsp_flags_try_adjust()
+ will perform the equivalent adjustment
+ and warn "adjusting FSP_SPACE_FLAGS". */
+ mtr_t mtr;
+ mtr.start();
+ if (buf_block_t* b = buf_page_get(
+ page_id_t(space->id, 0),
+ page_size_t(space->flags),
+ RW_X_LATCH, &mtr)) {
+ mtr.set_named_space(space);
+ mlog_write_ulint(
+ FSP_HEADER_OFFSET
+ + FSP_SPACE_FLAGS + b->frame,
+ space->flags
+ & ~FSP_FLAGS_MEM_MASK,
+ MLOG_4BYTES, &mtr);
+ }
+ mtr.commit();
+ }
+ }
+ }
col_set drop_list;
col_set v_drop_list;