diff --git a/mysql-test/suite/innodb/include/alter_nocopy.inc b/mysql-test/suite/innodb/include/alter_nocopy.inc index 6b19d244bd9..00cab8c47e5 100644 --- a/mysql-test/suite/innodb/include/alter_nocopy.inc +++ b/mysql-test/suite/innodb/include/alter_nocopy.inc @@ -14,16 +14,16 @@ SELECT @@alter_algorithm; --enable_info --error $error_code ---eval ALTER TABLE t1 ADD INDEX idx1(f4) +--eval ALTER TABLE t1 ADD INDEX idx1(f4), page_compressed=1 --error $error_code ---eval ALTER TABLE t1 DROP INDEX idx +--eval ALTER TABLE t1 DROP INDEX idx, page_compression_level=5 --error $error_code --eval ALTER TABLE t1 ADD UNIQUE INDEX u1(f2) --error $error_code ---eval ALTER TABLE t1 DROP INDEX f4 +--eval ALTER TABLE t1 DROP INDEX f4, page_compression_level=9 SET foreign_key_checks = 0; --error $error_code diff --git a/mysql-test/suite/innodb/r/alter_algorithm,INPLACE.rdiff b/mysql-test/suite/innodb/r/alter_algorithm,INPLACE.rdiff index e9a24820a50..8178e9ea58e 100644 --- a/mysql-test/suite/innodb/r/alter_algorithm,INPLACE.rdiff +++ b/mysql-test/suite/innodb/r/alter_algorithm,INPLACE.rdiff @@ -70,12 +70,12 @@ @@alter_algorithm -COPY +INPLACE - ALTER TABLE t1 ADD INDEX idx1(f4); + ALTER TABLE t1 ADD INDEX idx1(f4), page_compressed=1; -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; + ALTER TABLE t1 DROP INDEX idx, page_compression_level=5; -affected rows: 1 -info: Records: 1 Duplicates: 0 Warnings: 0 +affected rows: 0 @@ -85,7 +85,7 @@ -info: Records: 1 Duplicates: 0 Warnings: 0 +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 - ALTER TABLE t1 DROP INDEX f4; + ALTER TABLE t1 DROP INDEX f4, page_compression_level=9; -affected rows: 1 -info: Records: 1 Duplicates: 0 Warnings: 0 +affected rows: 0 diff --git a/mysql-test/suite/innodb/r/alter_algorithm,INSTANT.rdiff b/mysql-test/suite/innodb/r/alter_algorithm,INSTANT.rdiff index c432494dd53..ce2e240bb35 100644 --- a/mysql-test/suite/innodb/r/alter_algorithm,INSTANT.rdiff +++ b/mysql-test/suite/innodb/r/alter_algorithm,INSTANT.rdiff @@ -61,11 +61,11 @@ @@alter_algorithm -COPY +INSTANT - ALTER TABLE t1 ADD INDEX idx1(f4); + ALTER TABLE t1 ADD INDEX idx1(f4), page_compressed=1; -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; + ALTER TABLE t1 DROP INDEX idx, page_compression_level=5; -affected rows: 1 -info: Records: 1 Duplicates: 0 Warnings: 0 +ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: DROP INDEX. Try ALGORITHM=NOCOPY @@ -73,7 +73,7 @@ -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; + ALTER TABLE t1 DROP INDEX f4, page_compression_level=9; -affected rows: 1 -info: Records: 1 Duplicates: 0 Warnings: 0 +ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: DROP INDEX. Try ALGORITHM=NOCOPY diff --git a/mysql-test/suite/innodb/r/alter_algorithm,NOCOPY.rdiff b/mysql-test/suite/innodb/r/alter_algorithm,NOCOPY.rdiff index 3ec1eed2e3b..5d462e0012d 100644 --- a/mysql-test/suite/innodb/r/alter_algorithm,NOCOPY.rdiff +++ b/mysql-test/suite/innodb/r/alter_algorithm,NOCOPY.rdiff @@ -61,12 +61,12 @@ @@alter_algorithm -COPY +NOCOPY - ALTER TABLE t1 ADD INDEX idx1(f4); + ALTER TABLE t1 ADD INDEX idx1(f4), page_compressed=1; -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; + ALTER TABLE t1 DROP INDEX idx, page_compression_level=5; -affected rows: 1 -info: Records: 1 Duplicates: 0 Warnings: 0 +affected rows: 0 @@ -76,7 +76,7 @@ -info: Records: 1 Duplicates: 0 Warnings: 0 +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 - ALTER TABLE t1 DROP INDEX f4; + ALTER TABLE t1 DROP INDEX f4, page_compression_level=9; -affected rows: 1 -info: Records: 1 Duplicates: 0 Warnings: 0 +affected rows: 0 diff --git a/mysql-test/suite/innodb/r/alter_algorithm.result b/mysql-test/suite/innodb/r/alter_algorithm.result index 9a031d9066a..cbefcad5986 100644 --- a/mysql-test/suite/innodb/r/alter_algorithm.result +++ b/mysql-test/suite/innodb/r/alter_algorithm.result @@ -59,16 +59,16 @@ INSERT INTO t1(f1, f2, f4, f5) VALUES(1, 2, 3, 4); SELECT @@alter_algorithm; @@alter_algorithm COPY -ALTER TABLE t1 ADD INDEX idx1(f4); +ALTER TABLE t1 ADD INDEX idx1(f4), page_compressed=1; affected rows: 1 info: Records: 1 Duplicates: 0 Warnings: 0 -ALTER TABLE t1 DROP INDEX idx; +ALTER TABLE t1 DROP INDEX idx, page_compression_level=5; affected rows: 1 info: Records: 1 Duplicates: 0 Warnings: 0 ALTER TABLE t1 ADD UNIQUE INDEX u1(f2); affected rows: 1 info: Records: 1 Duplicates: 0 Warnings: 0 -ALTER TABLE t1 DROP INDEX f4; +ALTER TABLE t1 DROP INDEX f4, page_compression_level=9; affected rows: 1 info: Records: 1 Duplicates: 0 Warnings: 0 SET foreign_key_checks = 0; diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 86f8ce50a72..13a963575a6 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -110,20 +110,23 @@ static const alter_table_operations INNOBASE_FOREIGN_OPERATIONS = ALTER_DROP_FOREIGN_KEY | ALTER_ADD_FOREIGN_KEY; +/** Operations that InnoDB cares about and can perform without creating data */ +static const alter_table_operations INNOBASE_ALTER_NOCREATE + = ALTER_DROP_NON_UNIQUE_NON_PRIM_INDEX + | ALTER_DROP_UNIQUE_INDEX; + /** Operations that InnoDB cares about and can perform without rebuild */ static const alter_table_operations INNOBASE_ALTER_NOREBUILD = INNOBASE_ONLINE_CREATE - | ALTER_DROP_NON_UNIQUE_NON_PRIM_INDEX - | ALTER_DROP_UNIQUE_INDEX -#ifdef MYSQL_RENAME_INDEX - | ALTER_RENAME_INDEX -#endif - ; + | INNOBASE_ALTER_NOCREATE; /** Operations that can be performed instantly, without inplace_alter_table() */ static const alter_table_operations INNOBASE_ALTER_INSTANT = ALTER_VIRTUAL_COLUMN_ORDER | ALTER_COLUMN_NAME +#ifdef MYSQL_RENAME_INDEX + | ALTER_RENAME_INDEX +#endif | ALTER_ADD_VIRTUAL_COLUMN | INNOBASE_FOREIGN_OPERATIONS | ALTER_COLUMN_EQUAL_PACK_LENGTH @@ -550,6 +553,7 @@ innobase_need_rebuild( const TABLE* table) { if ((ha_alter_info->handler_flags & ~(INNOBASE_INPLACE_IGNORE + | INNOBASE_ALTER_NOREBUILD | INNOBASE_ALTER_INSTANT)) == ALTER_OPTIONS) { return alter_options_need_rebuild(ha_alter_info, table); @@ -6836,6 +6840,7 @@ err_exit: if (!(ha_alter_info->handler_flags & INNOBASE_ALTER_DATA) || ((ha_alter_info->handler_flags & ~(INNOBASE_INPLACE_IGNORE + | INNOBASE_ALTER_NOCREATE | INNOBASE_ALTER_INSTANT)) == ALTER_OPTIONS && !alter_options_need_rebuild(ha_alter_info, table))) { @@ -7121,6 +7126,7 @@ ok_exit: } if ((ha_alter_info->handler_flags & ~(INNOBASE_INPLACE_IGNORE + | INNOBASE_ALTER_NOCREATE | INNOBASE_ALTER_INSTANT)) == ALTER_OPTIONS && !alter_options_need_rebuild(ha_alter_info, table)) {