Repository navigation
fix(plan): preserve row rewrite rules through views - #29695
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? |
0fd5ab9 to
d8e3eb8
Compare
d8e3eb8 to
be97ba2
Compare
8551526 to
6e55734
Compare
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review: APPROVE on 6e55734cd3c5b53ff03087ad2fc31905317cfbd5. Reviewed directly, without subagents. No blocking findings.
The previous saved-view binding-mode finding is resolved in code and verified through the public MySQL path: a mode-0 view queried by a mode-1 caller now binds the replacement qualifier correctly. Policy-key normalization remains separate from the stored view's name-resolution mode.
Design and scope: all four changed files/hunks reviewed. bindView retains its independent name/CTE scope and carries the existing rewrite policy into the existing stacked-rewrite mechanism. The short qualifier inside a view agrees with ordinary table binding and persisted star expansion. No duplicate policy owner, state machine, storage, cache, or execution path was introduced. This is a focused bug fix; a separate feature design is unnecessary. Production +17/-3; tests +86/-0; documentation unchanged. The BVT extends the existing role/data fixture and teardown.
Validation:
- Reused exact-head CI run 37887975994: owning planner race shards and Linux SCA passed. The compose BVT log confirms
zz_accesscontrol/role_rule.sqlactually ran, with 206/206 checks passing (2.022s). - Ran
TestBindViewPropagatesOuterRewriteOptionthrough the controlled CGo wrapper: PASS. - Ran an independent, review-only public SQL probe twice against the same isolated instance: PASS. It checked exact visible IDs through direct/ordinary/nested/CTE views, aliases and qualification, self/left joins, outer-CTE scope isolation, native prepared reuse with the optional hint both off and on, stacked role/session rules, invalid-policy rejection and same-session recovery, and the saved/caller case-mode boundary. Database/user/role teardown postconditions were checked after each round. The two-round probe completed in 9.01s (10.523s package total).
- A challenged mode-1 rewrite source naming an inaccessible case-sensitive physical table returned the same 1146 through direct SQL and the view; the corresponding valid current-mode source passed. That input is not evidence of a view-specific regression.
Performance: the added propagation/qualifier work is in planning. View queries now perform the required policy rewrite and filtering that they previously bypassed. There is no new executor path, synchronization, or background resource. This is a code-path assessment, not a measured TP-throughput claim; no throughput benchmark was run.
Merge Queue Status
This pull request spent 49 minutes 55 seconds in the queue, with no time running CI. ReasonPull request #29695 has been dequeued Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.
HintYou should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it. Waiting for any of
All conditions
Tick the box to put this pull request back in the merge queue (same as
|
What type of PR is this?
Which issue(s) this PR fixes:
issue #29093
What this PR does / why we need it:
An ordinary view expansion created an isolated planner bind context without carrying the effective row rewrite policy from the outer query. Role row access rules therefore applied to direct base-table scans but were skipped when the same table was reached through a view.
This change propagates only the rewrite option into the view context while preserving the view's independent name and CTE scope. Nested view expansion and existing stacked rewrite-chain handling continue to apply the policy to the underlying base table. The access-control regression covers direct and ordinary-view queries with
enable_remap_hintenabled and disabled.Validation:
GOWORK=off go list -mod=readonly ./pkg/sql/planGOWORK=off go build -mod=readonly ./pkg/sql/planGOWORK=off go vet -mod=readonly ./pkg/sql/planGOWORK=off go test -mod=readonly -v -count=1 -timeout 120s ./pkg/sql/planrole_ruledistributed regression for ordinary views.