Repository navigation
Improve role base rule rewrite (#24393) - #24415
Conversation
1、修复多角色合并时改写规则不起效的问题 2、多角色起效时,不同角色对同一个库表都有改写规则的时候,如果列一致的情况下,那么做union distinct合并。否则保留最后一个规则 Approved by: @heni02, @XuPeng-SH
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? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Request changes:
- SET ROLE does not invalidate the rewrite cache, so the session can keep applying rules loaded for the previous role set after a role switch.
- Rewrite merge currently treats all non-aggregate/non-window scalar functions as safe, which still admits volatile functions like rand(), uuid(), and now() into union distinct merging.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Request changes:
rewrite_rule mergeability currently treats set-operation rules unsafely: outputColumnsFromRewriteSelectStatement() handles *tree.UnionClause by returning only the LEFT branch and ignoring RIGHT branch + Type/All/Distinct (UNION/UNION ALL/INTERSECT/EXCEPT/MINUS).
As a result, rules like select a ... union all select now() ... can be misclassified as mergeable, and later merged via union distinct even though semantics differ. Please make set-operation rules non-mergeable (or validate both branches and set-op type strictly), and update tests that currently codify left-only behavior.
已处理 |
已处理 |
XuPeng-SH
left a comment
There was a problem hiding this comment.
LGTM. 多角色规则合并逻辑正确,错误处理改进明显,测试覆盖充分。
Minor suggestions for future improvement:
getSqlForRoleIDsOfUserForRuleCache/getSqlForInheritedRoleIDsForRuleCacheselectwith_grant_optionbut never use it — can be removed.- Consider adding a depth/count limit for BFS role traversal to guard against pathological inheritance graphs.
Merge Queue Status
This pull request spent 25 seconds in the queue, including 5 seconds running CI. Required conditions to merge
|
1、修复多角色合并时改写规则不起效的问题
2、多角色起效时,不同角色对同一个库表都有改写规则的时候,如果列一致的情况下,那么做union distinct合并。否则保留最后一个规则
Approved by: @heni02, @XuPeng-SH
What type of PR is this?
Which issue(s) this PR fixes:
issue #23271
What this PR does / why we need it:
1、修复多角色合并时改写规则不起效的问题
2、多角色起效时,不同角色对同一个库表都有改写规则的时候,如果列一致的情况下,那么做union distinct合并。否则保留最后一个规则