[MDEV-6103] Adding/removing non-materialized virtual column triggers table recreation Created: 2014-04-15 Updated: 2014-06-04 Resolved: 2014-06-04 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | None |
| Affects Version/s: | 5.5.36, 10.0.10 |
| Fix Version/s: | 10.0.12 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Horst Schirmeier | Assignee: | Sergey Vojtovich |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
32-Bit Debian 7 |
||
| Attachments: |
|
||||||||
| Issue Links: |
|
||||||||
| Description |
|
When adding or removing a non-materialized virtual column to/from a MyISAM table with ALTER TABLE, MariaDB recreates the whole table although only the metadata should be affected:
This is especially annoying for multi-gigabyte tables, where this operation takes a long time. |
| Comments |
| Comment by Sergey Vojtovich [ 2014-05-29 ] | ||||||||||||
|
It came to be that MyISAM (and most probably Aria) reserves extra bits for virtual columns (NULL flag) in a physical record (the one that is written to disk). There should be no good reason to do so. E.g.: All in all it means physical record format changes when adding/dropping virtual columns and just relaxing table comparison function is not enough to fix this bug. I will attach partial fix for this bug shortly. InnoDB doesn't seem to be affected. | ||||||||||||
| Comment by Sergey Vojtovich [ 2014-05-29 ] | ||||||||||||
|
Sergei, please voice your suggestions. I see no simple solution for this bug. | ||||||||||||
| Comment by Sergei Golubchik [ 2014-05-31 ] | ||||||||||||
|
svoj As far as I understand, your patch fixes this issue for InnoDB and other storage engines that don't store MariaDB rows natively. While MyISAM and Aria still be affected? As far as the patch is concerned — it's pretty much ok. I don't see mysql-test/suite/vcol/r/vcol_non_stored_columns_myisam.result in it, and I'd suggest to move stored_in_db || is_in_partitioning_expr() into a separate inline helper function or method, but this is a minor detail. MyISAM/Aria — let's do it in a separate Jira issue, the fix would more intrusive and more risky, so it could only go into 10.1 not earlier. | ||||||||||||
| Comment by Sergey Vojtovich [ 2014-05-31 ] | ||||||||||||
|
serg My patch relaxes comparison function so that ADD/DROP virtual column is considered meta-data change. Such ALTER should work well with InnoDB, but it corrupts meta-data for MyISAM/Aria. In fact vcol_non_stored_columns_myisam fails with my patch. We could keep old behavior for MyISAM/Aria, but FWICS we'll have to hardcode it. | ||||||||||||
| Comment by Sergei Golubchik [ 2014-05-31 ] | ||||||||||||
|
You could add to ha_myisam::check_if_incompatible_data() the missing check — the one, that you removed from sql_table.cc:
| ||||||||||||
| Comment by Sergey Vojtovich [ 2014-05-31 ] | ||||||||||||
|
serg Indeed, I was confused by fact that Alter_info is not available there. But create_info should be just fine perform this check. | ||||||||||||
| Comment by Sergey Vojtovich [ 2014-06-02 ] | ||||||||||||
|
serg Hmm... it came to be that HA_CREATE_INFO doesn't store number of fields in altered definition. Should we extend HA_CREATE_INFO? | ||||||||||||
| Comment by Sergey Vojtovich [ 2014-06-02 ] | ||||||||||||
|
Removing 5.5 from "Fix versions": storage engines API of 5.5 is not flexible enough to solve this problem. | ||||||||||||
| Comment by Sergey Vojtovich [ 2014-06-03 ] | ||||||||||||
|
serg, please review fix for this bug. | ||||||||||||
| Comment by Sergei Golubchik [ 2014-06-03 ] | ||||||||||||
|
ok to push! | ||||||||||||
| Comment by Sergey Vojtovich [ 2014-06-04 ] | ||||||||||||
|
Fixed in 10.0.12:
| ||||||||||||
| Comment by Horst Schirmeier [ 2014-06-04 ] | ||||||||||||
|
Shouldn't this bug be split? As I understand, this issue is now fixed for InnoDB. I saw this issue with MyISAM, which is still affected. | ||||||||||||
| Comment by Sergey Vojtovich [ 2014-06-04 ] | ||||||||||||
|
See MDEV-6303. |