Repository navigation
fix(plan): resolve view sequences in stored database - #28116
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? |
aptend
left a comment
There was a problem hiding this comment.
Deep review completed at exact head 58bfad3355ccdf6c08dbcf0793b41804baa5691d against base/merge-base 99ed717b769e261b842c2f17345bd65865fc1470. There were no prior reviews or inline threads. I traced view expansion, hidden-overload binding, vector execution, database/relation lookup, and session sequence state across the full six-file diff.
The hidden database argument correctly fixes NEXTVAL and CURRVAL, preserves their one-argument SQL surface, and the committed cross-database regression covers both plus an ordinary-view control. One sibling sequence operation still follows the broken caller-database path and can mutate the wrong sequence, so this head needs changes before approval.
Validation with the repository-required CGO and locally built third-party artifacts: full go test ./pkg/sql/plan ./pkg/sql/plan/function -count=1; the new planner tests repeated 20 times; go vet for both packages; git diff --check; and a conflict-free merge tree against current origin/main. A review-only planner counterexample for SETVAL failed deterministically because the stored database argument was absent, and it was removed afterward. The SCA job failed in actions/checkout before analysis; other completed substantive checks are green, while UT and one BVT job remain in progress.
aunjgr
left a comment
There was a problem hiding this comment.
Review of commit bbe83f2bb5d4c50a3abae86a545bb22d8bdb462c.
No blocking finding in the reviewed change. The hidden database argument preserves the view's stored database for NEXTVAL/CURRVAL/SETVAL without splitting sequence names containing dots. Public arity guards and SETVAL overload normalization preserve existing calls; tests cover same-named sequences in the caller and view databases.
Evidence: source review and existing passing CI for this commit; no new local test run was performed for this review.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Reviewed head bbe83f2bb5d4c50a3abae86a545bb22d8bdb462c against base/merge-base 845fff8ee9cac962c5002a1007e0b0180efd591b. No blocking finding remains in the nine-file change.
Previous review closure:
- My CURRVAL performance finding is fixed: database handlers are cached by effective database within the batch. The four-row test expects exactly one Engine.Database call and verifies all four results.
- Both my and aptend's window-regression findings are fixed: the base-to-head query_builder_test.go diff is now additive; the stronger direct-CHAR/RANGE/helper coverage is retained.
- Aptend's earlier SETVAL finding is fixed: both public arities normalize to the stored-database internal overload, and the cross-database BVT checks that the caller's same-named sequence is not changed. The old review comments remain in GitHub history, but their cited code defects are resolved in this head.
I traced view-context inheritance into the hidden argument and NEXTVAL/CURRVAL/SETVAL execution, relation lookup, SQL updates, and table-ID-keyed session state. Public arities stay closed, dotted sequence names remain intact, and database/relation failures propagate. The cache is batch-local and introduces no shared lock, goroutine, or cross-transaction retained handle. The ordinary CURRVAL path adds a small map lookup per row but avoids the previously introduced per-row database resolution.
Evidence: complete diff/source review; current-head Ubuntu UT, SCA and both substantive multi-CN BVT checks are green; git diff --check passes. Existing CI evidence was reused, with no new local native execution. Approval expresses my independent conclusion and does not dismiss another reviewer's GitHub review state.
What type of PR is this?
Which issue(s) this PR fixes:
issue #27581
What this PR does / why we need it:
Fix sequence-backed views to resolve NEXTVAL and CURRVAL using the database where the view
was created, rather than the caller’s current database. The database is passed as an internal
execution argument without changing the public SQL function signatures. Added planner unit
tests and distributed regression coverage for both functions.