-
Dmitry Lenev authored
Stored generated column values and indexes on virtual generated columns were not correctly updated after columns on which these generated columns depended were swapped using ALTER TABLE ... RENAME COLUMN or ALTER TABLE ... CHANGE COLUMN. This problem was caused by the fact that renaming of columns on which generated columns were dependent was not prohibited as it was planned initially (we only detected the problem if generation expression became invalid). Nor the fact that base columns were swapped and generated expression needs re-evaluation as result was detected. This fix solves the problem by disallowing renaming of base columns for generated columns, generated defaults and functional indexes. However, such renaming is allowed if generated column/default or functional index is removed by the same ALTER TABLE. We also allow such renaming if dependent expression in question is updated within the same ALTER TABLE. This allows to support existing/documented user scenarios in which generation expression was updated to follow base column renames. Restriction on dropping columns on which generated columns, defaults or functional indexes depend was relaxed in similar way. Code which evaluates flags for in-place/instant ALTER TABLE SE API was adjusted to detect situations in which generated column expressions stays the same but has changed its values due to base column swapping or replacement (through drop/add). To support the above changes handling of Alter_info::drop_list list by SQL-layer code has been changed. We no longer delete elements which correspond to columns and keys from it. As consequence InnoDB SE code has been adjusted to take this change into account. To support the latter new members for number of added and dropped virtual columns were added to Alter_inplace_info class. New error message and code was added to report about dependent functional indexes for columns being renamed/dropped. Existing error message about dependent default expressions was adjusted to make it possible to use in cases when base columns are renamed. Reviewed-by:
Sivert Sorumgaard <sivert.sorumgaard@oracle.com> Reviewed-by:
Bin Su <bin.x.su@oracle.com>
Dmitry Lenev authoredStored generated column values and indexes on virtual generated columns were not correctly updated after columns on which these generated columns depended were swapped using ALTER TABLE ... RENAME COLUMN or ALTER TABLE ... CHANGE COLUMN. This problem was caused by the fact that renaming of columns on which generated columns were dependent was not prohibited as it was planned initially (we only detected the problem if generation expression became invalid). Nor the fact that base columns were swapped and generated expression needs re-evaluation as result was detected. This fix solves the problem by disallowing renaming of base columns for generated columns, generated defaults and functional indexes. However, such renaming is allowed if generated column/default or functional index is removed by the same ALTER TABLE. We also allow such renaming if dependent expression in question is updated within the same ALTER TABLE. This allows to support existing/documented user scenarios in which generation expression was updated to follow base column renames. Restriction on dropping columns on which generated columns, defaults or functional indexes depend was relaxed in similar way. Code which evaluates flags for in-place/instant ALTER TABLE SE API was adjusted to detect situations in which generated column expressions stays the same but has changed its values due to base column swapping or replacement (through drop/add). To support the above changes handling of Alter_info::drop_list list by SQL-layer code has been changed. We no longer delete elements which correspond to columns and keys from it. As consequence InnoDB SE code has been adjusted to take this change into account. To support the latter new members for number of added and dropped virtual columns were added to Alter_inplace_info class. New error message and code was added to report about dependent functional indexes for columns being renamed/dropped. Existing error message about dependent default expressions was adjusted to make it possible to use in cases when base columns are renamed. Reviewed-by:
Sivert Sorumgaard <sivert.sorumgaard@oracle.com> Reviewed-by:
Bin Su <bin.x.su@oracle.com>
Loading