Skip to content

fix(plan): support modern multi-target updates - #26462

Draft
ck89119 wants to merge 15 commits into
matrixorigin:mainfrom
ck89119:issue-26340-main
Draft

fix(plan): support modern multi-target updates#26462
ck89119 wants to merge 15 commits into
matrixorigin:mainfrom
ck89119:issue-26340-main

Conversation

@ck89119

@ck89119 ck89119 commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

fixes #26340

What this PR does / why we need it:

Multi-target UPDATE statements were still routed to the legacy planner because
the modern path could not independently deduplicate and filter rows for each
updated table. A shared source row may represent a valid target row for one
table and a duplicate or outer-join NULL row for another.

This change:

  • routes multi-target UPDATE statements through the modern MULTI_UPDATE
    path;
  • adds an independent row_number() selector for each physical target Rowid;
  • shares each target's filtered batch with its base, unique-index, and
    secondary-index write contexts in both table and S3 writers;
  • guards primary-key and unique-index DEDUP keys so unselected duplicate source
    rows do not trigger false duplicate-key errors;
  • preserves valid rows from other targets when a multi-target outer join has no
    old secondary-index row for one target;
  • carries the selector ownership through protobuf, remote execution, deep-copy,
    and partition-clone paths; and
  • adds planner, executor, serialization, partition, and distributed regression
    coverage.

Validation:

  • mo-cgo-test ./pkg/sql/plan -count=1
  • mo-cgo-test ./pkg/sql/colexec/multi_update -count=1
  • mo-cgo-test ./pkg/sql/compile -count=1
  • mo-cgo-test ./pkg/sql/plan -race -count=1
  • isolated mo-tester BVT: 17/17 statements passed
  • make build
  • make static-check
  • git diff --check

@matrix-meow matrix-meow added size/XXL Denotes a PR that changes 2000+ lines and removed size/XL Denotes a PR that changes [1000, 1999] lines labels Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working size/XXL Denotes a PR that changes 2000+ lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Subtask]: Move multi-target UPDATE semantics to MULTI_UPDATE

2 participants