[MDEV-18584] Avoid copying when altering CHAR column in InnoDB table Created: 2019-02-14 Updated: 2022-11-09 |
|
| Status: | Confirmed |
| Project: | MariaDB Server |
| Component/s: | Data Definition - Alter Table, Storage Engine - InnoDB |
| Affects Version/s: | 10.4.3 |
| Fix Version/s: | 10.4 |
| Type: | Bug | Priority: | Major |
| Reporter: | Marko Mäkelä | Assignee: | Thirunarayanan Balathandayuthapani |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | instant, types | ||
| Issue Links: |
|
||||||||||||||||
| Description |
|
We do not allow instant character set changes of CHAR columns in InnoDB. Initially, we allowed it for ROW_FORMAT=REDUNDANT as part of In the DYNAMIC, COMPACT and COMPRESSED formats, CHAR columns could be instantly extended in those special cases when they are internally stored as variable-length:
For the REDUNDANT format, it is best to disallow such instantaneous changes for CHAR columns, and let them remain fixed-size, always explicitly storing the same length for every column. The mbminlen!=mbmaxlen optimization was introduced for COMPACT,DYNAMIC,COMPRESSED only. |
| Comments |
| Comment by Marko Mäkelä [ 2022-02-21 ] | |||||||||||||||||||||
|
If we implement this, we must be careful not to introduce any bug like | |||||||||||||||||||||
| Comment by Marko Mäkelä [ 2022-11-09 ] | |||||||||||||||||||||
|
I think that the changes would be around the following code:
The conditions that the patch is removing will have to be adapted and likely moved later within the function. The condition m_prebuilt->table->not_redundant() && new_type.char_length >= field->char_length() && }} must hold in this optimization. Additionally, either {{field_cs.mbminlen() < field_cs.mbmaxlen()) must hold or the column must be already long enough so that it is internally stored in a variable-length format. We must carefully review what happens when retrieving data from a variable-length stored CHAR column that is shorter than n*mbminlen bytes. If the data is being padded correctly, then there should be no issue with that. Also, as already noted, we must check what happens when an index is created on the full column or a prefix of it. |