[MDEV-18819] ALTER_COLUMN_VCOL is not set for generated stored columns Created: 2019-03-05 Updated: 2019-10-30 Resolved: 2019-10-30 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Data Definition - Alter Table |
| Affects Version/s: | 10.2.2, 10.3.0, 10.4.0 |
| Fix Version/s: | 10.3.19, 10.4.9 |
| Type: | Bug | Priority: | Major |
| Reporter: | Marko Mäkelä | Assignee: | Sergei Golubchik |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | corruption, virtual_columns | ||
| Issue Links: |
|
||||||||
| Description |
|
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. Starting with 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.) |