-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
ddl: allow more charset/collation modifications for database/table #10958
Conversation
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.
LGTM
Codecov Report
@@ Coverage Diff @@
## master #10958 +/- ##
===========================================
Coverage 81.0421% 81.0421%
===========================================
Files 419 419
Lines 89662 89662
===========================================
Hits 72664 72664
Misses 11750 11750
Partials 5248 5248 |
But we don't support case insensitive collate. |
if toCharset == charset.CharsetUTF8MB4 && origCharset == charset.CharsetUTF8 { | ||
if (origCharset == charset.CharsetUTF8 && toCharset == charset.CharsetUTF8MB4) || | ||
(origCharset == charset.CharsetUTF8 && toCharset == charset.CharsetUTF8) || | ||
(origCharset == charset.CharsetUTF8MB4 && toCharset == charset.CharsetUTF8MB4) { |
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 change is needless, because L2353 has check the case that toCharset is same with origCharset.
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.
hi @Deardrops L2353 is used to report the error message. If the check is passed(2346 ~ 2348), nil
will be returned, and the change is used to allow changing collate when the charset is not changed.
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.
Sorry I point out a wrong place before. Not in L2353, but in L2361, there is also a return nil
for the case that toCharset is same with origCharset.
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.
The code is that we allow changing the collation while keeping charset unchanged if the charset is utf8/utf8mb4.
Please check the test case https://github.com/pingcap/tidb/pull/10958/files/e23ba9e480618ed994f176cd4f7fdbb2f02b850d#diff-703ae6b7872b425273d1832c198598c8R1751 for this logic. @Deardrops
Some users complained that in TiDB, creating a table with some collations like |
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.
LGTM
I am not familiar with TiDB's charset. Since TiDB does not support case insensitive collation, would it be better to disallow the creation of |
Some of TiDB users need this syntax, but they don't really care whether the collation is case-insensitive. |
ddl/ddl_api.go
Outdated
if toCharset == charset.CharsetUTF8MB4 && origCharset == charset.CharsetUTF8 { | ||
if (origCharset == charset.CharsetUTF8 && toCharset == charset.CharsetUTF8MB4) || | ||
(origCharset == charset.CharsetUTF8 && toCharset == charset.CharsetUTF8) || | ||
(origCharset == charset.CharsetUTF8MB4 && toCharset == charset.CharsetUTF8MB4) { | ||
// TiDB only allow utf8 to be changed to utf8mb4. |
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.
Do we need to update this comment?
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.
Updated, PTAL @zimulala
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.
LGTM
e23ba9e
to
fc638a2
Compare
/rebuild |
/run-all-tests |
What problem does this PR solve?
Allow modifying collations of databases/tables when their charsets are utf8/utf8mb4.
For example, some TiDB users want to do the following things:
Before this PR, an error is returned:
This PR fixes this error.
What is changed and how it works?
Some limitation checks are loosed
Check List
Tests
Code changes
Related changes