Skip to content

refactor(sql): consolidate UPDATE target ownership - #31798

Merged
XuPeng-SH merged 9 commits into
mainfrom
codex/29249-remap-owner
Oct 30, 2026
Merged

XuPeng-SH merged 9 commits into
mainfrom
codex/29249-remap-owner

Conversation

@XuPeng-SH

@XuPeng-SH XuPeng-SH commented Oct 30, 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:

Refs #29249

What this PR does / why we need it:

UPDATE planning already resolves writable targets in the modern DML context, but self-referencing foreign-key detection previously ran a second legacy resolution after the plan was built. Reuse the existing context for those checks, in source-table order, and remove the obsolete UPDATE rebinding and unused legacy fields. Preserve the checks' existing position and foreign-key setting. Remove a DELETE projection branch whose only caller always selected the other path.

READ ONLY admission now uses one disposition for allowed, persistent, and deferred decisions. READ WRITE transactions avoid UPDATE ownership classification after their mode is stamped. For READ ONLY multi-table UPDATE, successful source-column lookups are reused within one admission check, while unresolved lookups remain retryable and per-assignment ambiguity is preserved. Existing pre- and post-transaction admission boundaries remain unchanged. Database remap consumers also share the existing pure lookup policy without adding state.

A later duplicate SET generated_col = DEFAULT must not hide an earlier invalid generated-column assignment when the nonsequential multi-table path deduplicates assignments. Validate the original occurrences while preserving sequential error order. This also rejects that invalid statement with foreign-key checks disabled; the previous modern path could accept it.

The design records ownership and validation boundaries.

Validation

On darwin/arm64 with Go 1.27.1 and GOEXPERIMENT=simd:

  • Full pkg/sql/plan and pkg/frontend unit suites passed: 4,457 and 2,766 top-level tests; 3 existing skips.
  • Affected tests passed once with -race -count=1.
  • Configured incremental SCA for both packages passed (0 reported issues).
  • Real-service SQL cases: foreign-key UPDATE 203/203, READ ONLY 316/316, remap 220/220; multi-table DELETE 128/130 and INSERT/duplicate-key 170/178, with the remaining 2 and 8 respectively marked ignored by existing fixtures and no failures. Fixture database cleanup and the global identifier setting were checked.
  • A synthetic in-process admission benchmark with stubbed catalog resolution showed READ WRITE lookup calls 8 → 0 and READ ONLY calls 8 → 2 for four assignments across two sources (before vs. final source). These are call-count results, not an end-to-end database throughput claim.

An independent gpt-6-astra/xhigh review of the complete merged diff found and verified closure of a generated-column regression; the final overall review reported no remaining code blocker. CI results for this new head are pending.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@XuPeng-SH

XuPeng-SH commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor Author

mo-bot review · mo-bot-local · done

Commit: 088d4c5b34e867507c825f47a0d38e8dd143fce7

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mo-bot review · mo-bot-local · review

Commit: 088d4c5b34e867507c825f47a0d38e8dd143fce7

Assessment: approve

The shared lookup preserves normalization, mapping semantics, and each caller’s database-selection rules. No actionable findings remain.

Model: gpt-6-astra / xhigh

Session: 01a1869d-820c-7212-9788-aecfb86a4141 · slot 0 · generation 2

Validation:

  • Focused tests passed: 19 root tests, 101 total cases.

  • Frontend suite: 2,755 roots passed, one preexisting skip, and one read-only-filesystem failure. The failing export test subsequently passed from writable diagnostic storage using the frozen-source binary.

  • Source identity, cleanliness, patch, formatting, native provenance, and discussion coverage audits passed.

  • Commands, exit receipts, retained logs, and hashes are reconciled in attempt-1/validation-evidence.json.

Limitations:

  • The original full-suite command exited 1; its environment failure and successful targeted recovery are recorded separately.

  • CI was pending in the supplied snapshot. Author-reported BVT, race, SCA, and mutation results were not independently verified; those additional runs were unnecessary for this behavior-preserving extraction.

@XuPeng-SH XuPeng-SH changed the title refactor(frontend): share database remap lookup refactor(sql): consolidate UPDATE target ownership Oct 30, 2026
@matrix-meow matrix-meow removed the size/S Denotes a PR that changes [10,99] lines label Oct 30, 2026
@mergify mergify Bot added the kind/bug Something isn't working label Oct 30, 2026
@XuPeng-SH

XuPeng-SH commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor Author

mo-bot review · mo-bot-local · done

Commit: dcfb2654318fb7176fce927d082b3147b74b3bdb

Review completed. Read the assessment.

@matrix-meow matrix-meow added the size/L Denotes a PR that changes [500,999] lines label Oct 30, 2026

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mo-bot review · mo-bot-local · review

Commit: dcfb2654318fb7176fce927d082b3147b74b3bdb

Assessment: approve

The refactor preserves admission timing and FK target ownership, and correctly validates generated-column assignments before deduplication. No actionable findings remain.

Model: gpt-6-astra / xhigh

Session: 01a1869d-999c-7481-b340-ae4a63e8cee4 · slot 1 · generation 2

Validation:

  • 84 focused top-level tests passed.

  • Planner suite: 4,457 top-level tests passed.

  • Frontend suite: 2,765 passed, one skipped, and one export test failed on the read-only checkout. That test subsequently passed from writable storage using the frozen-source binary.

  • Source identity, formatting, native provenance, discussion coverage, and receipt/log reconciliation passed. Evidence is retained in attempt-1/validation-evidence.json.

Limitations:

  • The original full-suite command remains exit 1; its environment failure and successful targeted recovery are recorded separately.

  • Author-reported BVT, race, SCA, and benchmark results were not independently verified. The supplied CI snapshot contains no results.

@XuPeng-SH
XuPeng-SH merged commit f6feb84 into main Oct 30, 2026
22 of 28 checks passed
@XuPeng-SH
XuPeng-SH deleted the codex/29249-remap-owner branch October 30, 2026 02:44
XuPeng-SH added a commit that referenced this pull request Oct 30, 2026
## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Refs #29249

## What this PR does / why we need it:

The combination of #31795 and #31798 left a boolean return in a function
that now returns `writeDisposition`, breaking the main build. Return
`writePersistent` for an unresolved or derived DELETE source, preserving
the existing fail-closed behavior.

The same one-line correction is proposed in #31813; that PR's main CI is
currently blocked by its preflight description check.

Validation on darwin/arm64, Go 1.27.1, `GOEXPERIMENT=simd`:

- Full `pkg/frontend` unit suite passed (`-count=1`).
- Affected read-only classification tests passed with `-race -count=1`,
including the existing derived-source case.
- Configured incremental SCA for `./pkg/frontend` passed with 0 issues.

GitHub CI is pending.

This branch had an error being deployed

1 failed deployment
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 kind/enhancement kind/refactor Code refactor size/L Denotes a PR that changes [500,999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants