Skip to content

Commit

Permalink
tablecodec: fix text type decode for old row format (#23751) (#23772)
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-srebot authored May 11, 2021
1 parent 59cd283 commit b4c66ac
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tablecodec/tablecodec.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,11 +512,11 @@ func unflatten(datum types.Datum, ft *types.FieldType, loc *time.Location) (type
case mysql.TypeFloat:
datum.SetFloat32(float32(datum.GetFloat64()))
return datum, nil
case mysql.TypeVarchar, mysql.TypeString, mysql.TypeVarString:
case mysql.TypeVarchar, mysql.TypeString, mysql.TypeVarString, mysql.TypeTinyBlob,
mysql.TypeMediumBlob, mysql.TypeBlob, mysql.TypeLongBlob:
datum.SetString(datum.GetString(), ft.Collate)
case mysql.TypeTiny, mysql.TypeShort, mysql.TypeYear, mysql.TypeInt24,
mysql.TypeLong, mysql.TypeLonglong, mysql.TypeDouble, mysql.TypeTinyBlob,
mysql.TypeMediumBlob, mysql.TypeBlob, mysql.TypeLongBlob:
mysql.TypeLong, mysql.TypeLonglong, mysql.TypeDouble:
return datum, nil
case mysql.TypeDate, mysql.TypeDatetime, mysql.TypeTimestamp:
t := types.NewTime(types.ZeroCoreTime, ft.Tp, int8(ft.Decimal))
Expand Down
10 changes: 10 additions & 0 deletions tablecodec/tablecodec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,16 @@ func (s *testTableCodecSuite) TestUnflattenDatums(c *C) {
cmp, err := input[0].CompareDatum(sc, &output[0])
c.Assert(err, IsNil)
c.Assert(cmp, Equals, 0)

input = []types.Datum{types.NewCollationStringDatum("aaa", "utf8mb4_unicode_ci", 0)}
tps = []*types.FieldType{types.NewFieldType(mysql.TypeBlob)}
tps[0].Collate = "utf8mb4_unicode_ci"
output, err = UnflattenDatums(input, tps, sc.TimeZone)
c.Assert(err, IsNil)
cmp, err = input[0].CompareDatum(sc, &output[0])
c.Assert(err, IsNil)
c.Assert(cmp, Equals, 0)
c.Assert(output[0].Collation(), Equals, "utf8mb4_unicode_ci")
}

func (s *testTableCodecSuite) TestTimeCodec(c *C) {
Expand Down

0 comments on commit b4c66ac

Please sign in to comment.