Repository navigation
Closed
Labels
area/optimizerkind/subtaskseverity/s0Active / top priority for current sprint. Owner has committed to working on it now.
Description
Parent issue
Problem
When an UPDATE changes a referenced parent key, the legacy planner recursively builds child checks/updates through buildUpdatePlans / buildDeletePlans. This is the largest semantic dependency preventing removal of buildTableUpdate.
The modern planner needs an explicit referential-action graph. Merely having RefChildTbls is not enough to invoke it: parent-side work is required only for constraints whose referenced columns can change in the final row image.
Scope
- RESTRICT and NO ACTION.
- CASCADE.
- SET NULL.
- Current SET DEFAULT disposition: the legacy code groups it with NO ACTION/RESTRICT; preserve that compatibility or reject it explicitly rather than silently inventing mutation semantics.
- Self-referencing constraints.
- Multiple constraints, multiple child tables, and multi-level actions.
- Tables that are both parent and child.
Required work
- Discover affected constraints from updated referenced columns.
- Build a finite action DAG with explicit cycle/duplicate-row handling rather than uncontrolled recursive expansion.
- Use final parent keys and correct old/new child row images.
- Fold all base-table and regular hidden-index writes into one atomic statement plan.
- Define deterministic table/row lock ordering and retry behavior.
- Honor the defined
foreign_key_checkssemantics consistently with [Subtask]: Move child-side foreign-key UPDATE validation to MULTI_UPDATE #26338.
Acceptance criteria
- Updating a non-referenced parent column stays on the modern path without child probes/actions.
- RESTRICT and NO ACTION reject a referenced-key change when matching children remain.
- CASCADE updates every affected child row and regular index atomically.
- SET NULL validates child nullability before mutation and maintains indexes atomically.
- SET DEFAULT has an explicit compatibility test and documented disposition.
- Composite keys preserve column order and NULL semantics.
- Self-reference, cycles, and deep graphs terminate deterministically with a defined error where the graph is unsupported.
- Diamond/multiple FK paths do not double-update a row or corrupt affected-row accounting.
- Lock acquisition order is documented and covered by concurrent conflict/deadlock/retry tests.
- Any failure or cancellation rolls back parent, child, and hidden-index changes together.
- Supported cases produce modern plans with no
buildTableUpdateroute.
Test matrix
- RESTRICT/NO ACTION, CASCADE, SET NULL, and SET DEFAULT for single/composite keys.
- Parent with multiple children; child with multiple FKs; table acting as both.
- Self-reference, cycle, two-level/deeper cascade, and diamond graph.
- Cascaded rows with UNIQUE, secondary, generated, and partition columns.
foreign_key_checks=0/1.- Optimistic/pessimistic conflict, retry, cancellation, and rollback.
Dependencies
Metadata
Metadata
Assignees
Labels
area/optimizerkind/subtaskseverity/s0Active / top priority for current sprint. Owner has committed to working on it now.
Activity
fix(plan): validate child keys in modern update (#26407)
fix(plan): move parent FK update actions to MULTI_UPDATE (#26442)
fix(plan): validate child keys in modern update (matrixorigin#26407)
fix(plan): move parent FK update actions to MULTI_UPDATE (matrixorigi…
fix(plan): validate child keys in modern update (matrixorigin#26407)
fix(plan): move parent FK update actions to MULTI_UPDATE (matrixorigi…
fix(plan): validate child keys in modern update (matrixorigin#26407)
fix(plan): move parent FK update actions to MULTI_UPDATE (matrixorigi…