[MDEV-16332] Allow ALGORITHM=NOCOPY or INSTANT for changes of virtual column type Created: 2018-05-30  Updated: 2023-04-27

Status: Confirmed
Project: MariaDB Server
Component/s: Storage Engine - InnoDB
Affects Version/s: 10.2, 10.3, 10.4
Fix Version/s: 10.4

Type: Bug Priority: Major
Reporter: Marko Mäkelä Assignee: Thirunarayanan Balathandayuthapani
Resolution: Unresolved Votes: 1
Labels: ddl, instant, performance, virtual_columns

Issue Links:
Relates
relates to MDEV-11424 Instant ALTER TABLE of failure-free r... Closed
relates to MDEV-14046 Allow ALGORITHM=INPLACE for 10.1 tabl... Closed
relates to MDEV-14341 Allow LOCK=NONE in table-rebuilding A... Open
relates to MDEV-16356 Allow ALGORITHM=NOCOPY for ADD CONSTR... Open
relates to MDEV-17468 Avoid table rebuild on operations on ... Stalled
relates to MDEV-5800 indexes on virtual (not materialized)... Closed
relates to MDEV-15476 Inplace algorithm doesn't support cha... Stalled
relates to MDEV-19214 Virtual column type cannot be convert... Open

 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.



 Comments   
Comment by Marko Mäkelä [ 2018-08-10 ]

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.

Generated at Thu Feb 08 08:28:07 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.