mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Follow-up to MDEV-16328: ALTER TABLE…page_compression_level should not rebuild table
Allow combination of non-instant, non-rebuilding operations with changes of table options that do not require a rebuild. For example, DROP INDEX or ADD INDEX can be performed with ALGORITHM=NOCOPY together with changing such table options. Changing the table options alone would be allowed with ALGORITHM=INSTANT. INNOBASE_ALTER_NOCREATE: A new set of flags, for operations that are refused for ALGORITHM=INSTANT and do not involve creating index trees. Move ALTER_RENAME_INDEX to the proper place (INNOBASE_ALTER_INSTANT). innobase_need_rebuild(): Do not require a rebuild if INNOBASE_ALTER_NOREBUILD operations are combined with ALTER_OPTIONS. ha_innobase::prepare_inplace_alter_table(), ha_innobase::inplace_alter_table(): Use the fast path if ALTER_OPTIONS is combined with INNOBASE_ALTER_NOCREATE. In this case, the actual changes would be deferred to ha_innobase::commit_inplace_alter_table().
This commit is contained in:
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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)) {
|
||||
|
Reference in New Issue
Block a user