Repository navigation
refactor(sql): share DELETE target name resolution - #31786
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? |
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 9300af40d959883fc778c7ceaf0a93a255f25f2f
Assessment: approve
The consolidation preserves DELETE target resolution, temporary-table admission, and planner routing. No actionable findings. Source remains unchanged.
Model: gpt-6-astra / xhigh
Session: 01a1869d-820c-7212-9788-aecfb86a4141 · slot 0 · generation 2
Validation:
-
All 15 focused tests passed across planner and frontend.
-
Full planner suite passed. Frontend had one read-only-filesystem fixture failure; that unchanged test and its control passed with a diagnostic path-only overlay.
-
Both packages passed go vet; formatting and diff checks were clean.
-
Ten receipts reconciled with retained logs in validation-review.json; discussion-assessment.json covers both comments.
Limitations:
-
The original full frontend run remains non-passing; three existing tests/subtests were skipped across both packages.
-
Relevant frozen CI was pending. Author-reported BVT, race, mutation, and configured-linter results were not independently verified; configured linters were unavailable locally.
## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes #31794 ## What this PR does / why we need it: A WITH name matching a DELETE target alias could suppress the writable table and cause a planner panic. Extend the shared source collector from #31786 to retain visible source names and explicit-alias identity, then validate CTE/writable targets before catalog lookup in modern and legacy DELETE. SELECT retains the original WITH; INSERT/UPDATE handling is unchanged. Preserve main's qualified explicit-alias precedence, including an alias identical to its base table name. Reject true CTE/derived targets, absent writable sources and mismatched qualified implicit targets. The frontend read-only gate consumes the same source map and fails closed for missing sources; no parallel collector or AST mutation is introduced. Missing targets preserve the existing `missing FROM-clause entry` diagnostic. Work remains bounded by statement sources/targets/CTEs, with no per-row execution change. Validation (Go 1.27.1, darwin/arm64): full planner UT; affected planner/frontend/public SQL tests with race; gofmt, vet, pinned molint and incremental golangci-lint (0 issues). Local single-CN BVTs covering the full DELETE directory plus CTE and read-only cases completed with 1,236 checks passed, 24 existing ignores and zero failures; the original failing DELETE golden is unchanged. Database/account teardown verified. Upstream target-identity and AST-reuse controls are retained. Design and overall review: gpt-6.1-terra/max. GitHub CI is separate.
What type of PR is this?
Which issue(s) this PR fixes:
Refs #29249
What this PR does / why we need it:
READ ONLY admission and the modern/legacy DELETE planners independently implemented the rules that map a DELETE target alias to its source table. A qualified target such as
DELETE db.x FROM p AS xmust identifypconsistently before applying temporary-table and catalog policies.Share the pure alias collection and name substitution in
pkg/sql/plan, and remove the duplicated implementations. Each consumer retains its existing CTE checks, effective database resolution, catalog validation and transaction admission ordering. Classification reads current temporary-table bindings without mutating a reused AST. The change keeps O(source nodes + targets) work and statement-local storage; no runtime speedup is claimed.The design explains the ownership boundary and why UPDATE binding remains separate.
Validation on Go 1.27.1, darwin/arm64, GOEXPERIMENT=simd:
pkg/sql/planandpkg/frontendUT: passed with-count=1; 3 pre-existing skips.-race -count=1.make static-check-selectedfor both packages: passed, 0 issues.set/transaction_read_only.sql: 316/316 checks passed; same-instance rerun also 316/316, with teardown verified.Local validation uses base
b4cd00ee34f1; merge-result CI remains pending.