Skip to content

Commit

Permalink
add gbk_bin collation
Browse files Browse the repository at this point in the history
  • Loading branch information
xiongjiwei committed Jan 5, 2022
1 parent 6e75367 commit 74aa058
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5772,6 +5772,7 @@ func (s *testSuiteWithCliBaseCharsetNoNewCollation) TestCharsetFeature(c *C) {
"utf8_bin utf8 83 Yes Yes 1",
"gbk_bin gbk 87 Yes Yes 1",
))
tk.MustExec("create table t5(a char(20), b char(20) charset utf8, c binary) charset gbk collate gbk_bin;")
}

func (s *testSuiteWithCliBaseCharset) TestCharsetFeature(c *C) {
Expand Down Expand Up @@ -5828,6 +5829,7 @@ func (s *testSuiteWithCliBaseCharset) TestCharsetFeature(c *C) {
" `b` char(10) CHARACTER SET gbk COLLATE gbk_chinese_ci DEFAULT NULL\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin",
))
tk.MustExec("create table t5(a char(20), b char(20) charset utf8, c binary) charset gbk collate gbk_bin;")

tk.MustExec("create database test_gbk charset gbk;")
tk.MustExec("use test_gbk")
Expand Down
2 changes: 2 additions & 0 deletions util/collate/charset.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,15 @@ func addCharset() {
if NewCollationEnabled() {
charset.AddCharset(&charset.Charset{Name: charset.CharsetGBK, DefaultCollation: charset.CollationGBKChineseCI, Collations: make(map[string]*charset.Collation), Desc: "Chinese Internal Code Specification", Maxlen: 2})
charset.AddCollation(&charset.Collation{ID: 28, CharsetName: charset.CharsetGBK, Name: charset.CollationGBKChineseCI, IsDefault: true})
charset.AddCollation(&charset.Collation{ID: 87, CharsetName: charset.CharsetGBK, Name: charset.CollationGBKBin, IsDefault: false})

newCollatorMap[charset.CollationGBKBin] = &gbkBinCollator{charset.NewCustomGBKEncoder()}
newCollatorIDMap[CollationName2ID(charset.CollationGBKBin)] = &gbkBinCollator{charset.NewCustomGBKEncoder()}
newCollatorMap[charset.CollationGBKChineseCI] = &gbkChineseCICollator{}
newCollatorIDMap[CollationName2ID(charset.CollationGBKChineseCI)] = &gbkChineseCICollator{}
} else {
charset.AddCharset(&charset.Charset{Name: charset.CharsetGBK, DefaultCollation: charset.CollationGBKBin, Collations: make(map[string]*charset.Collation), Desc: "Chinese Internal Code Specification", Maxlen: 2})
charset.AddCollation(&charset.Collation{ID: 87, CharsetName: charset.CharsetGBK, Name: charset.CollationGBKBin, IsDefault: true})
charset.AddSupportedCollation(&charset.Collation{ID: 87, CharsetName: charset.CharsetGBK, Name: charset.CollationGBKBin, IsDefault: true})
}
}
Expand Down

0 comments on commit 74aa058

Please sign in to comment.