From 7e82fe3aa8790c811815d9689e391c0bcee6c06d Mon Sep 17 00:00:00 2001 From: tangenta Date: Mon, 20 Dec 2021 11:24:06 +0800 Subject: [PATCH] revert to_binary before insert for blob columns --- cmd/explaintest/r/new_character_set.result | 8 -------- cmd/explaintest/t/new_character_set.test | 7 ------- table/column.go | 11 ----------- 3 files changed, 26 deletions(-) diff --git a/cmd/explaintest/r/new_character_set.result b/cmd/explaintest/r/new_character_set.result index 7d4f61b481f5e..e48b58e4c8905 100644 --- a/cmd/explaintest/r/new_character_set.result +++ b/cmd/explaintest/r/new_character_set.result @@ -56,11 +56,3 @@ a hex(a) 中文 E4B8ADE69687 涓?枃 E6B6933FE69E83 set @@character_set_client = 'utf8mb4'; -drop table if exists t; -create table t(a blob(100)); -set names gbk; -insert into t values ("你好"); -select hex(a) from t; -hex(a) -E4BDA0E5A5BD -set names utf8mb4; diff --git a/cmd/explaintest/t/new_character_set.test b/cmd/explaintest/t/new_character_set.test index 380eb2c3efe57..8009ba73dae4b 100644 --- a/cmd/explaintest/t/new_character_set.test +++ b/cmd/explaintest/t/new_character_set.test @@ -39,10 +39,3 @@ prepare p1 from "insert into t values ('中文');"; execute p1; select a, hex(a) from t; set @@character_set_client = 'utf8mb4'; - -drop table if exists t; -create table t(a blob(100)); -set names gbk; -insert into t values ("你好"); -select hex(a) from t; -set names utf8mb4; \ No newline at end of file diff --git a/table/column.go b/table/column.go index 2fca1cc7942fe..d7e9a9ec5dadb 100644 --- a/table/column.go +++ b/table/column.go @@ -346,17 +346,6 @@ func validateStringDatum(ctx sessionctx.Context, origin, casted *types.Datum, co if fromBinary && toBinary { return nil } - if toBinary { - coll, err := charset.GetCollationByName(origin.Collation()) - if err != nil { - logutil.BgLogger().Warn("unknown collation", zap.Error(err)) - return nil - } - enc := charset.FindEncoding(coll.CharsetName) - replace, _ := enc.Transform(nil, casted.GetBytes(), charset.OpEncodeNoErr) - casted.SetBytesAsString(replace, charset.CollationUTF8MB4, 0) - return nil - } enc := charset.FindEncoding(col.Charset) // Skip utf8 check if possible. if enc.Tp() == charset.EncodingTpUTF8 && ctx.GetSessionVars().SkipUTF8Check {