Skip to content

Commit

Permalink
revert to_binary before insert for blob columns
Browse files Browse the repository at this point in the history
  • Loading branch information
tangenta committed Dec 20, 2021
1 parent 1cc6321 commit 7e82fe3
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 26 deletions.
8 changes: 0 additions & 8 deletions cmd/explaintest/r/new_character_set.result
Original file line number Diff line number Diff line change
Expand Up @@ -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;
7 changes: 0 additions & 7 deletions cmd/explaintest/t/new_character_set.test
Original file line number Diff line number Diff line change
Expand Up @@ -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;
11 changes: 0 additions & 11 deletions table/column.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 7e82fe3

Please sign in to comment.