From 74aa0583ef5d4cd6c8076baffaecee7b2b540f0a Mon Sep 17 00:00:00 2001 From: xiongjiwei Date: Wed, 5 Jan 2022 11:25:37 +0800 Subject: [PATCH] add gbk_bin collation --- executor/executor_test.go | 2 ++ util/collate/charset.go | 2 ++ 2 files changed, 4 insertions(+) diff --git a/executor/executor_test.go b/executor/executor_test.go index 27e5d4f972342..7b2db6a57e8e1 100644 --- a/executor/executor_test.go +++ b/executor/executor_test.go @@ -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) { @@ -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") diff --git a/util/collate/charset.go b/util/collate/charset.go index cc82c0e85db41..581736f623678 100644 --- a/util/collate/charset.go +++ b/util/collate/charset.go @@ -48,6 +48,7 @@ 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()} @@ -55,6 +56,7 @@ func addCharset() { 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}) } }