Skip to content

[Bug]: DELETE FROM ... PARTITION ignores the partition list and deletes every row #28312

Closed as not planned

Description

@XuPeng-SH

MatrixOne version

4fdb9e91615f9fc37703039ae28a47849206d1d6 (latest main when reproduced), Linux/amd64 standalone launch deployment.

What happened?

The parser accepts the single-table MySQL form DELETE FROM t PARTITION (p0), but the delete planner does not consume tree.Delete.PartitionNames. The delete source therefore scans the whole logical table and every row is deleted.

This was found while challenging #28309/#28310 with adjacent delete-scope restrictions. #28310 deliberately prevents partition-restricted statements from being classified as unrestricted/truncatable, but it does not implement partition pruning; this issue needs its own planner/storage design.

Reproduction

drop database if exists delete_partition_scope;
create database delete_partition_scope;
use delete_partition_scope;

create table p(
  id int primary key,
  body text
) partition by hash(id) partitions 2;

insert into p values
  (1, 'odd token'),
  (2, 'even token'),
  (3, 'odd three');

delete from p partition(p0);
select id from p order by id;

Actual behavior

The final SELECT returns no rows: rows outside p0 are also deleted.

Expected behavior

Only rows in the named partition are eligible for deletion. If partition-qualified DELETE is not supported, planning must reject it explicitly before mutation; it must never silently widen the delete set.

Root-cause direction

  • pkg/sql/parsers/tree/delete.go stores PartitionNames.
  • The MySQL grammar populates it for single-table DELETE.
  • The ordinary delete planning paths do not turn the list into a partition-restricted scan/filter.

A systematic fix should make the partition list part of the delete row-selection contract, validate unknown/duplicate partition names, preserve index/FK maintenance for only selected rows, and cover hash/range/list plus empty/multi-partition cases.

Activity

  1. added
    kind/bug
    on Sep 7, 2026
  2. added
    no-pr-linked
    on Sep 7, 2026
  3. added
    kind/refactor
    and removed
    no-pr-linked
    kind/refactor
    on Sep 7, 2026
  4. iamlinjunhong commented on Sep 7, 2026

    @iamlinjunhong
    Contributor

    当前 partition 需要重构,暂时不修复

  5. XuPeng-SH commented on Oct 25, 2026

    @XuPeng-SH
    ContributorAuthor

    Consolidated into #31084.

    Both reports concern an explicit PARTITION(...) target accepted and then ignored by DML. The active tracker now includes this DELETE reproducer, while retaining independent acceptance for DELETE source-row selection and INSERT/REPLACE destination eligibility. The planner paths differ; one branch's fix is not evidence that the others are fixed.

    #31084 retains the same owner and its existing severity/s1. This older deferred entry is closed for consolidated tracking only; the defect remains open in #31084.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

deferredkind/bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions