Repository navigation
Closed
Description
Parent issue
Problem
The modern UPDATE resolver currently rejects a target as soon as its table definition contains any Fkeys or RefChildTbls. Because ResolveUpdateTables calls ResolveTables(..., respectFKCheck=false), this routing also ignores the session's foreign_key_checks value.
Planner selection should instead depend on the columns actually updated:
- updating no FK child column needs no child-to-parent lookup;
- updating a child FK column needs validation of the new key;
- updating no referenced parent-key column needs no parent-side action;
- updating a referenced parent-key column belongs to [Subtask]: Move parent-side FK referential actions to MULTI_UPDATE #26339.
A table can be both child and parent, so these decisions must be made per constraint, not per table.
Required work
- Keep unrelated-column updates on FK-bearing tables in the modern
MULTI_UPDATEpath. - Detect which child FK constraints are affected by the final updated row image.
- Validate changed child keys against the corresponding parent key.
- Preserve single/composite FK NULL semantics, including partial-NULL keys.
- Apply the defined
foreign_key_checks=0/1semantics consistently to routing and validation; do not preserve the current metadata-only routing accident. - Reuse modern base-table, regular-index, lock, retry, and rollback behavior.
- Leave referenced-parent-key actions to [Subtask]: Move parent-side FK referential actions to MULTI_UPDATE #26339.
Acceptance criteria
- An unrelated-column UPDATE produces
MULTI_UPDATEeven when the target has child FKs, referenced children, or both. - Changing a child FK to an existing parent succeeds; changing it to a missing parent fails before mutation.
- Unchanged child FK columns do not cause redundant parent probes.
- Single and composite FKs cover all-non-NULL, all-NULL, partial-NULL, nullable, and NOT NULL cases.
-
foreign_key_checks=0and=1have explicit plan and behavior tests matching the intended SQL contract. - The real-server shape from [Bug]: nullable index UPDATE keeps Rowid from filtered NULL row #26334 (nullable UNIQUE plus unrelated FK metadata) uses
MULTI_UPDATE, contains noPreInsert UniqueKey, and leaves correct hidden-index contents. - [Bug]: nullable index UPDATE keeps Rowid from filtered NULL row #26334 remains independently fixed so the legacy path is safe during rollout.
- Optimistic/pessimistic conflict, retry, cancellation, and rollback cases remain atomic.
- INSERT/ODKU FK behavior is unchanged.
Test matrix
- Target with only
Fkeys, onlyRefChildTbls, and both. - Unrelated column; unchanged FK columns; changed child FK to present/missing parent.
- Single/composite FK with NULL combinations.
- Nullable single/composite UNIQUE and secondary indexes on the target.
- Multi-row batches where filtered NULL index keys precede and follow surviving rows.
foreign_key_checks=0/1in optimistic and pessimistic modes.
Dependencies
- Parent: [Task]: Retire the legacy UPDATE planner and converge on MULTI_UPDATE #26336
- Uses [Subtask]: Inventory and instrument legacy UPDATE planner fallbacks #26337 route classification.
- Parent-side actions are handled by [Subtask]: Move parent-side FK referential actions to MULTI_UPDATE #26339.
- Related safety fix: [Bug]: nullable index UPDATE keeps Rowid from filtered NULL row #26334.
Activity