Repository navigation
fix(plan): enforce CHECK constraints on final update rows - #26912
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep-reviewed exact head b519b9f.
CHECK constraints are evaluated over the final row image on the modern UPDATE path, the joined-update fallback, and ON DUPLICATE KEY UPDATE. Strict assertions remain row-preserving; UPDATE IGNORE uses a non-reorderable cardinality barrier; and DEDUP UPDATE, remapping, statistics, explain, operator duplication, and remote pipeline serialization preserve the new semantics.
Focused CGo tests passed for the assertion fast path and error cleanup, runtime-filter coexistence, remote round-trip, identity projection, UPDATE/UPDATE IGNORE/joined UPDATE/ODKU plan shapes, absent outer-join targets, pushdown boundaries, deep copy, and stats. git diff --check passed. No merge-blocking issue found.
…in#26912) ## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: issue matrixorigin#26820 ## What this PR does / why we need it: Enforces persisted CHECK constraints on the final row image for UPDATE and the UPDATE arm of INSERT ... ON DUPLICATE KEY UPDATE. - introduces a row-preserving ASSERT plan boundary for strict CHECK validation; - keeps UPDATE/INSERT IGNORE row-filter semantics behind an explicit pushdown barrier; - validates modern UPDATE, fallback joined UPDATE, and ODKU after final-row materialization but before writes; - preserves ASSERT semantics through parallel operator duplication and remote pipeline serialization; - adds planner, operator, protobuf, EXPLAIN, and multi-CN BVT coverage. Validation: - `make generate-pb` - CGo-enabled unit tests for the six owning packages - `make build` - multi-CN `check_constraint.test`: 55/55 passed Co-authored-by: XuPeng-SH <[email protected]>
…in#26912) ## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: issue matrixorigin#26820 ## What this PR does / why we need it: Enforces persisted CHECK constraints on the final row image for UPDATE and the UPDATE arm of INSERT ... ON DUPLICATE KEY UPDATE. - introduces a row-preserving ASSERT plan boundary for strict CHECK validation; - keeps UPDATE/INSERT IGNORE row-filter semantics behind an explicit pushdown barrier; - validates modern UPDATE, fallback joined UPDATE, and ODKU after final-row materialization but before writes; - preserves ASSERT semantics through parallel operator duplication and remote pipeline serialization; - adds planner, operator, protobuf, EXPLAIN, and multi-CN BVT coverage. Validation: - `make generate-pb` - CGo-enabled unit tests for the six owning packages - `make build` - multi-CN `check_constraint.test`: 55/55 passed Co-authored-by: XuPeng-SH <[email protected]>
…in#26912) ## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: issue matrixorigin#26820 ## What this PR does / why we need it: Enforces persisted CHECK constraints on the final row image for UPDATE and the UPDATE arm of INSERT ... ON DUPLICATE KEY UPDATE. - introduces a row-preserving ASSERT plan boundary for strict CHECK validation; - keeps UPDATE/INSERT IGNORE row-filter semantics behind an explicit pushdown barrier; - validates modern UPDATE, fallback joined UPDATE, and ODKU after final-row materialization but before writes; - preserves ASSERT semantics through parallel operator duplication and remote pipeline serialization; - adds planner, operator, protobuf, EXPLAIN, and multi-CN BVT coverage. Validation: - `make generate-pb` - CGo-enabled unit tests for the six owning packages - `make build` - multi-CN `check_constraint.test`: 55/55 passed Co-authored-by: XuPeng-SH <[email protected]>
## What type of PR is this? - [x] BUG ## Which issue(s) this PR fixes: Related to #26820. Applies the final-row CHECK behavior from #26912 to `4.2-dev`. ## What this PR does / why we need it: Enforce CHECK on the rows that ordinary and joined UPDATE, UPDATE IGNORE, upserts, and foreign-key actions actually write. Evaluate explicit assignments once, select a complete source row per update target, and derive generated values in dependency order. CHECK, generated keys, and the write use the same row values. - DedupJoin validates each image that another conflict will overwrite. The existing vectorized CHECK validates the emitted image before no-op write suppression, including a single conflicting row. A subsequent valid assignment cannot hide a rejected intermediate value. - SQL-equal explicit assignments retain observable representations. Implicit `ON UPDATE` values and dependent generated columns are finalized before CHECK. A generated column is evaluated once, including in a no-op where a provisional timestamp would have caused a cast error. Final write suppression compares the materialized values, including a timestamp changed by an earlier conflict. - Validate unsupported generated primary and unique key movement during each repeat fold. Pre-resolved conflict targets require stable encoded keys throughout folding, independently of CHECK and implicit `ON UPDATE`. Both fold and final-row validation use the same key encoding and return 20313 for unsupported movement. - Eligible single-row generated primary key updates reuse UPDATE's new-key duplicate check and lock. Delete by the old key and maintain regular secondary-index entries by their original owner. - Foreign-key actions validate the generated child row, preserve the NULL-component exemption, and compare outgoing keys with SQL equality. Changed non-NULL references use the existing parent lookup and lock when the parent is outside the write closure. REPLACE child Datalink admission stays bound to the final child values. Its existing guards cover generated changes that would require unsupported index maintenance or an unstable referenced parent. The rebase uses the shared CDC task-store readiness check from #33451 and removes the temporary local task-service setup. Intermediate generated-key checks reuse one encoded key snapshot per repeated group that needs it. The final plan checks the emitted key. The change reuses the existing plan fields, per-worker scratch and write path. ### Validation - Go 1.26.4, darwin/arm64. Fresh race runs passed in 10 Go packages covering planner, executor, compile, hash-build, multi-update, protocol types and consumers. The mandatory-role-rule integration test passed. Scoped golangci-lint reported zero issues. The pinned molint tool reported 11 existing diagnostics in eight files identical to the release base. Formatting, err-check and generated-plan binding verification passed. - At the previous PR head, direct UPDATE rejected negative zero with 3819. Matched and fresh duplicate groups and a singleton upsert accepted the same invalid representation. The fixed MySQL TCP probe passed all nine cases, including statement rollback inside an explicit transaction, reuse of a prepared statement after an error, a secondary UNIQUE conflict, an encoded generated key, and generated-cast boundaries. - Five BVT fixtures passed 704/704 statements on an isolated cluster. CHECK 245, generated columns 174, modern duplicate-key DML 203, VARCHAR casts 47, prepared projections 35. - Local timing for a prepared 4,096-conflict statement, five measured executions after warm-up, median before → after: plain 5.19 → 5.25 ms, check only 6.21 → 6.06 ms, implicit generated 7.09 → 7.14 ms. This is a single-CN comparison of these workloads. [Hosted checks](https://github.com/matrixorigin/matrixone/pull/33324/checks)
What type of PR is this?
Which issue(s) this PR fixes:
issue #26820
What this PR does / why we need it:
Enforces persisted CHECK constraints on the final row image for UPDATE and the UPDATE arm of INSERT ... ON DUPLICATE KEY UPDATE.
Validation:
make generate-pbmake buildcheck_constraint.test: 55/55 passed