-
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
ddl : fix column collate should use table's if it has when create table or alter table. #13119
ddl : fix column collate should use table's if it has when create table or alter table. #13119
Conversation
Codecov Report
@@ Coverage Diff @@
## master #13119 +/- ##
===========================================
Coverage ? 80.7511%
===========================================
Files ? 468
Lines ? 114417
Branches ? 0
===========================================
Hits ? 92393
Misses ? 15134
Partials ? 6890 |
/rebuild |
/run-unit-test |
ddl/db_change_test.go
Outdated
@@ -106,7 +111,12 @@ func (s *testStateChangeSuite) TestShowCreateTable(c *C) { | |||
currTestCaseOffset++ | |||
} | |||
if job.SchemaState != model.StatePublic { | |||
result := tk.MustQuery("show create table t") | |||
var result *testkit.Result | |||
if job.Query[12:14] == "t2" { |
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.
How about use t2 := testGetTableByName(c, tk.Se, "test", "t2")
then compare the job.TableID == t2.Meta().ID
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
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.
Nice idea.
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.
REST LGTM
ddl/db_change_test.go
Outdated
@@ -106,7 +111,12 @@ func (s *testStateChangeSuite) TestShowCreateTable(c *C) { | |||
currTestCaseOffset++ | |||
} | |||
if job.SchemaState != model.StatePublic { | |||
result := tk.MustQuery("show create table t") | |||
var result *testkit.Result | |||
if job.Query[12:14] == "t2" { |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
} | ||
} | ||
|
||
return tableCharset | ||
return tableCharset, tableCollate |
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 using two loops is more expressive when there is little impact on the performance.
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.
there is one loop with two if
judgment.
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
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 |
this pr need fix mysql_test as well |
/run-common-test |
/run-integration-common-test |
cherry pick to release-3.0 in PR #13174 |
cherry pick to release-3.1 in PR #13175 |
cherry pick to release-2.1 failed |
@@ -1759,18 +1768,30 @@ func resolveDefaultTableCharsetAndCollation(tbInfo *model.TableInfo, dbCharset s | |||
return | |||
} | |||
|
|||
func findTableOptionCharset(options []*ast.TableOption) string { | |||
var tableCharset string | |||
func findTableOptionCharsetAndCollate(options []*ast.TableOption) (tableCharset, tableCollate string) { |
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.
Please use this function instead:
Line 1841 in aaaf254
func getCharsetAndCollateInTableOption(startIdx int, options []*ast.TableOption) (ca, co string, err error) { |
I think we can remove findTableOptionCharsetAndCollate
…le or alter table. (pingcap#13119) fix column's collation should use table's collation
…le or alter table. (pingcap#13119) fix column's collation should use table's collation
It seems that, not for sure, we failed to cherry-pick this commit to release-2.1 release-3.0. Please comment '/run-cherry-picker' to try to trigger the cherry-picker if we did fail to cherry-pick this commit before. @AilinKid PTAL. |
What problem does this PR solve?
fix issue #13113
When creating a table, if we set a collate for this table, all columns in this table should use this collate instead of using default collates.
In MySQL:
In TiDB
What is changed and how it works?
Table's collate should be passed into
buildColumnsAndConstraints
when increate table or alter table
.Check List
Tests
Code changes
buildColumnsAndConstraints
function.Related changes
Release note