Skip to content
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

docs/design: add a proposal for full charsets support #27325

Merged
merged 9 commits into from Sep 9, 2021

Conversation

zimulala
Copy link
Contributor

What problem does this PR solve?

Issue Number: close #xxx

Problem Summary:

What is changed and how it works?

Add a proposal for full charsets support in TiDB.

Related issue: #26812

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Release note

None.

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Aug 18, 2021

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • kennytm
  • tangenta

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added release-note-none size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Aug 18, 2021
@zimulala zimulala added sig/sql-infra SIG: SQL Infra and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Aug 18, 2021
@zimulala zimulala mentioned this pull request Aug 18, 2021
35 tasks
@zimulala
Copy link
Contributor Author

The check_dev_2 test failed, created an issue: #27327

- Supports the use of `CAST`, `CONVERT` and other functions to convert gbk characters.
- Support SQL statements, such as: `SET CHARACTER SET GBK`, `SET NAMES GBK`, `SHOW CHARSET`, etc.
- It supports the comparison between strings in the gbk character set, as well as the comparison between gbk strings and strings in other character sets.
- There is no mapping between (U+D800, U+DFFF) and gbk. Attempting to convert code points in this range will return "?".
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it is talking about converting the surrogate code points from UTF8MB4 to GBK i don't know why they need to be singled out here. there are tons of real characters which is valid in UTF8MB4 but invalid in GBK e.g.

select 
    column_0 utf8mb4, 
    convert(column_0 using gbk) gbk, 
    convert(column_0 using gb18030) gb18030
from (values row('🤔'), row('ς'), row('σ')) _;
+---------+------+---------+
| utf8mb4 | gbk  | gb18030 |
+---------+------+---------+
| 🤔      | ?    | 🤔     |
| ς       | ?    | ς       |
| σ       | σ    | σ       |
+---------+------+---------+
3 rows in set (0.00 sec)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GB18030 is not GBK though

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docs/design/2021-08-18-charsets.md Outdated Show resolved Hide resolved
docs/design/2021-08-18-charsets.md Outdated Show resolved Hide resolved
docs/design/2021-08-18-charsets.md Outdated Show resolved Hide resolved
@ti-chi-bot ti-chi-bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Aug 20, 2021
@zimulala
Copy link
Contributor Author

PTAL @kennytm @tangenta

docs/design/2021-08-18-charsets.md Outdated Show resolved Hide resolved
docs/design/2021-08-18-charsets.md Show resolved Hide resolved
docs/design/2021-08-18-charsets.md Outdated Show resolved Hide resolved
docs/design/2021-08-18-charsets.md Outdated Show resolved Hide resolved
docs/design/2021-08-18-charsets.md Outdated Show resolved Hide resolved
docs/design/2021-08-18-charsets.md Show resolved Hide resolved
- TiKV
- Coprocessor related builtin functions need to be processed, and collation related functions need to be implemented.
- TiCDC
- It needs to be converted to gbk character set encoding when restoring the transaction downstream or outputting in accordance with the [TiCDC Open Protocol](https://docs.pingcap.com/zh/tidb/dev/ticdc-open-protocol).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the low-level storage of data is always utf8mb4,

when generating SQL, it is ok to just always write insert into x values (_utf8mb4'文字');.

for OpenProtocol it is up to debate, as JSON and Avro supports Unicode strings only (utf8mb4).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we don't need to do special treatment in TiCDC?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO no. But someone from the TiCDC team and/or business group should clarify if they want UTF-8-encoded data or native-charset-encoded data downstream for OpenProtocol.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TiCDC group will discuss this problem, and @overvenus will help reply later.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found Maxwell supports GBK (encoded in JSON) by outputing charset info and UTF8 data. https://github.com/zendesk/maxwell/blob/master/src/test/resources/sql/json/test_charsets

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But someone from the TiCDC team and/or business group should clarify if they want UTF-8-encoded data or native-charset-encoded data downstream for OpenProtocol.

@leoppro What do you think? Could you gather requirements from customers/business?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@overvenus the gbk, big5 and ujis in the test are just column names?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current discussion result: GBK support is not required for all JSON-based protocols, but the Canal protocol may need GBK support (@leoppro will help explain this after investigating).

According to the current conclusion, TiCDC may need special support for OpenProtocol, and other functions are basically not dealt with.

docs/design/2021-08-18-charsets.md Outdated Show resolved Hide resolved
docs/design/2021-08-18-charsets.md Outdated Show resolved Hide resolved
The third stage

- Basically support all string-related functions already supported by TiDB.
- Support the use of alter statement, support to modify the charset of the column.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this include modifying columns that are part of an index?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It needs to be included.

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Sep 8, 2021
@zimulala
Copy link
Contributor Author

zimulala commented Sep 9, 2021

PTAL @tangenta @xiongjiwei

@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Sep 9, 2021
@zimulala
Copy link
Contributor Author

zimulala commented Sep 9, 2021

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 9ac2433

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Sep 9, 2021
@ti-chi-bot
Copy link
Member

@zimulala: 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.

@zimulala
Copy link
Contributor Author

zimulala commented Sep 9, 2021

/run-check_dev_2

@ti-chi-bot ti-chi-bot merged commit 3714468 into pingcap:master Sep 9, 2021
@zimulala zimulala deleted the zimuxia/charset branch September 9, 2021 06:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note-none sig/sql-infra SIG: SQL Infra size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants