Skip to content

Fail to parse an index key #16

@JaySon-Huang

Description

@JaySon-Huang
>  mok 748000000000001dffb25f698000000000ff00000c0380000000ff245c32c103800000ff0000000006038000ff00006818d60803d8ff00000008c904c300fe
panic: runtime error: index out of range [-8]

goroutine 1 [running]:
github.com/pingcap/tidb/types.DecimalBinSize(...)
	/Users/jayson/go/pkg/mod/github.com/pingcap/tidb@v1.1.0-beta.0.20220610072431-5d4745e9d415/types/mydecimal.go:1486
github.com/pingcap/tidb/types.(*MyDecimal).FromBin(0x14000511968?, {0x1400013c764?, 0x19d8?, 0x1020fdb28?}, 0x1020f05b8?, 0x18?)
	/Users/jayson/go/pkg/mod/github.com/pingcap/tidb@v1.1.0-beta.0.20220610072431-5d4745e9d415/types/mydecimal.go:1404 +0x798
github.com/pingcap/tidb/util/codec.DecodeDecimal({0x1400013c764, 0x10, 0x1c})
	/Users/jayson/go/pkg/mod/github.com/pingcap/tidb@v1.1.0-beta.0.20220610072431-5d4745e9d415/util/codec/decimal.go:59 +0x118
github.com/pingcap/tidb/util/codec.DecodeOne({0x1400013c761?, 0x1400013a160?, 0x14000511b48?})
	/Users/jayson/go/pkg/mod/github.com/pingcap/tidb@v1.1.0-beta.0.20220610072431-5d4745e9d415/util/codec/codec.go:833 +0x1d8
main.DecodeIndexValues(0x18?)
	/Users/jayson/Projects/myproj/mok/rules.go:133 +0xcc
main.(*Node).Expand(0x140000c68c0)
	/Users/jayson/Projects/myproj/mok/mok.go:68 +0x6c
main.(*Node).Expand(0x140000c67c0)
	/Users/jayson/Projects/myproj/mok/mok.go:70 +0xa4
main.(*Node).Expand(0x140000c6580)
	/Users/jayson/Projects/myproj/mok/mok.go:70 +0xa4
main.(*Node).Expand(0x140000c6540)
	/Users/jayson/Projects/myproj/mok/mok.go:70 +0xa4
main.(*Node).Expand(0x140000c6500)
	/Users/jayson/Projects/myproj/mok/mok.go:70 +0xa4
main.main()
	/Users/jayson/Projects/myproj/mok/main.go:41 +0x654

But this key can be parse by tidb_decode_key

TiDB root@10.2.12.81:test> select tidb_decode_key('748000000000001dffb25f698000000000ff00000c0380000000ff245c32c103800000ff0000000006038000ff00006818d60803d8ff00000008c904c300fe')
+---------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_decode_key('748000000000001dffb25f698000000000ff00000c0380000000ff245c32c103800000ff0000000006038000ff00006818d60803d8ff00000008c904c300fe') |
+---------------------------------------------------------------------------------------------------------------------------------------------------+
| {"index_id":12,"index_vals":"610022081, 6, 1746458120, 6341068275485050051","table_id":7602}                                                      |
+---------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set
Time: 0.011s
TiDB root@10.2.12.81:test> select tidb_version() \G;
***************************[ 1. row ]***************************
tidb_version() | Release Version: v9.0.0-alpha-386-gc902ad1
Edition: Community
Git Commit Hash: c902ad1f4cb7172f04af4c414400da2e3176a88f
Git Branch: HEAD
UTC Build Time: 2025-03-10 20:49:28
GoVersion: go1.23.7
Race Enabled: false
Check Table Before Drop: false
Store: tikv

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions