Skip to content

fix: maintain indexes for REPLACE foreign key actions - #27062

Draft
ck89119 wants to merge 2 commits into
matrixorigin:mainfrom
ck89119:issue-26875-main
Draft

fix: maintain indexes for REPLACE foreign key actions#27062
ck89119 wants to merge 2 commits into
matrixorigin:mainfrom
ck89119:issue-26875-main

Conversation

@ck89119

@ck89119 ck89119 commented Aug 12, 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:

issue #26875

What this PR does / why we need it:

Fixes REPLACE foreign-key actions when child tables have explicit unique or secondary indexes.

  • Keeps binding tags and positional projections only on recursive FK index-maintenance paths.
  • Gives hidden-index DELETE operators a stable rowid/primary-key input layout.
  • Remaps regular UK/SK pre-insert metadata after projection pruning.
  • Preserves secondary-index pre-insert context when copying prepared plans.
  • Avoids unsafe optimizer assumptions for untagged internal DML scans.
  • Disables the internal RIGHT JOIN runtime filter only when it would create an FK-action wait cycle.
  • Adds end-to-end coverage for indexed CASCADE and SET NULL through literal REPLACE and binary-protocol prepared statements.

Validation:

  • go test ./pkg/sql/plan
  • TestIssue26875ReplaceMaintainsIndexedForeignKeyChildren
  • TestIssue25526PreparedUpdateJoinSecondExecute
  • golangci-lint run -v -c .golangci.yml ./...

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/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants