Skip to content

Commit

Permalink
cherry pick pingcap#31309 to release-5.4
Browse files Browse the repository at this point in the history
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
  • Loading branch information
xiongjiwei authored and ti-srebot committed Apr 26, 2022
1 parent 11dbb91 commit 7a7bcc1
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions util/collate/charset.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,40 @@ func switchDefaultCollation(flag bool) {
} else {
charset.CharacterSetInfos[charset.CharsetGBK].DefaultCollation = charset.CollationGBKBin
}
<<<<<<< HEAD
charset.CharacterSetInfos[charset.CharsetGBK].Collations[charset.CollationGBKBin].IsDefault = !flag
charset.CharacterSetInfos[charset.CharsetGBK].Collations[charset.CollationGBKChineseCI].IsDefault = flag
=======
}

// CharsetFeatEnabled return true if charset feature is enabled.
func CharsetFeatEnabled() bool {
return enableCharsetFeat
}

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})
}
}

func removeCharset() {
charset.RemoveCharset(charset.CharsetGBK)
delete(newCollatorMap, charset.CollationGBKBin)
delete(newCollatorIDMap, CollationName2ID(charset.CollationGBKBin))

delete(newCollatorMap, charset.CollationGBKChineseCI)
delete(newCollatorIDMap, CollationName2ID(charset.CollationGBKChineseCI))
>>>>>>> 29c398cbc... charset: add gbk_bin collation into gbk charaset (#31309)
}

0 comments on commit 7a7bcc1

Please sign in to comment.