Repository navigation
fix(sql): preserve same-table update alias semantics - #26927
Conversation
# Conflicts: # pkg/common/moerr/error.go # pkg/pb/pipeline/pipeline.pb.go # pkg/pb/plan/plan.pb.go # pkg/sql/colexec/multi_update/multi_update.go # pkg/sql/colexec/multi_update/multi_update_partition.go # pkg/sql/colexec/multi_update/multi_update_partition_test.go # pkg/sql/colexec/multi_update/s3writer_delegate.go # pkg/sql/colexec/multi_update/types.go # pkg/sql/colexec/multi_update/update_test.go # pkg/sql/compile/operator.go # pkg/sql/compile/remoterun.go # pkg/sql/compile/remoterun_test.go # pkg/sql/plan/bind_update.go # pkg/sql/plan/bind_update_fk.go # pkg/sql/plan/build_test.go # pkg/sql/plan/deepcopy.go # pkg/sql/plan/deepcopy_test.go # pkg/sql/plan/query_builder.go # proto/plan.proto # test/distributed/cases/dml/update/update_multi_target_modern.result # test/distributed/cases/dml/update/update_multi_target_modern.sql # test/distributed/cases/foreign_key/fk_self_refer3.result
aptend
left a comment
There was a problem hiding this comment.
[P2] Reject repeated-alias partition-key updates
validateRepeatedPhysicalTargetPrimaryKeyUpdate only scans tableDef.Pkey.Names, although ER 1706 also forbids changing a partition key when the same physical table is updated through multiple aliases. A table without a primary key makes the hole easy to reproduce:
create table pt(id int, p int, x int)
partition by range(p) (
partition p0 values less than (10),
partition p1 values less than (maxvalue)
);
insert into pt values (1,1,0);
update pt a join pt b on a.id=b.id set a.p=11,b.x=2;At this head MatrixOne accepts the statement and produces (1,11,2), moving the row between partitions. MySQL rejects it with ER_MULTI_UPDATE_KEY_CONFLICT (1706): “Primary key/partition key update is not allowed since the table is updated both as a and b.” Please include every column used by the partition expression (not only PK names) in this repeated-physical-target validation, and add a regression for a partition key that is not a primary key.
# Conflicts: # pkg/common/moerr/error.go
aptend
left a comment
There was a problem hiding this comment.
Deep re-review completed on exact head 28c52e47d64cfe31936cd098d10e7f110f19bce9, incorporating the prior same-table-alias review history. No blocking findings remain. The previous partition-key hole is closed: repeated physical targets now build the protected set from both primary-key names and every column reference reachable through the stored partition routing expressions, including non-primary and composite expression inputs, before checking each alias assignment. The explicit UPDATE IGNORE and unrelated-column controls cover the important routing decisions.
Validation: the complete diff passes git diff --check; the focused primary-key and partition-expression rejection suites passed for 20 repetitions under the controlled CGo environment. Exact-head CI build and PR validation are green; the remaining jobs were still running at review time.
aunjgr
left a comment
There was a problem hiding this comment.
Reviewed current head 28c52e. Repeated physical-target protection now covers primary keys and partition-routing columns, propagates the update context through planning/execution/remote serialization, and the added DML/regression coverage exercises the protected paths. No additional blocking finding.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review completed on exact head 28c52e47d64cfe31936cd098d10e7f110f19bce9. No blocking correctness, lifecycle, concurrency, or protocol issue found.
I traced the same-physical-row state machine through alias-local source-tuple selection, greedy UPDATE IGNORE acceptance/fallback, final generated/CHECK/FK/UNIQUE validation, physical Rowid deduplication, per-alias affected-row accounting, partition routing, plan remapping/deep copy, and v22 remote serialization. The previous partition-key gap is closed for both primary-key parts and columns referenced by stored partition expressions; RIGHT/NATURAL RIGHT ordering and mixed repeated/singleton targets retain deterministic table-list semantics. The retained Rowid state is freed on Reset/Free and the S3 path remains memory-admitted.
Validation: complete diff is git diff --check clean; focused repeated-target planner, selector/filtering, partition, and remote-protocol tests passed under -race -count=10 in the controlled CGo environment.
Merge Queue Status
This pull request spent 1 hour 52 minutes 50 seconds in the queue, with no time running CI. ReasonThe pull request can't be updated
HintYou should update or rebase your pull request manually. If you do, this pull request will automatically be requeued once the queue conditions match again. Requeued — the merge queue status continues in this comment ↓. |
# Conflicts: # pkg/defines/const.go
Merge Queue Status
This pull request spent 1 hour 26 minutes 33 seconds in the queue, with no time running CI. ReasonThe pull request can't be updated
HintYou should update or rebase your pull request manually. If you do, this pull request will automatically be requeued once the queue conditions match again. Requeued — the merge queue status continues in this comment ↓. |
# Conflicts: # pkg/pb/plan/plan.pb.go
Merge Queue Status
This pull request spent 4 hours 20 minutes 32 seconds in the queue, with no time running CI. Waiting for
All conditions
ReasonThe merge conditions cannot be satisfied due to failing checks Failing checks:
HintYou may have to fix your CI before adding the pull request to the queue again. Requeued — the merge queue status continues in this comment ↓. |
Merge Queue Status
This pull request spent 1 hour 17 minutes 52 seconds in the queue, with no time running CI. Waiting for
All conditions
ReasonThe merge conditions cannot be satisfied due to failing checks Failing checks:
HintYou may have to fix your CI before adding the pull request to the queue again. Requeued — the merge queue status continues in this comment ↓. |
Merge Queue Status
This pull request spent 42 minutes 52 seconds in the queue, with no time running CI. Waiting for
All conditions
ReasonThe merge conditions cannot be satisfied due to failing checks Failing checks:
HintYou may have to fix your CI before adding the pull request to the queue again. Requeued — the merge queue status continues in this comment ↓. |
# Conflicts: # pkg/pb/plan/plan.pb.go
Merge Queue Status
This pull request spent 1 hour 21 minutes 49 seconds in the queue, with no time running CI. ReasonThe pull request can't be updated
HintYou should update or rebase your pull request manually. If you do, this pull request will automatically be requeued once the queue conditions match again. Requeued — the merge queue status continues in this comment ↓. |
# Conflicts: # pkg/defines/const.go # pkg/pb/plan/plan.pb.go # pkg/sql/compile/compile.go # pkg/sql/plan/bind_update.go # pkg/sql/plan/dml_context.go
Merge Queue Status
This pull request spent 2 hours 29 minutes 58 seconds in the queue, including 46 minutes 43 seconds running CI. Required conditions to merge
|
What type of PR is this?
Which issue(s) this PR fixes:
Part of #26340.
Stacked on #26923. Please review and merge the base PR first. Once #26923 lands, this PR diff will contain only the same-table alias semantics layer.
What this PR does / why we need it:
This PR completes same-physical-table writable alias semantics for multi-target UPDATE:
Validation: