MCPcopy Create free account
hub / github.com/pingcap/tidb / TestEncodeLargeSmallReuseBug

Function TestEncodeLargeSmallReuseBug

pkg/util/rowcodec/rowcodec_test.go:48–84  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

46}
47
48func TestEncodeLargeSmallReuseBug(t *testing.T) {
49 // reuse one rowcodec.Encoder.
50 var encoder rowcodec.Encoder
51 colFt := types.NewFieldType(mysql.TypeString)
52
53 largeColID := int64(300)
54 b, err := encoder.Encode(nil, []int64{largeColID}, []types.Datum{types.NewBytesDatum([]byte(""))}, nil, nil)
55 require.NoError(t, err)
56
57 bDecoder := rowcodec.NewDatumMapDecoder([]rowcodec.ColInfo{
58 {
59 ID: largeColID,
60 Ft: colFt,
61 IsPKHandle: false,
62 },
63 }, nil)
64 _, err = bDecoder.DecodeToDatumMap(b, nil)
65 require.NoError(t, err)
66
67 colFt = types.NewFieldType(mysql.TypeLonglong)
68 smallColID := int64(1)
69 b, err = encoder.Encode(nil, []int64{smallColID}, []types.Datum{types.NewIntDatum(2)}, nil, nil)
70 require.NoError(t, err)
71
72 bDecoder = rowcodec.NewDatumMapDecoder([]rowcodec.ColInfo{
73 {
74 ID: smallColID,
75 Ft: colFt,
76 IsPKHandle: false,
77 },
78 }, nil)
79 m, err := bDecoder.DecodeToDatumMap(b, nil)
80 require.NoError(t, err)
81
82 v := m[smallColID]
83 require.Equal(t, int64(2), v.GetInt64())
84}
85
86func TestDecodeRowWithHandle(t *testing.T) {
87 handleID := int64(-1)

Callers

nothing calls this directly

Calls 8

EncodeMethod · 0.95
DecodeToDatumMapMethod · 0.95
NewFieldTypeFunction · 0.92
NewBytesDatumFunction · 0.92
NewDatumMapDecoderFunction · 0.92
NewIntDatumFunction · 0.92
EqualMethod · 0.65
GetInt64Method · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…