Skip to content

Commit

Permalink
codec: Don't convert set or enum datum to float64 (pingcap#32372)
Browse files Browse the repository at this point in the history
  • Loading branch information
ekexium committed Feb 24, 2022
1 parent e34e9e4 commit f6cc6f5
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions util/codec/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,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 @@ -355,11 +355,11 @@ func encodeHashChunkRowIdx(sc *stmtctx.StatementContext, row chunk.Row, tp *type
case mysql.TypeEnum:
if mysql.HasEnumSetAsIntFlag(tp.Flag) {
flag = uvarintFlag
v := uint64(row.GetEnum(idx).ToNumber())
v := row.GetEnum(idx).Value
b = (*[sizeUint64]byte)(unsafe.Pointer(&v))[:]
} else {
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 @@ -570,11 +570,11 @@ func HashChunkSelected(sc *stmtctx.StatementContext, h []hash.Hash64, chk *chunk
isNull[i] = !ignoreNull
} else if mysql.HasEnumSetAsIntFlag(tp.Flag) {
buf[0] = uvarintFlag
v := uint64(column.GetEnum(i).ToNumber())
v := column.GetEnum(i).Value
b = (*[sizeUint64]byte)(unsafe.Pointer(&v))[:]
} 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 Expand Up @@ -1326,9 +1326,9 @@ func HashCode(b []byte, d types.Datum) []byte {
decStr := d.GetMysqlDecimal().ToString()
b = encodeBytes(b, decStr, false)
case types.KindMysqlEnum:
b = encodeUnsignedInt(b, uint64(d.GetMysqlEnum().ToNumber()), false)
b = encodeUnsignedInt(b, d.GetMysqlEnum().Value, false)
case types.KindMysqlSet:
b = encodeUnsignedInt(b, uint64(d.GetMysqlSet().ToNumber()), false)
b = encodeUnsignedInt(b, d.GetMysqlSet().Value, false)
case types.KindMysqlBit, types.KindBinaryLiteral:
val := d.GetBinaryLiteral()
b = encodeBytes(b, val, false)
Expand Down

0 comments on commit f6cc6f5

Please sign in to comment.