[MDEV-15563] Instant failure-free data type conversions Created: 2018-03-14 Updated: 2023-12-19 Resolved: 2019-02-13 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Storage Engine - InnoDB |
| Fix Version/s: | 10.4.3 |
| Type: | Task | Priority: | Critical |
| Reporter: | Marko Mäkelä | Assignee: | Marko Mäkelä |
| Resolution: | Fixed | Votes: | 1 |
| Labels: | instant, online-ddl | ||
| Attachments: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Issue Links: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Description |
|
The original InnoDB record format (retroactively named ROW_FORMAT=REDUNDANT in MySQL 5.0.3) basically treats every column as variable-length and possibly NULL. That is why we can freely change those columns, by changing the metadata only. MariaDB 10.2 supports VARCHAR column extension, but only if the maximum length does not change from less than 256 to at least 256 bytes. For ROW_FORMAT=REDUNDANT we should support this unconditionally. Likewise, for ROW_FORMAT=REDUNDANT we can support the extension of any CHAR column, or converting VARCHAR to a CHAR that is at least as wide. We can also support converting INT to BIGINT and similar. Maybe also conversion from an unsigned integer to a signed wider integer (such as INT UNSIGNED to BIGINT), but this would require a change to the 'metadata row' format to indicate that the column originally was in unsigned format. To support instant conversion of CHAR to VARCHAR, we should store a flag in the
The above example would read 'a' from the column and not 'a '. TO BE DETERMINED: On secondary indexes of full columns (not column prefixes), do we have to rebuild the index when the length of a fixed-length column (CHAR, BINARY) is changed? |
| Comments |
| Comment by Marko Mäkelä [ 2018-09-20 ] | ||||||||||
|
When it comes to avoiding rebuilding secondary indexes, | ||||||||||
| Comment by Eugene Kosov (Inactive) [ 2018-10-24 ] | ||||||||||
|
Please, review a first part of an issue. | ||||||||||
| Comment by Marko Mäkelä [ 2018-10-31 ] | ||||||||||
|
The first part (NOT NULL to NULL) conversion looks mostly OK, except for one condition in the code. We must check the ROW_FORMAT from InnoDB dict_table_t, because it could be wrong in the .frm file. | ||||||||||
| Comment by Aleksey Midenkov [ 2018-11-04 ] | ||||||||||
|
Analysis is in progress for part 2: https://github.com/tempesta-tech/mariadb/issues/555 | ||||||||||
| Comment by Marko Mäkelä [ 2018-11-05 ] | ||||||||||
|
The first part (NOT NULL removal) was moved to MDEV-17520. | ||||||||||
| Comment by Marko Mäkelä [ 2018-12-11 ] | ||||||||||
|
I ported all generic changes from bb-10.4-MDEV-17520 to a new branch bb-10.4- | ||||||||||
| Comment by Matthias Leich [ 2018-12-13 ] | ||||||||||
|
| ||||||||||
| Comment by Marko Mäkelä [ 2018-12-13 ] | ||||||||||
|
I pushed bb-10.4- This task should no longer depend on MDEV-17520, if we change the course so that the most generic instant length and type changes are limited to ROW_FORMAT=REDUNDANT. For ROW_FORMAT=DYNAMIC and ROW_FORMAT=COMPACT, we should be able to do the following instantly, without changing the storage format:
| ||||||||||
| Comment by Marko Mäkelä [ 2019-02-13 ] | ||||||||||
|
I split this into 3 more commits: I decided to omit UNSIGNED-bigger-signed.patch | ||||||||||
| Comment by Marko Mäkelä [ 2019-02-18 ] | ||||||||||
|
The third change (instant fixed-size column extension for ROW_FORMAT=REDUNDANT) had to be reverted due to incorrect results for indexed columns, in |