From f998c6e40a2cd6d3065873f5751b8169dba5eca1 Mon Sep 17 00:00:00 2001 From: tangenta Date: Fri, 19 Nov 2021 23:05:37 +0800 Subject: [PATCH] add test for DecodeRowKey --- tablecodec/tablecodec_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tablecodec/tablecodec_test.go b/tablecodec/tablecodec_test.go index 554287b8dc6a7..e373eadba33b9 100644 --- a/tablecodec/tablecodec_test.go +++ b/tablecodec/tablecodec_test.go @@ -46,6 +46,20 @@ func TestTableCodec(t *testing.T) { require.Equal(t, int64(2), h.IntValue()) } +// https://github.com/pingcap/tidb/issues/27687. +func TestTableCodecInvalid(t *testing.T) { + tableID := int64(100) + buf := make([]byte, 0, 11) + buf = append(buf, 't') + buf = codec.EncodeInt(buf, tableID) + buf = append(buf, '_', 'r') + buf = codec.EncodeInt(buf, -9078412423848787968) + buf = append(buf, '0') + _, err := DecodeRowKey(buf) + require.NotNil(t, err) + require.Equal(t, "invalid encoded key", err.Error()) +} + // column is a structure used for test type column struct { id int64