Details
-
Bug
-
Status: Confirmed (View Workflow)
-
Major
-
Resolution: Unresolved
-
10.2(EOL), 10.3(EOL), 10.4(EOL)
Description
Changing the type of a virtual column will not affect the format of the clustered index. It may imply DROP INDEX and ADD INDEX for any indexes that are defined on the virtual column. If such indexes are to remain after the ALTER TABLE operation, then changing the virtual column type obviously cannot be an instantaneous operation.
Attachments
Issue Links
- relates to
-
MDEV-11424 Instant ALTER TABLE of failure-free record format changes
-
- Closed
-
-
MDEV-14046 Allow ALGORITHM=INPLACE for 10.1 tables that contain virtual columns
-
- Closed
-
-
MDEV-14341 Allow LOCK=NONE in table-rebuilding ALTER when indexed virtual columns exist
-
- Open
-
-
MDEV-16356 Allow ALGORITHM=NOCOPY for ADD CONSTRAINT
-
- Open
-
-
MDEV-17468 Avoid table rebuild on operations on generated columns
-
- Stalled
-
-
MDEV-5800 indexes on virtual (not materialized) columns
-
- Closed
-
-
MDEV-15476 Inplace algorithm doesn't support changing virtual column datatype
-
- Stalled
-
-
MDEV-19214 Virtual column type cannot be converted from one to another - unhelpful error message
-
- Open
-
With ALGORITHM=COPY, changing the data type of a virtual column will cause each value to be validated. ALTER IGNORE TABLE would issue warnings for any invalid values, and without IGNORE the operation would be aborted.
The type compatibility aspect of virtual columns is similar to constraints. By default, ADD CONSTRAINT requires validation as well, both for CHECK and FOREIGN KEY. Currently this validation is only performed by ALGORITHM=COPY; it would be much more efficient to perform the validation only (scan the table) and then change the metadata instantly.
Theoretically, we could skip the validation if the type of the virtual column is changed to a more permissive one, or if NOT NULL is being added and the virtual column expression never returns NULL. But even in this case, it could be that the virtual column was inconsistently created (with ALTER IGNORE) earlier, and also the altered virtual column would fail validation.
For more efficient algorithms, ALGORITHM=COPY is the specification that dictates what should be done. If ALTER IGNORE…ALGORITHM=COPY is issuing warnings for incompatible values, then it looks like we should not support instant operation (without validation) even with the IGNORE clause. We might want a separate WITHOUT VALIDATION clause.