runtime error: index out of range [0] with length 0 #38323
Closed
Description
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
create table t(id int, k int);
prepare stmt from "explain select * from t where id = ? and k = ? group by id, k";
2. What did you expect to see? (Required)
No error
3. What did you see instead (Required)
ERROR 1105 (HY000): runtime error: index out of range [0] with length 0
The stack
stack="github.com/pingcap/tidb/server.(*clientConn).Run.func1
/Users/yanchengpeng/go/src/github.com/pingcap/tidb/server/conn.go:1042
runtime.gopanic
/usr/local/opt/go/libexec/src/runtime/panic.go:890
github.com/pingcap/tidb/executor.(*ExecStmt).Exec.func1
/Users/yanchengpeng/go/src/github.com/pingcap/tidb/executor/adapter.go:437
runtime.gopanic
/usr/local/opt/go/libexec/src/runtime/panic.go:890
runtime.goPanicIndex
/usr/local/opt/go/libexec/src/runtime/panic.go:113
github.com/pingcap/tidb/expression.(*ParamMarker).GetUserVar
/Users/yanchengpeng/go/src/github.com/pingcap/tidb/expression/constant.go:91
github.com/pingcap/tidb/expression.(*Constant).getLazyDatum
/Users/yanchengpeng/go/src/github.com/pingcap/tidb/expression/constant.go:187
github.com/pingcap/tidb/expression.(*Constant).Eval
/Users/yanchengpeng/go/src/github.com/pingcap/tidb/expression/constant.go:197
github.com/pingcap/tidb/planner/core.getNameValuePairs
/Users/yanchengpeng/go/src/github.com/pingcap/tidb/planner/core/point_get_plan.go:1314
github.com/pingcap/tidb/planner/core.getNameValuePairs
/Users/yanchengpeng/go/src/github.com/pingcap/tidb/planner/core/point_get_plan.go:1288
github.com/pingcap/tidb/planner/core.tryPointGetPlan
/Users/yanchengpeng/go/src/github.com/pingcap/tidb/planner/core/point_get_plan.go:1002
github.com/pingcap/tidb/planner/core.TryFastPlan
/Users/yanchengpeng/go/src/github.com/pingcap/tidb/planner/core/point_get_plan.go:519
github.com/pingcap/tidb/planner.Optimize
/Users/yanchengpeng/go/src/github.com/pingcap/tidb/planner/optimize.go:154
github.com/pingcap/tidb/planner/core.(*PlanBuilder).buildExplain
/Users/yanchengpeng/go/src/github.com/pingcap/tidb/planner/core/planbuilder.go:4686
github.com/pingcap/tidb/planner/core.(*PlanBuilder).Build
/Users/yanchengpeng/go/src/github.com/pingcap/tidb/planner/core/planbuilder.go:767
github.com/pingcap/tidb/planner/core.GeneratePlanCacheStmtWithAST
/Users/yanchengpeng/go/src/github.com/pingcap/tidb/planner/core/plan_cache_utils.go:135
github.com/pingcap/tidb/executor.(*PrepareExec).Next
/Users/yanchengpeng/go/src/github.com/pingcap/tidb/executor/prepared.go:120
github.com/pingcap/tidb/executor.Next
/Users/yanchengpeng/go/src/github.com/pingcap/tidb/executor/executor.go:324
github.com/pingcap/tidb/executor.(*ExecStmt).next
/Users/yanchengpeng/go/src/github.com/pingcap/tidb/executor/adapter.go:987
github.com/pingcap/tidb/executor.(*ExecStmt).handleNoDelayExecutor
/Users/yanchengpeng/go/src/github.com/pingcap/tidb/executor/adapter.go:761
github.com/pingcap/tidb/executor.(*ExecStmt).handleNoDelay
/Users/yanchengpeng/go/src/github.com/pingcap/tidb/executor/adapter.go:609
github.com/pingcap/tidb/executor.(*ExecStmt).Exec
/Users/yanchengpeng/go/src/github.com/pingcap/tidb/executor/adapter.go:538
github.com/pingcap/tidb/session.runStmt
/Users/yanchengpeng/go/src/github.com/pingcap/tidb/session/session.go:2213
github.com/pingcap/tidb/session.(*session).ExecuteStmt
/Users/yanchengpeng/go/src/github.com/pingcap/tidb/session/session.go:2077
github.com/pingcap/tidb/server.(*TiDBContext).ExecuteStmt
/Users/yanchengpeng/go/src/github.com/pingcap/tidb/server/driver_tidb.go:231
github.com/pingcap/tidb/server.(*clientConn).handleStmt
/Users/yanchengpeng/go/src/github.com/pingcap/tidb/server/conn.go:2049
github.com/pingcap/tidb/server.(*clientConn).handleQuery
/Users/yanchengpeng/go/src/github.com/pingcap/tidb/server/conn.go:1904
github.com/pingcap/tidb/server.(*clientConn).dispatch
/Users/yanchengpeng/go/src/github.com/pingcap/tidb/server/conn.go:1359
github.com/pingcap/tidb/server.(*clientConn).Run
/Users/yanchengpeng/go/src/github.com/pingcap/tidb/server/conn.go:1104
github.com/pingcap/tidb/server.(*Server).onConn
/Users/yanchengpeng/go/src/github.com/pingcap/tidb/server/server.go:563"
4. What is your TiDB version? (Required)
latest master