[MDEV-18732] InnoDB: Wrong results in ALTER IGNORE TABLE with ALGORITHM=INPLACE Created: 2019-02-25 Updated: 2019-03-05 Resolved: 2019-03-05 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Storage Engine - InnoDB |
| Affects Version/s: | 10.0, 10.2.2, 10.3.0, 10.4.0 |
| Fix Version/s: | 10.2.23, 10.1.39, 10.3.14, 10.4.4 |
| Type: | Bug | Priority: | Major |
| Reporter: | Matthias Leich | Assignee: | Marko Mäkelä |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | upstream | ||
| Attachments: |
|
||||||||||||||||||||
| Issue Links: |
|
||||||||||||||||||||
| Description |
|
Problem found during RQG testing involving row based replication.
|
| Comments |
| Comment by Matthias Leich [ 2019-02-25 ] | ||||||||||||||||
|
How to replay the problem?
| ||||||||||||||||
| Comment by Marko Mäkelä [ 2019-02-27 ] | ||||||||||||||||
|
Here is a more concise test case that demonstrates the issue on 10.2. I suspect that it could be present on 10.0 and 10.1 as well:
The problem is that ALGORITHM=INPLACE is throwing an error, while ALGORITHM=COPY allows the operation to go through (the NULL is being updated to 0). | ||||||||||||||||
| Comment by Marko Mäkelä [ 2019-02-27 ] | ||||||||||||||||
|
On MariaDB 10.3, the ALTER IGNORE TABLE will not fail, but it will actually produce the warning. So, we must fix different things in this area. Starting with MariaDB 10.2, SQL_MODE includes STRICT_TRANS_TABLES by default. In older versions, you would have to set that in order to enable ALGORITHM=INPLACE for introducing a NOT NULL attribute to a column. | ||||||||||||||||
| Comment by Matthias Leich [ 2019-02-27 ] | ||||||||||||||||
|
| ||||||||||||||||
| Comment by Marko Mäkelä [ 2019-03-04 ] | ||||||||||||||||
|
The sql_mode in the test effectively turns off STRICT_ALL_TABLES or STRICT_TRANS_TABLES. Starting with In MariaDB 10.0, 10.1 and 10.2, we should have refused ALTER IGNORE TABLE when introducing a NOT NULL attribute. (This is available when one of strict_all_tables or strict_trans_tables is set in sql_mode.) ALGORITHM=INPLACE allowed the ALTER IGNORE TABLE but returned an error for the NULL value. With the fix in place, 10.1 and 10.2 will refuse ALTER IGNORE TABLE for introducing NOT NULL attribute, and ALGORITHM=COPY will do the right thing. While merging the fix from 10.1 to 10.2, I noticed that a regression had been introduced in MariaDB 10.2.2: ALTER IGNORE TABLE would fail to refuse ALGORITHM=INPLACE for ADD PRIMARY KEY or ADD UNIQUE KEY. I restored that code and added a test case. For MariaDB Server 10.3, we need a bigger fix. Either we will have to refuse the ALTER IGNORE TABLE if indexed virtual columns depend on the column, or we will have to compute the dependent indexed virtual column values when updating the NULL column values. | ||||||||||||||||
| Comment by Marko Mäkelä [ 2019-03-05 ] | ||||||||||||||||
|
The bug in MariaDB 10.3 only affects generated stored columns. For indexed virtual columns, we would use ALGORITHM=COPY because the ALTER_COLUMN_VCOL flag would be set in ha_alter_info->handler_flags. The bug in MariaDB 10.3 is not limited to ALTER IGNORE TABLE. It also occurs when sql_mode does not include either of STRICT_ALL_TABLES or STRICT_TRANS_TABLES. The bug is that the generated stored columns are not being recomputed when a NULL value in a base column is being replaced with something else. I believe that it is easiest to fall back to ALGORITHM=COPY in such cases. | ||||||||||||||||
| Comment by Marko Mäkelä [ 2019-03-05 ] | ||||||||||||||||
|
I merged the fixes up to 10.3 so far. Part of the problem in 10.3 and 10.4 remains to be fixed by |