From 19e0be40fe3690b0f09bd767734e3fcf5db4bd79 Mon Sep 17 00:00:00 2001 From: winkyao Date: Thu, 6 Dec 2018 20:32:29 +0800 Subject: [PATCH] [parser] charsert: make collation case insensitive (#66) --- parser/charset/charset.go | 1 + parser/charset/charset_test.go | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/parser/charset/charset.go b/parser/charset/charset.go index c42c13e4b09fc..0c0d3820efa56 100644 --- a/parser/charset/charset.go +++ b/parser/charset/charset.go @@ -94,6 +94,7 @@ func ValidCharsetAndCollation(cs string, co string) bool { if co == "" { return true } + co = strings.ToLower(co) _, ok = c.Collations[co] if !ok { return false diff --git a/parser/charset/charset_test.go b/parser/charset/charset_test.go index c400d97f183be..9492a562d6517 100644 --- a/parser/charset/charset_test.go +++ b/parser/charset/charset_test.go @@ -49,6 +49,12 @@ func (s *testCharsetSuite) TestValidCharset(c *C) { {"utf8", "utf8_invalid_ci", false}, {"utf16", "utf16_bin", false}, {"gb2312", "gb2312_chinese_ci", false}, + {"UTF8", "UTF8_BIN", true}, + {"UTF8", "utf8_bin", true}, + {"UTF8MB4", "utf8mb4_bin", true}, + {"UTF8MB4", "UTF8MB4_bin", true}, + {"UTF8MB4", "UTF8MB4_general_ci", true}, + {"Utf8", "uTf8_bIN", true}, } for _, tt := range tests { testValidCharset(c, tt.cs, tt.co, tt.succ)