-
Notifications
You must be signed in to change notification settings - Fork 5.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
types: convert to new charset before inserting to blob or json column #31031
Conversation
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
/run-check_dev_2 |
@@ -5,7 +5,7 @@ insert into t values ('中文', 'asdf', '字符集'); | |||
insert into t values ('À', 'ø', '😂'); | |||
Error 1366: Incorrect string value '\xC3\x80' for column 'a' | |||
insert into t values ('中文À中文', 'asdføfdsa', '字符集😂字符集'); | |||
Error 1366: Incorrect string value '\xC3\x80\xE4\xB8\xAD\xE6...' for column 'a' | |||
Error 1366: Incorrect string value '\xC3\x80' for column 'a' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not same as MySQL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is OK to have this difference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Em... Not sure. Seems we had a PR to fix it before. #25087
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR does not introduce the garbled code as described in #25087. It extracts the error message from ErrInvalidCharacterSet
(which should be in a well format).
The only difference is the number of invalid bytes displayed.
mysql> create table t (a bit(45));
Query OK, 0 rows affected (0.02 sec)
mysql> insert into t values (117471723421);
Query OK, 1 row affected (0.01 sec)
mysql> alter table t modify column a varchar(31) collate utf8mb4_general_ci;
Query OK, 1 row affected (0.05 sec)
Records: 1 Duplicates: 0 Warnings: 0
mysql> select * from t;
+--------------+
| a |
+--------------+
| 117471723421 |
+--------------+
1 row in set (0.03 sec) We can see that even if non-binary string, the
|
/merge |
This pull request has been accepted and is ready to merge. Commit hash: 0c00650
|
/run-unit-test
|
/run-unit-test
|
/merge |
This pull request has been accepted and is ready to merge. Commit hash: d96bcde
|
@tangenta: Your PR was out of date, I have automatically updated it for you. At the same time I will also trigger all tests for you: /run-all-tests If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
/run-unit-test because it is timeout. |
/run-unit-test |
What problem does this PR solve?
Issue Number: close #30690
Problem Summary:
The expected insertion procedure for TiDB is:
'你好'
is parsed with GBK(because of the@@character_set_client
), resulting a UTF-8 string'浣犲ソ'
datum annotated with "gbk_bin"(because of the@@character_set_connection
).'浣犲ソ'
should be changed back to'你好'
.Previously, step 2 is missed for type blob and json, this PR fix the issue.
What is changed and how it works?
This PR also moves string encoding/decoding/validation to
Datum.ConvertTo()
.Check List
Tests
Side effects
Documentation
Release note