Commit ac24289e authored by Marko Mäkelä's avatar Marko Mäkelä

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.
parent c5a9a632
--- alter_algorithm.result 2018-05-06 23:42:08.022302601 +0530 --- alter_algorithm.result
+++ alter_algorithm.reject 2018-05-06 23:45:23.813346814 +0530 +++ alter_algorithm.reject
@@ -7,35 +7,44 @@ @@ -7,44 +7,44 @@
INSERT INTO t1(f1, f2, f3) VALUES(1, 1, 1); INSERT INTO t1(f1, f2, f3) VALUES(1, 1, 1);
SELECT @@alter_algorithm; SELECT @@alter_algorithm;
@@alter_algorithm @@alter_algorithm
-NOCOPY -COPY
+INPLACE +INPLACE
# All the following cases needs table rebuild # All the following cases needs table rebuild
# Add and Drop primary key # Add and Drop primary key
ALTER TABLE t1 ADD COLUMN col1 INT NOT NULL,DROP PRIMARY KEY,ADD PRIMARY KEY(col1); 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 +affected rows: 0
+info: Records: 0 Duplicates: 0 Warnings: 0 +info: Records: 0 Duplicates: 0 Warnings: 0
# Make existing column NULLABLE # Make existing column NULLABLE
ALTER TABLE t1 MODIFY f2 INT; 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 +affected rows: 0
+info: Records: 0 Duplicates: 0 Warnings: 0 +info: Records: 0 Duplicates: 0 Warnings: 0
# Make existing column NON-NULLABLE # Make existing column NON-NULLABLE
ALTER TABLE t1 MODIFY f3 INT NOT NULL; 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 +affected rows: 0
+info: Records: 0 Duplicates: 0 Warnings: 0 +info: Records: 0 Duplicates: 0 Warnings: 0
# Drop Stored Column # Drop Stored Column
ALTER TABLE t1 DROP COLUMN f5; 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 +affected rows: 0
+info: Records: 0 Duplicates: 0 Warnings: 0 +info: Records: 0 Duplicates: 0 Warnings: 0
# Add base non-generated column as a last column in the compressed table # Add base non-generated column as a last column in the compressed table
ALTER TABLE t1 ADD COLUMN f6 INT NOT NULL; 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 +affected rows: 0
+info: Records: 0 Duplicates: 0 Warnings: 0 +info: Records: 0 Duplicates: 0 Warnings: 0
# Add base non-generated column but not in the last position # Add base non-generated column but not in the last position
ALTER TABLE t1 ADD COLUMN f7 INT NOT NULL after f3; 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 +affected rows: 0
+info: Records: 0 Duplicates: 0 Warnings: 0 +info: Records: 0 Duplicates: 0 Warnings: 0
# Force the table to rebuild # Force the table to rebuild
ALTER TABLE t1 FORCE; 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 +affected rows: 0
+info: Records: 0 Duplicates: 0 Warnings: 0 +info: Records: 0 Duplicates: 0 Warnings: 0
# Row format changes # Row format changes
ALTER TABLE t1 ROW_FORMAT=COMPRESSED; 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 +affected rows: 0
+info: Records: 0 Duplicates: 0 Warnings: 0 +info: Records: 0 Duplicates: 0 Warnings: 0
# Engine table # Engine table
ALTER TABLE t1 ENGINE=INNODB; 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 +affected rows: 0
+info: Records: 0 Duplicates: 0 Warnings: 0 +info: Records: 0 Duplicates: 0 Warnings: 0
DROP TABLE t1; DROP TABLE t1;
affected rows: 0 affected rows: 0
CREATE TABLE t1(f1 INT PRIMARY KEY, f2 INT NOT NULL, 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); INSERT INTO t1(f1, f2, f4, f5) VALUES(1, 2, 3, 4);
SELECT @@alter_algorithm; SELECT @@alter_algorithm;
@@alter_algorithm @@alter_algorithm
-NOCOPY -COPY
+INPLACE +INPLACE
ALTER TABLE t1 ADD INDEX idx1(f4); 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 affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0
--- alter_algorithm.result 2018-05-06 23:42:08.022302601 +0530 --- alter_algorithm.result
+++ alter_algorithm.reject 2018-05-06 23:46:08.482772800 +0530 +++ alter_algorithm.reject
@@ -7,35 +7,35 @@ @@ -7,44 +7,35 @@
INSERT INTO t1(f1, f2, f3) VALUES(1, 1, 1); INSERT INTO t1(f1, f2, f3) VALUES(1, 1, 1);
SELECT @@alter_algorithm; SELECT @@alter_algorithm;
@@alter_algorithm @@alter_algorithm
-NOCOPY -COPY
+INSTANT +INSTANT
# All the following cases needs table rebuild # All the following cases needs table rebuild
# Add and Drop primary key # Add and Drop primary key
ALTER TABLE t1 ADD COLUMN col1 INT NOT NULL,DROP PRIMARY KEY,ADD PRIMARY KEY(col1); 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 +Got one of the listed errors
# Make existing column NULLABLE # Make existing column NULLABLE
ALTER TABLE t1 MODIFY f2 INT; 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 +Got one of the listed errors
# Make existing column NON-NULLABLE # Make existing column NON-NULLABLE
ALTER TABLE t1 MODIFY f3 INT NOT NULL; 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 +Got one of the listed errors
# Drop Stored Column # Drop Stored Column
ALTER TABLE t1 DROP COLUMN f5; 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 +Got one of the listed errors
# Add base non-generated column as a last column in the compressed table # Add base non-generated column as a last column in the compressed table
ALTER TABLE t1 ADD COLUMN f6 INT NOT NULL; 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 +Got one of the listed errors
# Add base non-generated column but not in the last position # Add base non-generated column but not in the last position
ALTER TABLE t1 ADD COLUMN f7 INT NOT NULL after f3; 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 +Got one of the listed errors
# Force the table to rebuild # Force the table to rebuild
ALTER TABLE t1 FORCE; 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 +Got one of the listed errors
# Row format changes # Row format changes
ALTER TABLE t1 ROW_FORMAT=COMPRESSED; 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 +Got one of the listed errors
# Engine table # Engine table
ALTER TABLE t1 ENGINE=INNODB; 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 +Got one of the listed errors
DROP TABLE t1; DROP TABLE t1;
affected rows: 0 affected rows: 0
CREATE TABLE t1(f1 INT PRIMARY KEY, f2 INT NOT NULL, 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); INSERT INTO t1(f1, f2, f4, f5) VALUES(1, 2, 3, 4);
SELECT @@alter_algorithm; SELECT @@alter_algorithm;
@@alter_algorithm @@alter_algorithm
-NOCOPY -COPY
+INSTANT +INSTANT
ALTER TABLE t1 ADD INDEX idx1(f4); ALTER TABLE t1 ADD INDEX idx1(f4);
-affected rows: 0 -affected rows: 1
-info: Records: 0 Duplicates: 0 Warnings: 0 -info: Records: 1 Duplicates: 0 Warnings: 0
+ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: ADD INDEX. Try ALGORITHM=NOCOPY +ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: ADD INDEX. Try ALGORITHM=NOCOPY
ALTER TABLE t1 DROP INDEX idx; ALTER TABLE t1 DROP INDEX idx;
-affected rows: 0 -affected rows: 1
-info: Records: 0 Duplicates: 0 Warnings: 0 -info: Records: 1 Duplicates: 0 Warnings: 0
+ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: DROP INDEX. Try ALGORITHM=NOCOPY +ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: DROP INDEX. Try ALGORITHM=NOCOPY
ALTER TABLE t1 ADD UNIQUE INDEX u1(f2); ALTER TABLE t1 ADD UNIQUE INDEX u1(f2);
-affected rows: 0 -affected rows: 1
-info: Records: 0 Duplicates: 0 Warnings: 0 -info: Records: 1 Duplicates: 0 Warnings: 0
+ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: ADD INDEX. Try ALGORITHM=NOCOPY +ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: ADD INDEX. Try ALGORITHM=NOCOPY
ALTER TABLE t1 DROP INDEX f4; ALTER TABLE t1 DROP INDEX f4;
-affected rows: 0 -affected rows: 1
-info: Records: 0 Duplicates: 0 Warnings: 0 -info: Records: 1 Duplicates: 0 Warnings: 0
+ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: DROP INDEX. Try ALGORITHM=NOCOPY +ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: DROP INDEX. Try ALGORITHM=NOCOPY
SET foreign_key_checks = 0; SET foreign_key_checks = 0;
affected rows: 0 affected rows: 0
ALTER TABLE t1 ADD FOREIGN KEY(f5) REFERENCES t2(f1); ALTER TABLE t1 ADD FOREIGN KEY(f5) REFERENCES t2(f1);
-affected rows: 0 -affected rows: 1
-info: Records: 0 Duplicates: 0 Warnings: 0 -info: Records: 1 Duplicates: 0 Warnings: 0
+ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: ADD INDEX. Try ALGORITHM=NOCOPY +ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: ADD INDEX. Try ALGORITHM=NOCOPY
DROP TABLE t2, t1; DROP TABLE t2, t1;
affected rows: 0 affected rows: 0
--- alter_algorithm.result 2018-05-06 23:42:08.022302601 +0530 --- alter_algorithm.result
+++ alter_algorithm.reject 2018-05-06 23:42:16.382634082 +0530 +++ alter_algorithm.reject
@@ -7,35 +7,44 @@ @@ -7,44 +7,35 @@
INSERT INTO t1(f1, f2, f3) VALUES(1, 1, 1); INSERT INTO t1(f1, f2, f3) VALUES(1, 1, 1);
SELECT @@alter_algorithm; SELECT @@alter_algorithm;
@@alter_algorithm @@alter_algorithm
-NOCOPY -COPY
+COPY +NOCOPY
# All the following cases needs table rebuild # All the following cases needs table rebuild
# Add and Drop primary key # Add and Drop primary key
ALTER TABLE t1 ADD COLUMN col1 INT NOT NULL,DROP PRIMARY KEY,ADD PRIMARY KEY(col1); 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
+affected rows: 1 -info: Records: 1 Duplicates: 0 Warnings: 0
+info: Records: 1 Duplicates: 0 Warnings: 0 +Got one of the listed errors
# Make existing column NULLABLE # Make existing column NULLABLE
ALTER TABLE t1 MODIFY f2 INT; ALTER TABLE t1 MODIFY f2 INT;
-ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE -affected rows: 1
+affected rows: 1 -info: Records: 1 Duplicates: 0 Warnings: 0
+info: Records: 1 Duplicates: 0 Warnings: 0 +Got one of the listed errors
# Make existing column NON-NULLABLE # Make existing column NON-NULLABLE
ALTER TABLE t1 MODIFY f3 INT NOT NULL; ALTER TABLE t1 MODIFY f3 INT NOT NULL;
-ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE -affected rows: 1
+affected rows: 1 -info: Records: 1 Duplicates: 0 Warnings: 0
+info: Records: 1 Duplicates: 0 Warnings: 0 +Got one of the listed errors
# Drop Stored Column # Drop Stored Column
ALTER TABLE t1 DROP COLUMN f5; ALTER TABLE t1 DROP COLUMN f5;
-ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE -affected rows: 1
+affected rows: 1 -info: Records: 1 Duplicates: 0 Warnings: 0
+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 # Add base non-generated column as a last column in the compressed table
ALTER TABLE t1 ADD COLUMN f6 INT NOT NULL; 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
+affected rows: 1 -info: Records: 1 Duplicates: 0 Warnings: 0
+info: Records: 1 Duplicates: 0 Warnings: 0 +Got one of the listed errors
# Add base non-generated column but not in the last position # Add base non-generated column but not in the last position
ALTER TABLE t1 ADD COLUMN f7 INT NOT NULL after f3; 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
+affected rows: 1 -info: Records: 1 Duplicates: 0 Warnings: 0
+info: Records: 1 Duplicates: 0 Warnings: 0 +Got one of the listed errors
# Force the table to rebuild # Force the table to rebuild
ALTER TABLE t1 FORCE; ALTER TABLE t1 FORCE;
-ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE -affected rows: 1
+affected rows: 1 -info: Records: 1 Duplicates: 0 Warnings: 0
+info: Records: 1 Duplicates: 0 Warnings: 0 +Got one of the listed errors
# Row format changes # Row format changes
ALTER TABLE t1 ROW_FORMAT=COMPRESSED; ALTER TABLE t1 ROW_FORMAT=COMPRESSED;
-ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE -affected rows: 1
+affected rows: 1 -info: Records: 1 Duplicates: 0 Warnings: 0
+info: Records: 1 Duplicates: 0 Warnings: 0 +Got one of the listed errors
# Engine table # Engine table
ALTER TABLE t1 ENGINE=INNODB; ALTER TABLE t1 ENGINE=INNODB;
-ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE -affected rows: 1
+affected rows: 1 -info: Records: 1 Duplicates: 0 Warnings: 0
+info: Records: 1 Duplicates: 0 Warnings: 0 +Got one of the listed errors
DROP TABLE t1; DROP TABLE t1;
affected rows: 0 affected rows: 0
CREATE TABLE t1(f1 INT PRIMARY KEY, f2 INT NOT NULL, CREATE TABLE t1(f1 INT PRIMARY KEY, f2 INT NOT NULL,
@@ -49,23 +58,23 @@ @@ -58,23 +49,23 @@
INSERT INTO t1(f1, f2, f4, f5) VALUES(1, 2, 3, 4); INSERT INTO t1(f1, f2, f4, f5) VALUES(1, 2, 3, 4);
SELECT @@alter_algorithm; SELECT @@alter_algorithm;
@@alter_algorithm @@alter_algorithm
-NOCOPY -COPY
+COPY +NOCOPY
ALTER TABLE t1 ADD INDEX idx1(f4); ALTER TABLE t1 ADD INDEX idx1(f4);
-affected rows: 0 -affected rows: 1
-info: Records: 0 Duplicates: 0 Warnings: 0 -info: Records: 1 Duplicates: 0 Warnings: 0
+affected rows: 1 +affected rows: 0
+info: Records: 1 Duplicates: 0 Warnings: 0 +info: Records: 0 Duplicates: 0 Warnings: 0
ALTER TABLE t1 DROP INDEX idx; ALTER TABLE t1 DROP INDEX idx;
-affected rows: 0 -affected rows: 1
-info: Records: 0 Duplicates: 0 Warnings: 0 -info: Records: 1 Duplicates: 0 Warnings: 0
+affected rows: 1 +affected rows: 0
+info: Records: 1 Duplicates: 0 Warnings: 0 +info: Records: 0 Duplicates: 0 Warnings: 0
ALTER TABLE t1 ADD UNIQUE INDEX u1(f2); ALTER TABLE t1 ADD UNIQUE INDEX u1(f2);
-affected rows: 0 -affected rows: 1
-info: Records: 0 Duplicates: 0 Warnings: 0 -info: Records: 1 Duplicates: 0 Warnings: 0
+affected rows: 1 +affected rows: 0
+info: Records: 1 Duplicates: 0 Warnings: 0 +info: Records: 0 Duplicates: 0 Warnings: 0
ALTER TABLE t1 DROP INDEX f4; ALTER TABLE t1 DROP INDEX f4;
-affected rows: 0 -affected rows: 1
-info: Records: 0 Duplicates: 0 Warnings: 0 -info: Records: 1 Duplicates: 0 Warnings: 0
+affected rows: 1 +affected rows: 0
+info: Records: 1 Duplicates: 0 Warnings: 0 +info: Records: 0 Duplicates: 0 Warnings: 0
SET foreign_key_checks = 0; SET foreign_key_checks = 0;
affected rows: 0 affected rows: 0
ALTER TABLE t1 ADD FOREIGN KEY(f5) REFERENCES t2(f1); ALTER TABLE t1 ADD FOREIGN KEY(f5) REFERENCES t2(f1);
-affected rows: 0 -affected rows: 1
-info: Records: 0 Duplicates: 0 Warnings: 0 -info: Records: 1 Duplicates: 0 Warnings: 0
+affected rows: 1 +affected rows: 0
+info: Records: 1 Duplicates: 0 Warnings: 0 +info: Records: 0 Duplicates: 0 Warnings: 0
DROP TABLE t2, t1; DROP TABLE t2, t1;
affected rows: 0 affected rows: 0
...@@ -7,35 +7,44 @@ PRIMARY KEY(f1))ROW_FORMAT=COMPRESSED, ENGINE=INNODB; ...@@ -7,35 +7,44 @@ PRIMARY KEY(f1))ROW_FORMAT=COMPRESSED, ENGINE=INNODB;
INSERT INTO t1(f1, f2, f3) VALUES(1, 1, 1); INSERT INTO t1(f1, f2, f3) VALUES(1, 1, 1);
SELECT @@alter_algorithm; SELECT @@alter_algorithm;
@@alter_algorithm @@alter_algorithm
NOCOPY COPY
# All the following cases needs table rebuild # All the following cases needs table rebuild
# Add and Drop primary key # Add and Drop primary key
ALTER TABLE t1 ADD COLUMN col1 INT NOT NULL,DROP PRIMARY KEY,ADD PRIMARY KEY(col1); 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 # Make existing column NULLABLE
ALTER TABLE t1 MODIFY f2 INT; 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 # Make existing column NON-NULLABLE
ALTER TABLE t1 MODIFY f3 INT NOT NULL; 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 # Drop Stored Column
ALTER TABLE t1 DROP COLUMN f5; 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 # Add base non-generated column as a last column in the compressed table
ALTER TABLE t1 ADD COLUMN f6 INT NOT NULL; 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 # Add base non-generated column but not in the last position
ALTER TABLE t1 ADD COLUMN f7 INT NOT NULL after f3; 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 # Force the table to rebuild
ALTER TABLE t1 FORCE; 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 # Row format changes
ALTER TABLE t1 ROW_FORMAT=COMPRESSED; 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 # Engine table
ALTER TABLE t1 ENGINE=INNODB; 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; DROP TABLE t1;
affected rows: 0 affected rows: 0
CREATE TABLE t1(f1 INT PRIMARY KEY, f2 INT NOT NULL, CREATE TABLE t1(f1 INT PRIMARY KEY, f2 INT NOT NULL,
...@@ -49,23 +58,23 @@ FOREIGN KEY `fidx` (f1) REFERENCES t1(f1))ENGINE=INNODB; ...@@ -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); INSERT INTO t1(f1, f2, f4, f5) VALUES(1, 2, 3, 4);
SELECT @@alter_algorithm; SELECT @@alter_algorithm;
@@alter_algorithm @@alter_algorithm
NOCOPY COPY
ALTER TABLE t1 ADD INDEX idx1(f4); ALTER TABLE t1 ADD INDEX idx1(f4);
affected rows: 0 affected rows: 1
info: Records: 0 Duplicates: 0 Warnings: 0 info: Records: 1 Duplicates: 0 Warnings: 0
ALTER TABLE t1 DROP INDEX idx; ALTER TABLE t1 DROP INDEX idx;
affected rows: 0 affected rows: 1
info: Records: 0 Duplicates: 0 Warnings: 0 info: Records: 1 Duplicates: 0 Warnings: 0
ALTER TABLE t1 ADD UNIQUE INDEX u1(f2); ALTER TABLE t1 ADD UNIQUE INDEX u1(f2);
affected rows: 0 affected rows: 1
info: Records: 0 Duplicates: 0 Warnings: 0 info: Records: 1 Duplicates: 0 Warnings: 0
ALTER TABLE t1 DROP INDEX f4; ALTER TABLE t1 DROP INDEX f4;
affected rows: 0 affected rows: 1
info: Records: 0 Duplicates: 0 Warnings: 0 info: Records: 1 Duplicates: 0 Warnings: 0
SET foreign_key_checks = 0; SET foreign_key_checks = 0;
affected rows: 0 affected rows: 0
ALTER TABLE t1 ADD FOREIGN KEY(f5) REFERENCES t2(f1); ALTER TABLE t1 ADD FOREIGN KEY(f5) REFERENCES t2(f1);
affected rows: 0 affected rows: 1
info: Records: 0 Duplicates: 0 Warnings: 0 info: Records: 1 Duplicates: 0 Warnings: 0
DROP TABLE t2, t1; DROP TABLE t2, t1;
affected rows: 0 affected rows: 0
...@@ -147,7 +147,8 @@ count(*) ...@@ -147,7 +147,8 @@ count(*)
select count(*) from innodb_page_compressed9 where c1 < 500000; select count(*) from innodb_page_compressed9 where c1 < 500000;
count(*) count(*)
5000 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; show warnings;
Level Code Message Level Code Message
show create table innodb_normal; show create table innodb_normal;
...@@ -156,6 +157,10 @@ innodb_normal CREATE TABLE `innodb_normal` ( ...@@ -156,6 +157,10 @@ innodb_normal CREATE TABLE `innodb_normal` (
`c1` int(11) DEFAULT NULL, `c1` int(11) DEFAULT NULL,
`b` char(20) DEFAULT NULL `b` char(20) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 `page_compressed`=1 `page_compression_level`=8 ) 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; alter table innodb_compressed row_format=default page_compressed=1 page_compression_level=8 key_block_size=0;
show warnings; show warnings;
Level Code Message Level Code Message
...@@ -174,6 +179,7 @@ update innodb_page_compressed6 set c1 = c1 + 1; ...@@ -174,6 +179,7 @@ update innodb_page_compressed6 set c1 = c1 + 1;
update innodb_page_compressed7 set c1 = c1 + 1; update innodb_page_compressed7 set c1 = c1 + 1;
update innodb_page_compressed8 set c1 = c1 + 1; update innodb_page_compressed8 set c1 = c1 + 1;
update innodb_page_compressed9 set c1 = c1 + 1; update innodb_page_compressed9 set c1 = c1 + 1;
commit;
select count(*) from innodb_compressed; select count(*) from innodb_compressed;
count(*) count(*)
5000 5000
......
...@@ -147,7 +147,8 @@ count(*) ...@@ -147,7 +147,8 @@ count(*)
select count(*) from innodb_page_compressed9 where c1 < 500000; select count(*) from innodb_page_compressed9 where c1 < 500000;
count(*) count(*)
5000 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; show warnings;
Level Code Message Level Code Message
show create table innodb_normal; show create table innodb_normal;
...@@ -156,6 +157,10 @@ innodb_normal CREATE TABLE `innodb_normal` ( ...@@ -156,6 +157,10 @@ innodb_normal CREATE TABLE `innodb_normal` (
`c1` int(11) DEFAULT NULL, `c1` int(11) DEFAULT NULL,
`b` char(20) DEFAULT NULL `b` char(20) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 `page_compressed`=1 `page_compression_level`=8 ) 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; alter table innodb_compressed row_format=default page_compressed=1 page_compression_level=8 key_block_size=0;
show warnings; show warnings;
Level Code Message Level Code Message
......
...@@ -147,7 +147,8 @@ count(*) ...@@ -147,7 +147,8 @@ count(*)
select count(*) from innodb_page_compressed9 where c1 < 500000; select count(*) from innodb_page_compressed9 where c1 < 500000;
count(*) count(*)
5000 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; show warnings;
Level Code Message Level Code Message
show create table innodb_normal; show create table innodb_normal;
...@@ -156,6 +157,10 @@ innodb_normal CREATE TABLE `innodb_normal` ( ...@@ -156,6 +157,10 @@ innodb_normal CREATE TABLE `innodb_normal` (
`c1` int(11) DEFAULT NULL, `c1` int(11) DEFAULT NULL,
`b` char(20) DEFAULT NULL `b` char(20) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 `page_compressed`=1 `page_compression_level`=8 ) 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; alter table innodb_compressed row_format=default page_compressed=1 page_compression_level=8 key_block_size=0;
show warnings; show warnings;
Level Code Message Level Code Message
...@@ -174,6 +179,7 @@ update innodb_page_compressed6 set c1 = c1 + 1; ...@@ -174,6 +179,7 @@ update innodb_page_compressed6 set c1 = c1 + 1;
update innodb_page_compressed7 set c1 = c1 + 1; update innodb_page_compressed7 set c1 = c1 + 1;
update innodb_page_compressed8 set c1 = c1 + 1; update innodb_page_compressed8 set c1 = c1 + 1;
update innodb_page_compressed9 set c1 = c1 + 1; update innodb_page_compressed9 set c1 = c1 + 1;
commit;
select count(*) from innodb_compressed; select count(*) from innodb_compressed;
count(*) count(*)
5000 5000
......
...@@ -147,7 +147,8 @@ count(*) ...@@ -147,7 +147,8 @@ count(*)
select count(*) from innodb_page_compressed9 where c1 < 500000; select count(*) from innodb_page_compressed9 where c1 < 500000;
count(*) count(*)
5000 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; show warnings;
Level Code Message Level Code Message
show create table innodb_normal; show create table innodb_normal;
...@@ -156,6 +157,10 @@ innodb_normal CREATE TABLE `innodb_normal` ( ...@@ -156,6 +157,10 @@ innodb_normal CREATE TABLE `innodb_normal` (
`c1` int(11) DEFAULT NULL, `c1` int(11) DEFAULT NULL,
`b` char(20) DEFAULT NULL `b` char(20) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 `page_compressed`=1 `page_compression_level`=8 ) 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; alter table innodb_compressed row_format=default page_compressed=1 page_compression_level=8 key_block_size=0;
show warnings; show warnings;
Level Code Message Level Code Message
...@@ -174,6 +179,7 @@ update innodb_page_compressed6 set c1 = c1 + 1; ...@@ -174,6 +179,7 @@ update innodb_page_compressed6 set c1 = c1 + 1;
update innodb_page_compressed7 set c1 = c1 + 1; update innodb_page_compressed7 set c1 = c1 + 1;
update innodb_page_compressed8 set c1 = c1 + 1; update innodb_page_compressed8 set c1 = c1 + 1;
update innodb_page_compressed9 set c1 = c1 + 1; update innodb_page_compressed9 set c1 = c1 + 1;
commit;
select count(*) from innodb_compressed; select count(*) from innodb_compressed;
count(*) count(*)
5000 5000
......
...@@ -88,8 +88,12 @@ select count(*) from innodb_dynamic where c1 < 1500000; ...@@ -88,8 +88,12 @@ select count(*) from innodb_dynamic where c1 < 1500000;
count(*) count(*)
5000 5000
set global innodb_compression_algorithm = 0; set global innodb_compression_algorithm = 0;
alter table innodb_compact engine=innodb page_compressed=DEFAULT; alter table innodb_compact page_compressed=DEFAULT, algorithm=instant;
alter table innodb_dynamic engine=innodb page_compressed=DEFAULT; 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; show create table innodb_compact;
Table Create Table Table Create Table
innodb_compact CREATE TABLE `innodb_compact` ( innodb_compact CREATE TABLE `innodb_compact` (
......
...@@ -147,7 +147,8 @@ count(*) ...@@ -147,7 +147,8 @@ count(*)
select count(*) from innodb_page_compressed9 where c1 < 500000; select count(*) from innodb_page_compressed9 where c1 < 500000;
count(*) count(*)
5000 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; show warnings;
Level Code Message Level Code Message
show create table innodb_normal; show create table innodb_normal;
...@@ -156,6 +157,10 @@ innodb_normal CREATE TABLE `innodb_normal` ( ...@@ -156,6 +157,10 @@ innodb_normal CREATE TABLE `innodb_normal` (
`c1` int(11) DEFAULT NULL, `c1` int(11) DEFAULT NULL,
`b` char(20) DEFAULT NULL `b` char(20) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 `page_compressed`=1 `page_compression_level`=8 ) 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; alter table innodb_compressed row_format=default page_compressed=1 page_compression_level=8 key_block_size=0;
show warnings; show warnings;
Level Code Message Level Code Message
......
...@@ -3,7 +3,7 @@ let $algorithm = `SELECT @@ALTER_ALGORITHM`; ...@@ -3,7 +3,7 @@ let $algorithm = `SELECT @@ALTER_ALGORITHM`;
let $error_code = 0; let $error_code = 0;
if ($algorithm == "NOCOPY") { 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") { if ($algorithm == "INSTANT") {
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
-- source include/have_innodb_bzip2.inc -- source include/have_innodb_bzip2.inc
-- source include/not_embedded.inc -- source include/not_embedded.inc
let $innodb_compression_algorithm_orig=`select @@innodb_compression_algorithm`;
# bzip2 # bzip2
set global innodb_compression_algorithm = 5; set global innodb_compression_algorithm = 5;
...@@ -79,9 +77,14 @@ select count(*) from innodb_page_compressed7 where c1 < 500000; ...@@ -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_compressed8 where c1 < 500000;
select count(*) from innodb_page_compressed9 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 warnings;
show create table innodb_normal; 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; alter table innodb_compressed row_format=default page_compressed=1 page_compression_level=8 key_block_size=0;
show warnings; show warnings;
show create table innodb_compressed; show create table innodb_compressed;
...@@ -95,6 +98,7 @@ update innodb_page_compressed6 set c1 = c1 + 1; ...@@ -95,6 +98,7 @@ update innodb_page_compressed6 set c1 = c1 + 1;
update innodb_page_compressed7 set c1 = c1 + 1; update innodb_page_compressed7 set c1 = c1 + 1;
update innodb_page_compressed8 set c1 = c1 + 1; update innodb_page_compressed8 set c1 = c1 + 1;
update innodb_page_compressed9 set c1 = c1 + 1; update innodb_page_compressed9 set c1 = c1 + 1;
commit;
select count(*) from innodb_compressed; select count(*) from innodb_compressed;
select count(*) from innodb_page_compressed1; select count(*) from innodb_page_compressed1;
select count(*) from innodb_page_compressed1 where c1 < 500000; select count(*) from innodb_page_compressed1 where c1 < 500000;
...@@ -236,8 +240,3 @@ drop table innodb_page_compressed6; ...@@ -236,8 +240,3 @@ drop table innodb_page_compressed6;
drop table innodb_page_compressed7; drop table innodb_page_compressed7;
drop table innodb_page_compressed8; drop table innodb_page_compressed8;
drop table innodb_page_compressed9; drop table innodb_page_compressed9;
# reset system
--disable_query_log
EVAL SET GLOBAL innodb_compression_algorithm = $innodb_compression_algorithm_orig;
--enable_query_log
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
-- source include/have_innodb_lz4.inc -- source include/have_innodb_lz4.inc
-- source include/not_embedded.inc -- source include/not_embedded.inc
let $innodb_compression_algorithm_orig=`SELECT @@innodb_compression_algorithm`;
# lz4 # lz4
set global innodb_compression_algorithm = 2; set global innodb_compression_algorithm = 2;
...@@ -79,9 +77,14 @@ select count(*) from innodb_page_compressed7 where c1 < 500000; ...@@ -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_compressed8 where c1 < 500000;
select count(*) from innodb_page_compressed9 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 warnings;
show create table innodb_normal; 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; alter table innodb_compressed row_format=default page_compressed=1 page_compression_level=8 key_block_size=0;
show warnings; show warnings;
show create table innodb_compressed; show create table innodb_compressed;
...@@ -237,8 +240,3 @@ drop table innodb_page_compressed6; ...@@ -237,8 +240,3 @@ drop table innodb_page_compressed6;
drop table innodb_page_compressed7; drop table innodb_page_compressed7;
drop table innodb_page_compressed8; drop table innodb_page_compressed8;
drop table innodb_page_compressed9; drop table innodb_page_compressed9;
# reset system
--disable_query_log
EVAL SET GLOBAL innodb_compression_algorithm = $innodb_compression_algorithm_orig;
--enable_query_log
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
-- source include/have_innodb_lzma.inc -- source include/have_innodb_lzma.inc
-- source include/not_embedded.inc -- source include/not_embedded.inc
let $innodb_compression_algorithm_orig=`SELECT @@innodb_compression_algorithm`;
# lzma # lzma
set global innodb_compression_algorithm = 4; set global innodb_compression_algorithm = 4;
...@@ -79,9 +77,14 @@ select count(*) from innodb_page_compressed7 where c1 < 500000; ...@@ -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_compressed8 where c1 < 500000;
select count(*) from innodb_page_compressed9 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 warnings;
show create table innodb_normal; 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; alter table innodb_compressed row_format=default page_compressed=1 page_compression_level=8 key_block_size=0;
show warnings; show warnings;
show create table innodb_compressed; show create table innodb_compressed;
...@@ -95,6 +98,7 @@ update innodb_page_compressed6 set c1 = c1 + 1; ...@@ -95,6 +98,7 @@ update innodb_page_compressed6 set c1 = c1 + 1;
update innodb_page_compressed7 set c1 = c1 + 1; update innodb_page_compressed7 set c1 = c1 + 1;
update innodb_page_compressed8 set c1 = c1 + 1; update innodb_page_compressed8 set c1 = c1 + 1;
update innodb_page_compressed9 set c1 = c1 + 1; update innodb_page_compressed9 set c1 = c1 + 1;
commit;
select count(*) from innodb_compressed; select count(*) from innodb_compressed;
select count(*) from innodb_page_compressed1; select count(*) from innodb_page_compressed1;
select count(*) from innodb_page_compressed1 where c1 < 500000; select count(*) from innodb_page_compressed1 where c1 < 500000;
...@@ -236,8 +240,3 @@ drop table innodb_page_compressed6; ...@@ -236,8 +240,3 @@ drop table innodb_page_compressed6;
drop table innodb_page_compressed7; drop table innodb_page_compressed7;
drop table innodb_page_compressed8; drop table innodb_page_compressed8;
drop table innodb_page_compressed9; drop table innodb_page_compressed9;
# reset system
--disable_query_log
EVAL SET GLOBAL innodb_compression_algorithm = $innodb_compression_algorithm_orig;
--enable_query_log
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
-- source include/have_innodb_lzo.inc -- source include/have_innodb_lzo.inc
-- source include/not_embedded.inc -- source include/not_embedded.inc
let $innodb_compression_algorithm_orig=`select @@innodb_compression_algorithm`;
# lzo # lzo
set global innodb_compression_algorithm = 3; set global innodb_compression_algorithm = 3;
...@@ -79,9 +77,14 @@ select count(*) from innodb_page_compressed7 where c1 < 500000; ...@@ -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_compressed8 where c1 < 500000;
select count(*) from innodb_page_compressed9 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 warnings;
show create table innodb_normal; 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; alter table innodb_compressed row_format=default page_compressed=1 page_compression_level=8 key_block_size=0;
show warnings; show warnings;
show create table innodb_compressed; show create table innodb_compressed;
...@@ -95,6 +98,7 @@ update innodb_page_compressed6 set c1 = c1 + 1; ...@@ -95,6 +98,7 @@ update innodb_page_compressed6 set c1 = c1 + 1;
update innodb_page_compressed7 set c1 = c1 + 1; update innodb_page_compressed7 set c1 = c1 + 1;
update innodb_page_compressed8 set c1 = c1 + 1; update innodb_page_compressed8 set c1 = c1 + 1;
update innodb_page_compressed9 set c1 = c1 + 1; update innodb_page_compressed9 set c1 = c1 + 1;
commit;
select count(*) from innodb_compressed; select count(*) from innodb_compressed;
select count(*) from innodb_page_compressed1; select count(*) from innodb_page_compressed1;
select count(*) from innodb_page_compressed1 where c1 < 500000; select count(*) from innodb_page_compressed1 where c1 < 500000;
...@@ -189,8 +193,3 @@ drop table innodb_page_compressed6; ...@@ -189,8 +193,3 @@ drop table innodb_page_compressed6;
drop table innodb_page_compressed7; drop table innodb_page_compressed7;
drop table innodb_page_compressed8; drop table innodb_page_compressed8;
drop table innodb_page_compressed9; drop table innodb_page_compressed9;
# reset system
--disable_query_log
eval set global innodb_compression_algorithm = $innodb_compression_algorithm_orig;
--enable_query_log
...@@ -70,8 +70,12 @@ select count(*) from innodb_dynamic where c1 < 1500000; ...@@ -70,8 +70,12 @@ select count(*) from innodb_dynamic where c1 < 1500000;
# none # none
set global innodb_compression_algorithm = 0; set global innodb_compression_algorithm = 0;
alter table innodb_compact engine=innodb page_compressed=DEFAULT; --error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
alter table innodb_dynamic engine=innodb page_compressed=DEFAULT; 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_compact;
show create table innodb_dynamic; show create table innodb_dynamic;
......
--source include/have_innodb.inc --source include/have_innodb.inc
--source include/not_embedded.inc --source include/not_embedded.inc
let $innodb_compression_algorithm_orig=`SELECT @@innodb_compression_algorithm`;
# zlib # zlib
set global innodb_compression_algorithm = 1; set global innodb_compression_algorithm = 1;
...@@ -78,9 +76,14 @@ select count(*) from innodb_page_compressed7 where c1 < 500000; ...@@ -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_compressed8 where c1 < 500000;
select count(*) from innodb_page_compressed9 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 warnings;
show create table innodb_normal; 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; alter table innodb_compressed row_format=default page_compressed=1 page_compression_level=8 key_block_size=0;
show warnings; show warnings;
show create table innodb_compressed; show create table innodb_compressed;
...@@ -187,8 +190,3 @@ drop table innodb_page_compressed6; ...@@ -187,8 +190,3 @@ drop table innodb_page_compressed6;
drop table innodb_page_compressed7; drop table innodb_page_compressed7;
drop table innodb_page_compressed8; drop table innodb_page_compressed8;
drop table innodb_page_compressed9; drop table innodb_page_compressed9;
# reset system
--disable_query_log
EVAL SET GLOBAL innodb_compression_algorithm = $innodb_compression_algorithm_orig;
--enable_query_log
...@@ -7919,3 +7919,5 @@ ER_VERS_QUERY_IN_PARTITION ...@@ -7919,3 +7919,5 @@ ER_VERS_QUERY_IN_PARTITION
eng "SYSTEM_TIME partitions in table %`s does not support historical query" eng "SYSTEM_TIME partitions in table %`s does not support historical query"
ER_KEY_DOESNT_SUPPORT ER_KEY_DOESNT_SUPPORT
eng "%s index %`s does not support this operation" 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"
...@@ -78,7 +78,7 @@ static const alter_table_operations INNOBASE_ALTER_REBUILD ...@@ -78,7 +78,7 @@ static const alter_table_operations INNOBASE_ALTER_REBUILD
= ALTER_ADD_PK_INDEX = ALTER_ADD_PK_INDEX
| ALTER_DROP_PK_INDEX | ALTER_DROP_PK_INDEX
| ALTER_OPTIONS | ALTER_OPTIONS
/* ALTER_OPTIONS needs to check create_option_need_rebuild() */ /* ALTER_OPTIONS needs to check alter_options_need_rebuild() */
| ALTER_COLUMN_NULLABLE | ALTER_COLUMN_NULLABLE
| INNOBASE_DEFAULTS | INNOBASE_DEFAULTS
| ALTER_STORED_COLUMN_ORDER | ALTER_STORED_COLUMN_ORDER
...@@ -210,6 +210,9 @@ struct ha_innobase_inplace_ctx : public inplace_alter_handler_ctx ...@@ -210,6 +210,9 @@ struct ha_innobase_inplace_ctx : public inplace_alter_handler_ctx
(3) Allow the conversion only in non-strict mode. */ (3) Allow the conversion only in non-strict mode. */
const bool allow_not_null; 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, ha_innobase_inplace_ctx(row_prebuilt_t*& prebuilt_arg,
dict_index_t** drop_arg, dict_index_t** drop_arg,
ulint num_to_drop_arg, ulint num_to_drop_arg,
...@@ -226,7 +229,9 @@ struct ha_innobase_inplace_ctx : public inplace_alter_handler_ctx ...@@ -226,7 +229,9 @@ struct ha_innobase_inplace_ctx : public inplace_alter_handler_ctx
ulint add_autoinc_arg, ulint add_autoinc_arg,
ulonglong autoinc_col_min_value_arg, ulonglong autoinc_col_min_value_arg,
ulonglong autoinc_col_max_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(), inplace_alter_handler_ctx(),
prebuilt (prebuilt_arg), prebuilt (prebuilt_arg),
add_index (0), add_key_numbers (0), num_to_add_index (0), 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 ...@@ -254,9 +259,15 @@ struct ha_innobase_inplace_ctx : public inplace_alter_handler_ctx
old_n_cols(prebuilt_arg->table->n_cols), old_n_cols(prebuilt_arg->table->n_cols),
old_cols(prebuilt_arg->table->cols), old_cols(prebuilt_arg->table->cols),
old_col_names(prebuilt_arg->table->col_names), 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(old_n_cols >= DATA_N_SYS_COLS);
ut_ad(page_compression_level <= 9);
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
for (ulint i = 0; i < num_to_add_index; i++) { for (ulint i = 0; i < num_to_add_index; i++) {
ut_ad(!add_index[i]->to_be_dropped); ut_ad(!add_index[i]->to_be_dropped);
...@@ -490,11 +501,11 @@ innobase_spatial_exist( ...@@ -490,11 +501,11 @@ innobase_spatial_exist(
return(false); 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] ha_alter_info the ALTER TABLE operation
@param[in] table metadata before ALTER TABLE @param[in] table metadata before ALTER TABLE
@return whether it is mandatory to rebuild the 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 Alter_inplace_info* ha_alter_info,
const TABLE* table) const TABLE* table)
{ {
...@@ -513,12 +524,12 @@ static bool create_option_need_rebuild( ...@@ -513,12 +524,12 @@ static bool create_option_need_rebuild(
} }
const ha_table_option_struct& alt_opt= 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; const ha_table_option_struct& opt= *table->s->option_struct;
if (alt_opt.page_compressed != opt.page_compressed /* Allow an instant change to enable page_compressed,
|| alt_opt.page_compression_level and any change of page_compression_level. */
!= opt.page_compression_level if ((!alt_opt.page_compressed && opt.page_compressed)
|| alt_opt.encryption != opt.encryption || alt_opt.encryption != opt.encryption
|| alt_opt.encryption_key_id != opt.encryption_key_id) { || alt_opt.encryption_key_id != opt.encryption_key_id) {
return(true); return(true);
...@@ -541,7 +552,7 @@ innobase_need_rebuild( ...@@ -541,7 +552,7 @@ innobase_need_rebuild(
if ((ha_alter_info->handler_flags & ~(INNOBASE_INPLACE_IGNORE if ((ha_alter_info->handler_flags & ~(INNOBASE_INPLACE_IGNORE
| INNOBASE_ALTER_INSTANT)) | INNOBASE_ALTER_INSTANT))
== ALTER_OPTIONS) { == 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); return !!(ha_alter_info->handler_flags & INNOBASE_ALTER_REBUILD);
...@@ -689,7 +700,7 @@ instant_alter_column_possible( ...@@ -689,7 +700,7 @@ instant_alter_column_possible(
} }
return !(ha_alter_info->handler_flags & ALTER_OPTIONS) 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 /** Check whether the non-const default value for the field
...@@ -849,9 +860,11 @@ ha_innobase::check_if_supported_inplace_alter( ...@@ -849,9 +860,11 @@ ha_innobase::check_if_supported_inplace_alter(
{ {
DBUG_ENTER("check_if_supported_inplace_alter"); DBUG_ENTER("check_if_supported_inplace_alter");
if ((table->versioned(VERS_TIMESTAMP) const bool need_rebuild = innobase_need_rebuild(ha_alter_info, table);
|| altered_table->versioned(VERS_TIMESTAMP))
&& innobase_need_rebuild(ha_alter_info, table)) { if (need_rebuild
&& (table->versioned(VERS_TIMESTAMP)
|| altered_table->versioned(VERS_TIMESTAMP))) {
ha_alter_info->unsupported_reason = ha_alter_info->unsupported_reason =
"Not implemented for system-versioned tables"; "Not implemented for system-versioned tables";
DBUG_RETURN(HA_ALTER_INPLACE_NOT_SUPPORTED); DBUG_RETURN(HA_ALTER_INPLACE_NOT_SUPPORTED);
...@@ -907,15 +920,15 @@ ha_innobase::check_if_supported_inplace_alter( ...@@ -907,15 +920,15 @@ ha_innobase::check_if_supported_inplace_alter(
DBUG_RETURN(HA_ALTER_INPLACE_NOT_SUPPORTED); DBUG_RETURN(HA_ALTER_INPLACE_NOT_SUPPORTED);
} }
#if 0 switch (ha_alter_info->handler_flags & ~INNOBASE_INPLACE_IGNORE) {
if (altered_table->file->ht != ht) { case ALTER_OPTIONS:
/* Non-native partitioning table engine. No longer supported, if (alter_options_need_rebuild(ha_alter_info, table)) {
due to implementation of native InnoDB partitioning. */ ha_alter_info->unsupported_reason = my_get_err_msg(
DBUG_RETURN(HA_ALTER_INPLACE_NOT_SUPPORTED); ER_ALTER_OPERATION_TABLE_OPTIONS_NEED_REBUILD);
} break;
#endif }
/* fall through */
if (!(ha_alter_info->handler_flags & ~INNOBASE_INPLACE_IGNORE)) { case 0:
DBUG_RETURN(HA_ALTER_INPLACE_INSTANT); DBUG_RETURN(HA_ALTER_INPLACE_INSTANT);
} }
...@@ -1294,9 +1307,8 @@ ha_innobase::check_if_supported_inplace_alter( ...@@ -1294,9 +1307,8 @@ ha_innobase::check_if_supported_inplace_alter(
if (!online) { if (!online) {
/* We already determined that only a non-locking /* We already determined that only a non-locking
operation is possible. */ operation is possible. */
} else if (((ha_alter_info->handler_flags } else if ((need_rebuild || (ha_alter_info->handler_flags
& ALTER_ADD_PK_INDEX) & ALTER_ADD_PK_INDEX))
|| innobase_need_rebuild(ha_alter_info, table))
&& (innobase_fulltext_exist(altered_table) && (innobase_fulltext_exist(altered_table)
|| innobase_spatial_exist(altered_table) || innobase_spatial_exist(altered_table)
|| innobase_indexed_virtual_exist(altered_table))) { || innobase_indexed_virtual_exist(altered_table))) {
...@@ -1394,10 +1406,9 @@ ha_innobase::check_if_supported_inplace_alter( ...@@ -1394,10 +1406,9 @@ ha_innobase::check_if_supported_inplace_alter(
} }
// FIXME: implement Online DDL for system-versioned tables // FIXME: implement Online DDL for system-versioned tables
if ((table->versioned(VERS_TRX_ID) if (need_rebuild &&
|| altered_table->versioned(VERS_TRX_ID)) (table->versioned(VERS_TRX_ID)
&& innobase_need_rebuild(ha_alter_info, table)) { || altered_table->versioned(VERS_TRX_ID))) {
if (ha_alter_info->online) { if (ha_alter_info->online) {
ha_alter_info->unsupported_reason = ha_alter_info->unsupported_reason =
"Not implemented for system-versioned tables"; "Not implemented for system-versioned tables";
...@@ -1406,7 +1417,7 @@ ha_innobase::check_if_supported_inplace_alter( ...@@ -1406,7 +1417,7 @@ ha_innobase::check_if_supported_inplace_alter(
online = false; online = false;
} }
if (fts_need_rebuild || innobase_need_rebuild(ha_alter_info, table)) { if (need_rebuild || fts_need_rebuild) {
DBUG_RETURN(online DBUG_RETURN(online
? HA_ALTER_INPLACE_COPY_NO_LOCK ? HA_ALTER_INPLACE_COPY_NO_LOCK
: HA_ALTER_INPLACE_COPY_LOCK); : HA_ALTER_INPLACE_COPY_LOCK);
...@@ -6827,11 +6838,14 @@ ha_innobase::prepare_inplace_alter_table( ...@@ -6827,11 +6838,14 @@ ha_innobase::prepare_inplace_alter_table(
} }
} }
const ha_table_option_struct& alt_opt=
*ha_alter_info->create_info->option_struct;
if (!(ha_alter_info->handler_flags & INNOBASE_ALTER_DATA) if (!(ha_alter_info->handler_flags & INNOBASE_ALTER_DATA)
|| ((ha_alter_info->handler_flags & ~(INNOBASE_INPLACE_IGNORE || ((ha_alter_info->handler_flags & ~(INNOBASE_INPLACE_IGNORE
| INNOBASE_ALTER_INSTANT)) | INNOBASE_ALTER_INSTANT))
== ALTER_OPTIONS == ALTER_OPTIONS
&& !create_option_need_rebuild(ha_alter_info, table))) { && !alter_options_need_rebuild(ha_alter_info, table))) {
if (heap) { if (heap) {
ha_alter_info->handler_ctx ha_alter_info->handler_ctx
...@@ -6845,7 +6859,9 @@ ha_innobase::prepare_inplace_alter_table( ...@@ -6845,7 +6859,9 @@ ha_innobase::prepare_inplace_alter_table(
heap, indexed_table, heap, indexed_table,
col_names, ULINT_UNDEFINED, 0, 0, col_names, ULINT_UNDEFINED, 0, 0,
(ha_alter_info->ignore (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); DBUG_ASSERT(m_prebuilt->trx->dict_operation_lock_mode == 0);
...@@ -6974,7 +6990,8 @@ ha_innobase::prepare_inplace_alter_table( ...@@ -6974,7 +6990,8 @@ ha_innobase::prepare_inplace_alter_table(
add_autoinc_col_no, add_autoinc_col_no,
ha_alter_info->create_info->auto_increment_value, ha_alter_info->create_info->auto_increment_value,
autoinc_col_max_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( DBUG_RETURN(prepare_inplace_alter_table_dict(
ha_alter_info, altered_table, table, ha_alter_info, altered_table, table,
...@@ -7113,7 +7130,7 @@ ha_innobase::inplace_alter_table( ...@@ -7113,7 +7130,7 @@ ha_innobase::inplace_alter_table(
if ((ha_alter_info->handler_flags & ~(INNOBASE_INPLACE_IGNORE if ((ha_alter_info->handler_flags & ~(INNOBASE_INPLACE_IGNORE
| INNOBASE_ALTER_INSTANT)) | INNOBASE_ALTER_INSTANT))
== ALTER_OPTIONS == ALTER_OPTIONS
&& !create_option_need_rebuild(ha_alter_info, table)) { && !alter_options_need_rebuild(ha_alter_info, table)) {
goto ok_exit; goto ok_exit;
} }
...@@ -8824,6 +8841,58 @@ get_col_list_to_be_dropped( ...@@ -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() /** Commit the changes made during prepare_inplace_alter_table()
and inplace_alter_table() inside the data dictionary tables, and inplace_alter_table() inside the data dictionary tables,
when not rebuilding the table. when not rebuilding the table.
...@@ -8857,6 +8926,13 @@ commit_try_norebuild( ...@@ -8857,6 +8926,13 @@ commit_try_norebuild(
|| ctx->num_to_drop_vcol || ctx->num_to_drop_vcol
== ha_alter_info->alter_info->drop_list.elements); == 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++) { for (ulint i = 0; i < ctx->num_to_add_index; i++) {
dict_index_t* index = ctx->add_index[i]; dict_index_t* index = ctx->add_index[i];
DBUG_ASSERT(dict_index_get_online_status(index) DBUG_ASSERT(dict_index_get_online_status(index)
...@@ -9002,6 +9078,57 @@ commit_cache_norebuild( ...@@ -9002,6 +9078,57 @@ commit_cache_norebuild(
{ {
DBUG_ENTER("commit_cache_norebuild"); DBUG_ENTER("commit_cache_norebuild");
DBUG_ASSERT(!ctx->need_rebuild()); 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 drop_list;
col_set v_drop_list; col_set v_drop_list;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment