-
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: fix alter table charset bug that change blob column type to text #10477
Conversation
/rebuild |
Codecov Report
@@ Coverage Diff @@
## master #10477 +/- ##
===============================================
- Coverage 78.354% 78.3403% -0.0137%
===============================================
Files 414 414
Lines 87730 87730
===============================================
- Hits 68740 68728 -12
- Misses 13849 13856 +7
- Partials 5141 5146 +5 |
ddl/table.go
Outdated
@@ -735,6 +735,9 @@ func onModifyTableCharsetAndCollate(t *meta.Meta, job *model.Job) (ver int64, _ | |||
tblInfo.Collate = toCollate | |||
// update column charset. | |||
for _, col := range tblInfo.Columns { | |||
if col.Charset == charset.CharsetBin { |
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.
We can use HasCharset
here.
@@ -735,7 +736,7 @@ func onModifyTableCharsetAndCollate(t *meta.Meta, job *model.Job) (ver int64, _ | |||
tblInfo.Collate = toCollate | |||
// update column charset. | |||
for _, col := range tblInfo.Columns { | |||
if typesNeedCharset(col.Tp) { | |||
if field_types.HasCharset(&col.FieldType) { |
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 guess typesNeedCharset
can be replaced by HasCharset
. Another code that calls this function is:
Line 299 in 5c21fa4
if typesNeedCharset(tp.Tp) { |
Can you confirm it here?
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.
No,
Line 299 in 5c21fa4
if typesNeedCharset(tp.Tp) { |
HasCharset
here may be got some error.
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.
so why you use HashCharset
finally?
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.
HashCharset
can be used here(ddl/table.go #739
), but ddl/ddl_api.go #299
should use typesNeedCharset
function.
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 still don't quite understand, why is it correct to change to HasCharset
?
/run-all-tests |
1 similar comment
/run-all-tests |
/rebuild |
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
However, obviously, we should not judge column type from their charsets. It should be corrected in some other PRs.
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
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
/run-all-tests |
/run-all-tests |
What problem does this PR solve?
Alter table charset will change
blob
column totext
column. just like below.Before
What is changed and how it works?
Check List
Tests
Code changes
Side effects
Related changes