Skip to content

Commit

Permalink
cherry pick: codec: Don't convert set or enum datum to float64 (pingc…
Browse files Browse the repository at this point in the history
…ap#32372)

close pingcap#32302

Signed-off-by: ekexium <ekexium@gmail.com>
  • Loading branch information
ekexium committed Feb 24, 2022
1 parent 1df538b commit da6a3fc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
1 change: 0 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,6 @@ github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQD
github.com/sasha-s/go-deadlock v0.2.0/go.mod h1:StQn567HiB1fF2yJ44N9au7wOhrPS3iZqiDbRupzT10=
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
github.com/sergi/go-diff v1.0.1-0.20180205163309-da645544ed44/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/shirou/gopsutil v2.19.10+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/shirou/gopsutil v3.20.12+incompatible h1:6VEGkOXP/eP4o2Ilk8cSsX0PhOEfX6leqAnD+urrp9M=
Expand Down
8 changes: 4 additions & 4 deletions util/codec/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ func EstimateValueSize(sc *stmtctx.StatementContext, val types.Datum) (int, erro
case types.KindMysqlDecimal:
l = valueSizeOfDecimal(val.GetMysqlDecimal(), val.Length(), val.Frac()) + 1
case types.KindMysqlEnum:
l = valueSizeOfUnsignedInt(uint64(val.GetMysqlEnum().ToNumber()))
l = valueSizeOfUnsignedInt(val.GetMysqlEnum().Value)
case types.KindMysqlSet:
l = valueSizeOfUnsignedInt(uint64(val.GetMysqlSet().ToNumber()))
l = valueSizeOfUnsignedInt(val.GetMysqlSet().Value)
case types.KindMysqlBit, types.KindBinaryLiteral:
val, err := val.GetBinaryLiteral().ToInt(sc)
terror.Log(errors.Trace(err))
Expand Down Expand Up @@ -351,7 +351,7 @@ func encodeHashChunkRowIdx(sc *stmtctx.StatementContext, row chunk.Row, tp *type
}
case mysql.TypeEnum:
flag = compactBytesFlag
v := uint64(row.GetEnum(idx).ToNumber())
v := row.GetEnum(idx).Value
str := ""
if enum, err := types.ParseEnumValue(tp.Elems, v); err == nil {
// str will be empty string if v out of definition of enum.
Expand Down Expand Up @@ -560,7 +560,7 @@ func HashChunkSelected(sc *stmtctx.StatementContext, h []hash.Hash64, chk *chunk
isNull[i] = !ignoreNull
} else {
buf[0] = compactBytesFlag
v := uint64(column.GetEnum(i).ToNumber())
v := column.GetEnum(i).Value
str := ""
if enum, err := types.ParseEnumValue(tp.Elems, v); err == nil {
// str will be empty string if v out of definition of enum.
Expand Down

0 comments on commit da6a3fc

Please sign in to comment.