Bug #121896 INPLACE drop of UNIQUE functional index fails with error 1846

Submitted: 24 Nov 4:50
Reporter: QiFan Liu Email Updates:
Status: Open Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S3 (Non-critical)
Version:26.10.0 OS:Linux
Assigned to: CPU Architecture:x86
Tags: ALGORITHM=INPLACE, ALTER TABLE, functional index, Online DDL, unique

[24 Nov 4:50] QiFan Liu
Description:
Dropping a UNIQUE functional secondary index from an InnoDB table fails when ALGORITHM=INPLACE and LOCK=NONE are requested:

ERROR 1846 (0A000): ALGORITHM=INPLACE is not supported. Reason: INPLACE ADD or DROP of virtual columns cannot be combined with other ALTER TABLE actions. Try ALGORITHM=COPY.

The index is not dropped. The table retains both functional indexes and both hidden virtual columns.

This contradicts the MySQL 26.10 Reference Manual, section 17.12.1, “Online DDL Operations.” Table 17.13 describes dropping an index as:

Dropping an index | No | Yes | No | Yes | Yes

The columns are “Operation | Instant | In Place | Rebuilds Table | Permits Concurrent DML | Only Modifies Metadata.” The section also states:

The table remains available for read and write operations while the index is being dropped.

The CREATE INDEX documentation also states that UNIQUE is supported for indexes that include functional key parts. No exception for dropping a UNIQUE functional index is documented.

How to repeat:
Run as root in the mysql client:

CREATE DATABASE db1;
USE db1;

CREATE TABLE t1 (
  a INT,
  b INT,
  UNIQUE INDEX u1 ((a + 1)),
  UNIQUE INDEX u2 ((b + 1))
) ENGINE=InnoDB;

SELECT COUNT(*) AS before_virtual_count
FROM INFORMATION_SCHEMA.INNODB_VIRTUAL AS v
JOIN INFORMATION_SCHEMA.INNODB_TABLES AS t ON t.TABLE_ID = v.TABLE_ID
WHERE t.NAME = 'db1/t1';
-- returns 2

ALTER TABLE t1
  DROP INDEX u2,
  ALGORITHM=INPLACE,
  LOCK=NONE;
-- ERROR 1846 (0A000): ALGORITHM=INPLACE is not supported. Reason: INPLACE ADD or DROP of virtual columns cannot be combined with other ALTER TABLE actions. Try ALGORITHM=COPY.

SELECT COUNT(*) AS after_virtual_count
FROM INFORMATION_SCHEMA.INNODB_VIRTUAL AS v
JOIN INFORMATION_SCHEMA.INNODB_TABLES AS t ON t.TABLE_ID = v.TABLE_ID
WHERE t.NAME = 'db1/t1';
-- returns 2; expected 1

SELECT COUNT(*) AS remaining_indexes
FROM INFORMATION_SCHEMA.STATISTICS
WHERE TABLE_SCHEMA = 'db1'
  AND TABLE_NAME = 't1';
-- returns 2; expected 1

Suggested fix:
Handle the drop of a UNIQUE functional secondary index like the drop of a non-unique functional secondary index when validating online ALTER TABLE operation combinations.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.048 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.