[MDEV-31008] Instant ALTER allows to violate column check constraint Created: 2023-04-04 Updated: 2023-11-28 |
|
| Status: | Confirmed |
| Project: | MariaDB Server |
| Component/s: | Data Definition - Alter Table, Storage Engine - InnoDB |
| Affects Version/s: | 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10, 10.11, 11.0 |
| Fix Version/s: | 10.4, 10.5, 10.6, 10.11, 11.0 |
| Type: | Bug | Priority: | Major |
| Reporter: | Elena Stepanova | Assignee: | Sergei Golubchik |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | consistency | ||
| Issue Links: |
|
||||||||
| Description |
|
An even simpler, but a degenerate test case is
Result is the same. Not reproducible with algorithm=copy. |
| Comments |
| Comment by Marko Mäkelä [ 2023-04-05 ] | |||||||||||
|
Part of the problem here is that there no flag exists for adding a CHECK constraint. The only flag that will be set is one for adding the column:
The same problem occurs also with the following:
In this case, a different flag (which is ignored by InnoDB) will be set by fill_alter_inplace_info():
I think that by default, adding any CHECK constraints must imply ALGORITHM=COPY. Similar to adding FOREIGN KEY constraints, there could be an override mechanism. Ultimately, in MDEV-16356, we can allow ALGORITHM=NOCOPY for adding such constraints, by implementing a validation pass. This is something that needs to be fixed outside the storage engine. InnoDB has nothing to do with CHECK constraints. (I assume that it also fails to enforce them related to FOREIGN KEY, similar to triggers: MDEV-12302.) |