Fix the issue where the CHARSET cannot be retrieved in OceanBase. #881
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
An error occurred while I was using pt-archiver to migrate data from MySQL to OceanBase: "Character set mismatch: --dest DSN uses utf8mb4, table uses . ". It seems that pt-archiver did not correctly detect the character set of the destination database.
I noticed that the format of DDL statements in OceanBase differs slightly from that in MySQL. In MySQL, the output of the SHOW CREATE TABLE command shows the character set without spaces around the equals sign (e.g., CHARSET=utf8mb4). In contrast, OceanBase shows the character set with spaces around the equals sign (e.g., CHARSET = utf8mb4).
To resolve this issue, I modified the regular expression used for matching the character set, and the migration was successful.
mysql DDL statement
mysql> show create table t3;
+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| t3 | CREATE TABLE
t3
(id
int(11) NOT NULL AUTO_INCREMENT,name
varchar(20) DEFAULT NULL,PRIMARY KEY (
id
)) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 |
+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
OceanBase DDL statement
obclient [sun_test]> show create table t3;
+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| t3 | CREATE TABLE
t3
(id
int(11) NOT NULL AUTO_INCREMENT,name
varchar(20) DEFAULT NULL,PRIMARY KEY (
id
)) AUTO_INCREMENT = 2 DEFAULT CHARSET = utf8mb4 ROW_FORMAT = DYNAMIC |
+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.005 sec)