Skip to content

DELETE ... PARTITION statement meets runtime error #62458

@fuboat

Description

@fuboat

Bug Report

DELETE ... PARTITION statement meets runtime error. It can be reproduced on the docker image pingcap/tidb:nightly.

1. Minimal reproduce step (Required)

CREATE TABLE t (c1 INT, c2 VARCHAR(255)) PARTITION BY LIST (c1) (PARTITION p1 VALUES IN (1, 2, 3), PARTITION p2 VALUES IN (4, 5, 6));
CREATE UNIQUE INDEX i ON t (c1);
DELETE FROM t PARTITION (p1) WHERE c1 = 15;

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

No runtime error.

3. What did you see instead (Required)

mysql> DELETE FROM t PARTITION (p1) WHERE c1 = 15;
ERROR 1105 (HY000): runtime error: index out of range [-1]

Logs:

[2025/07/16 13:51:38.626 +00:00] [ERROR] [conn.go:1047] ["connection running loop panic"] [conn=2097176] [session_alias=] 
[lastSQL="DELETE FROM t PARTITION (p1) WHERE c1 = 15"] 
[err="runtime error: index out of range [-1]"] 
github.com/pingcap/tidb/pkg/server.(*clientConn).Run.func1
        /workspace/source/tidb/pkg/server/conn.go:1050
runtime.gopanic
        /root/go/pkg/mod/golang.org/[email protected]/src/runtime/panic.go:791
github.com/pingcap/tidb/pkg/executor.(*ExecStmt).Exec.func1
        /workspace/source/tidb/pkg/executor/adapter.go:544
runtime.gopanic
        /root/go/pkg/mod/golang.org/[email protected]/src/runtime/panic.go:791
runtime.goPanicIndex
        /root/go/pkg/mod/golang.org/[email protected]/src/runtime/panic.go:115
github.com/pingcap/tidb/pkg/planner/core.isInExplicitPartitions
        /workspace/source/tidb/pkg/planner/core/point_get_plan.go:678
github.com/pingcap/tidb/pkg/planner/core.(*PointGetPlan).PrunePartitions
        /workspace/source/tidb/pkg/planner/core/point_get_plan.go:424
github.com/pingcap/tidb/pkg/executor.(*executorBuilder).buildPointGet
        /workspace/source/tidb/pkg/executor/point_get.go:59
github.com/pingcap/tidb/pkg/executor.(*executorBuilder).build
        /workspace/source/tidb/pkg/executor/builder.go:200
github.com/pingcap/tidb/pkg/executor.(*executorBuilder).buildDelete
        /workspace/source/tidb/pkg/executor/builder.go:2936
github.com/pingcap/tidb/pkg/executor.(*executorBuilder).build
        /workspace/source/tidb/pkg/executor/builder.go:192
github.com/pingcap/tidb/pkg/executor.(*ExecStmt).buildExecutor
        /workspace/source/tidb/pkg/executor/adapter.go:1283
github.com/pingcap/tidb/pkg/executor.(*ExecStmt).Exec
        /workspace/source/tidb/pkg/executor/adapter.go:624
github.com/pingcap/tidb/pkg/session.runStmt
        /workspace/source/tidb/pkg/session/session.go:2358
github.com/pingcap/tidb/pkg/session.(*session).ExecuteStmt
        /workspace/source/tidb/pkg/session/session.go:2210
github.com/pingcap/tidb/pkg/server.(*TiDBContext).ExecuteStmt
        /workspace/source/tidb/pkg/server/driver_tidb.go:291
github.com/pingcap/tidb/pkg/server.(*clientConn).handleStmt
        /workspace/source/tidb/pkg/server/conn.go:2038
github.com/pingcap/tidb/pkg/server.(*clientConn).handleQuery
        /workspace/source/tidb/pkg/server/conn.go:1794
github.com/pingcap/tidb/pkg/server.(*clientConn).dispatch
        /workspace/source/tidb/pkg/server/conn.go:1384
github.com/pingcap/tidb/pkg/server.(*clientConn).Run
        /workspace/source/tidb/pkg/server/conn.go:1153
github.com/pingcap/tidb/pkg/server.(*Server).onConn
        /workspace/source/tidb/pkg/server/server.go:740

4. What is your TiDB version? (Required)

Release Version: v9.0.0-beta.2.pre-118-g6ec4810
Edition: Community
Git Commit Hash: 6ec48101cae75529682a0f9fa8c16cbc42f246d3
Git Branch: HEAD
UTC Build Time: 2025-07-16 11:00:02
GoVersion: go1.23.11
Race Enabled: false
Check Table Before Drop: false
Store: unistore
Kernel Type: Classic

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions