Repository navigation
[4.1.6-hotfix] fix(frontend): preserve string literals in merged role rules - #32890
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? |
|
This pull request is merged. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
The literal and identifier handling fixes the reported examples, but the new merged-rule serialization still produces invalid SQL for supported predicates. I reproduced the user-visible failure with a real CN and two active roles; details and the requested regression coverage are in the inline comment.
This failure also exists on the base commit; it is not a regression introduced by this PR. I am requesting its closure because it affects the same multi-role rule round-trip that this change is intended to make reliable.
Validation: the frontend, MySQL parser and tree short tests and focused race tests passed; the existing role-rule BVT passed 355/355 on this head. An independent predicate round-trip matrix and a real multi-role SQL reproduction exposed the issue.
XuPeng-SH
left a comment
There was a problem hiding this comment.
The current head addresses the previously reported POSITION, EXTRACT and REGEXP round-trip failures. The merged formatter preserves string values and quoted identifiers, and the binary literal representation survives repeated merges. I found no additional blocking code issue in this review.
Validation on 60ae27bd1dfeaebf934bd56b41f735e9133ceb38:
- Full
pkg/frontend,pkg/sql/parsers/dialect/mysql, andpkg/sql/parsers/treetests passed. Focused frontend race tests passed. - The isolated single-CN
role_rule.sqlBVT passed 355/355 twice. A separate two-role probe combining POSITION, EXTRACT, and REGEXP returned row 1 with the primary role and rows 1 and 2 with both roles. - The generated parser matches the grammar source. Additional predicate and string-escape round-trip probes passed apart from the existing AST spelling difference for the INTERVAL keyword, which preserves its parsed meaning.
CI remains red on this head: the x86 UT and arm64 SCA jobs failed, and their job logs are unavailable. Their failure causes are unverified, so the CI results still need investigation or a successful rerun before merge.
What type of PR is this?
Which issue(s) this PR fixes:
Fixes matrixorigin/matrixflow#22006
What this PR does / why we need it:
On
4.1.6-hotfix, merging two compatible role rules rebuilds their SELECT with an OR predicate. The default formatter emits decoded string values without SQL quotes. When the rewrite hint is read back, a value such as'0001'can become a number, and other values can make the rule fail to parse.Use the existing single-quoted SQL literal formatter only when emitting the merged SELECT. Rule eligibility, fallback, cache invalidation and the source-row union from #24929 are unchanged.
The unit test compares reparsed trees for Unicode, zero-padded strings in a subquery, an embedded quote and a backslash. It failed at reparse before the fix and passes after it. The role-rule BVT now distinguishes
'0001'from'1': one role sees one row; two roles see both matching rows even though their projections are equal. Re-saving the rule and querying from a new session produces the same result.Local validation: full
pkg/frontendunit tests,go vet, incremental golangci-lint, andzz_accesscontrol/role_rule.sqlvia mo-tester (335/335 passed).