Skip to content

Panic triggered at expression.ExplainExpressionList (planner/core/explain.go:335) #42587

@JZuming

Description

@JZuming

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

Setup the environment:

~/tidb/bin/tidb-server &
mysql -h "127.0.0.1" -u root -P 4000 -D testdb < mysql_bk.sql

mysql_bk.sql: mysql_bk.txt

Testcase

select  
  ref_39.c17 as c0
from 
  (t1 as ref_39
    left outer join t2 as ref_40
    on (ref_39.c13 = ref_40.vkey ))
where (case when exists (
              select  
                  ref_73.c9 as c0
                from 
                  t1 as ref_73
                union
                select  
                  null + 83 as c0
                from 
                  t6 as ref_77
                where (ref_40.pkey = null) and (2 > ( 
                  select 1 as c0
                    from 
                      t1 as ref_85
                    where exists (
                                select  
                                  ref_103.c25 as c0
                                from 
                                  t3 as ref_103
                                where ref_85.c13 = ref_103.c25 
                                ) 
                      limit 1
                  ))
                )  then null else 1 end
    ) >= 1;

2. What did you expect to see? (Required)

No panic.

3. What did you see instead (Required)

ERROR 1105 (HY000): runtime error: index out of range [0] with length 0

Log of TiDB server:

[ERROR] [conn.go:1039] ["connection running loop panic"] [conn=2199023260581] [lastSQL="select  
      ref_39.c17 as c0
    from 
      (t1 as ref_39
        left outer join t2 as ref_40
        on (ref_39.c13 = ref_40.vkey ))
    where (case when exists (
                  select  
                      ref_73.c9 as c0
                    from 
                      t1 as ref_73
                    union
                    select  
                      null + 83 as c0
                    from 
                      t6 as ref_77
                    where (ref_40.pkey = null) and (2 > ( 
                      select 1 as c0
                        from 
                          t1 as ref_85
                        where exists (
                                    select  
                                      ref_103.c25 as c0
                                    from 
                                      t3 as ref_103
                                    where ref_85.c13 = ref_103.c25 
                                   ) 
                         limit 1
                      ))
                   )  then null else 1 end
        ) >= 1"] [err="runtime error: index out of range [0] with length 0"] [stack="github.com/pingcap/tidb/server.(*clientConn).Run.func1
    /root/tidb/server/conn.go:1042
runtime.gopanic
    /usr/local/go/src/runtime/panic.go:884
runtime.goPanicIndex
    /usr/local/go/src/runtime/panic.go:113
github.com/pingcap/tidb/expression.ExplainExpressionList
    /root/tidb/expression/explain.go:122
github.com/pingcap/tidb/planner/core.(*PhysicalProjection).ExplainInfo
    /root/tidb/planner/core/explain.go:335
github.com/pingcap/tidb/planner/core.(*Explain).getOperatorInfo
    /root/tidb/planner/core/common_plans.go:1138
github.com/pingcap/tidb/planner/core.(*Explain).prepareOperatorInfo
    /root/tidb/planner/core/common_plans.go:1051
github.com/pingcap/tidb/planner/core.(*Explain).explainFlatOpInRowFormat
    /root/tidb/planner/core/common_plans.go:987
github.com/pingcap/tidb/planner/core.(*Explain).explainFlatPlanInRowFormat
    /root/tidb/planner/core/common_plans.go:936
github.com/pingcap/tidb/planner/core.(*Explain).RenderResult
    /root/tidb/planner/core/common_plans.go:888
github.com/pingcap/tidb/planner/core.GetExplainRowsForPlan
    /root/tidb/planner/core/common_plans.go:761
github.com/pingcap/tidb/session.(*session).SetProcessInfo
    /root/tidb/session/session.go:1545
github.com/pingcap/tidb/server.(*clientConn).dispatch.func2
    /root/tidb/server/conn.go:1297
runtime.gopanic
    /usr/local/go/src/runtime/panic.go:890
github.com/pingcap/tidb/executor.(*ExecStmt).Exec.func1
    /root/tidb/executor/adapter.go:459
runtime.gopanic
    /usr/local/go/src/runtime/panic.go:884
runtime.goPanicIndex
    /usr/local/go/src/runtime/panic.go:113
github.com/pingcap/tidb/expression.ExplainExpressionList
    /root/tidb/expression/explain.go:122
github.com/pingcap/tidb/planner/core.(*PhysicalProjection).ExplainInfo
    /root/tidb/planner/core/explain.go:335
github.com/pingcap/tidb/planner/core.(*Explain).getOperatorInfo
    /root/tidb/planner/core/common_plans.go:1138
github.com/pingcap/tidb/planner/core.(*Explain).prepareOperatorInfo
    /root/tidb/planner/core/common_plans.go:1051
github.com/pingcap/tidb/planner/core.(*Explain).explainFlatOpInRowFormat
    /root/tidb/planner/core/common_plans.go:987
github.com/pingcap/tidb/planner/core.(*Explain).explainFlatPlanInRowFormat
    /root/tidb/planner/core/common_plans.go:936
github.com/pingcap/tidb/planner/core.(*Explain).RenderResult
    /root/tidb/planner/core/common_plans.go:888
github.com/pingcap/tidb/planner/core.GetExplainRowsForPlan
    /root/tidb/planner/core/common_plans.go:761
github.com/pingcap/tidb/session.(*session).SetProcessInfo
    /root/tidb/session/session.go:1545
github.com/pingcap/tidb/executor.(*ExecStmt).Exec
    /root/tidb/executor/adapter.go:553
github.com/pingcap/tidb/session.runStmt
    /root/tidb/session/session.go:2332
github.com/pingcap/tidb/session.(*session).ExecuteStmt
    /root/tidb/session/session.go:2189
github.com/pingcap/tidb/server.(*TiDBContext).ExecuteStmt
    /root/tidb/server/driver_tidb.go:252
github.com/pingcap/tidb/server.(*clientConn).handleStmt
    /root/tidb/server/conn.go:2054
github.com/pingcap/tidb/server.(*clientConn).handleQuery
    /root/tidb/server/conn.go:1851
github.com/pingcap/tidb/server.(*clientConn).dispatch
    /root/tidb/server/conn.go:1337
github.com/pingcap/tidb/server.(*clientConn).Run
    /root/tidb/server/conn.go:1120
github.com/pingcap/tidb/server.(*Server).onConn
    /root/tidb/server/server.go:675"]

4. What is your TiDB version? (Required)

+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v7.1.0-alpha-27-gf5ca27ef3
Edition: Community
Git Commit Hash: f5ca27e
Git Branch: master
UTC Build Time: 2023-03-23 13:57:53
GoVersion: go1.20.2
Race Enabled: false
TiKV Min Version: 6.2.0-alpha
Check Table Before Drop: false
Store: unistore |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

Metadata

Metadata

Assignees

Labels

affects-7.1This bug affects the 7.1.x(LTS) versions.affects-7.5This bug affects the 7.5.x(LTS) versions.affects-8.1This bug affects the 8.1.x(LTS) versions.report/communityThe community has encountered this bug.severity/moderatesig/plannerSIG: Plannertype/bugThe issue is confirmed as a bug.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions