[MDEV-27864] Alter table modify column for same data type copying table Created: 2022-02-16 Updated: 2023-05-02 Resolved: 2023-05-02 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | None |
| Affects Version/s: | 10.4.21 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Critical |
| Reporter: | Scott Sommerville (Inactive) | Assignee: | Alexander Barkov |
| Resolution: | Incomplete | Votes: | 3 |
| Labels: | alter, ddl, json | ||
| Environment: |
Amazon RDS |
||
| Attachments: |
|
||||||||||||||||
| Issue Links: |
|
||||||||||||||||
| Description |
|
The customer is observing the copying of the entire table when the DDL statement "alter table <table_name> modify column <column_name> json;" is ran against a table with an already existing data-type of JSON for the same column. I have recreated this in my local tests and have been able to compare with non JSON data-types where the table is not copied/recreated.
Conversely, I created another similar table, but this time with the data type of text and the recreation/copying of the table does not occur as shown below:
Therefore, there appears to be an issue for the 10.4.21 MariaDB Community edition where despite a field already being of a JSON data-type, the table is being recreated. This is proving problematic for the customer, as they have very large tables with the JSON data-type column and the resultant table recreation when the DDL statement is ran, is causing delays in their environment. |
| Comments |
| Comment by Sergei Petrunia [ 2022-03-28 ] | ||||||||||||||||||||||||||||||||||||||||||||||
|
Trying on 10.8:
It seems to have copied the table here.
If the column is already defined as JSON, it didn't. | ||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2022-05-10 ] | ||||||||||||||||||||||||||||||||||||||||||||||
|
I think that this needs to be fixed in a similar way to | ||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Alexander Barkov [ 2022-06-03 ] | ||||||||||||||||||||||||||||||||||||||||||||||
|
The test for a possible ALTER fails here in 10.4:
field->is_equal() returns:
The problem does not exist in 10.5. It was most likely fixed in 10.5 by this commit:
| ||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Alexander Barkov [ 2022-06-07 ] | ||||||||||||||||||||||||||||||||||||||||||||||
|
This script:
in 10.4.26 returns:
in 10.5.14 (also tested in 10.5.17) returns:
in 10.5.13 (an in 10.5.14 before the fix for
A temporary table for JSON->JSON conversion:
|