The flag ALTER_COLUMN_VCOL is supposed to be set when an ALTER TABLE operation affects the base column of a generated column in a way that something may have to be recalculated. Consider the following example, which I am about to add to the test innodb.innodb-alter-nullable in 10.2:
For tables t1,t3 in the above example, we would have to recompute something when the ALTER TABLE updates c=NULL to c=0. For t3, we are doing the right thing, because all three flags will be set:
For t2, it is correct to set only the following flags, because the virtual column that depends on the modified column is not being materialized anywhere (not in the table nor in any indexes):
But, for t1, instead of setting only the 2 flags, we should set all 3 flags, because the stored generated column g should be updated in sync with its base column c.
MDEV-14168 and MDEV-16365 in MariaDB 10.3.7 and 10.3.8, InnoDB supports ALGORITHM=INPLACE in non-strict mode (as well as for ALTER IGNORE TABLE) for converting a column from NULL to NOT NULL.
I do not think that anything needs to be changed in MariaDB 10.2. With 10.3, we should set the flag if NULL values are allowed to be modified during the ALTER TABLE. The condition for that would be as follows:
Actually, we are currently unnecessarily setting the ALTER_COLUMN_VCOL flag when changing the base column of an indexed virtual column in strict mode. In this mode, InnoDB should be able to rebuild the table within ALGORITHM=INPLACE, without any changes to any virtual column values. (The operation would fail if any NULL values were encountered in the column.)