Done
Details
Details
Assignee
Venkatesh Prasad
Venkatesh PrasadReporter
jinyou.ma
jinyou.maLabels
Needs QA
Yes
Sprint
None
Fix versions
Affects versions
Priority
Smart Checklist
Smart Checklist
Created May 1, 2024 at 1:33 AM
Updated August 29, 2024 at 12:19 PM
Resolved June 17, 2024 at 6:47 AM
Description
When MySQL converts the charset collation on a table, it converts the date and time data types columns in ibd file. The collation_id in the ibd does not match that of data dictionary.
the table structure is below
mysql> CREATE TABLE test.a ( a datetime ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_as_ci;
shell> ibd2sdi /var/lib/mysql/test/a.ibd | jq '.[1].object.dd_object.columns[0]' | grep collation_id "collation_id": 8,
after converting the charset collation, the collation_id becomes 224 (
utf8mb4_unicode_ci
)mysql> ALTER TABLE test.a CONVERT TO CHARACTER SET utf8mb4 collate utf8mb4_unicode_ci; shell> ibd2sdi /var/lib/mysql/test/a.ibd | jq '.[1].object.dd_object.columns[0]' | grep collation_id "collation_id": 224,
when coping the table to a new table, the collation_id of the new table is 8 (
latin1_swedish_ci
)mysql> create table test.b like test.a; shell> ibd2sdi /var/lib/mysql/test/b.ibd | jq '.[1].object.dd_object.columns[0]' | grep collation_id "collation_id": 8,
After altering table, the the collation_id becomes 8 (
latin1_swedish_ci
)mysql> ALTER TABLE test.a ENGINE = INNODB; shell> ibd2sdi /var/lib/mysql/test/a.ibd | jq '.[1].object.dd_object.columns[0]' | grep collation_id "collation_id": 8,
Reproduce
CREATE DATABASE test; CREATE TABLE test.a ( a datetime ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_as_ci; ALTER TABLE test.a CONVERT TO CHARACTER SET utf8mb4 collate utf8mb4_unicode_ci;