Repository navigation
Fix to populate row policies for all select query types in query_log - #101044
Conversation
|
Workflow [PR], commit [f706dbe] Summary: ✅ AI ReviewSummaryThis PR moves row-policy collection into Findings
Tests
ClickHouse Rules
Final Verdict
|
There was a problem hiding this comment.
| throw Exception(ErrorCodes::LOGICAL_ERROR, "Global context cannot have view access info"); |
There was a problem hiding this comment.
Thanks! I will make this change.
| void Context::addUsedRowPolicy(const String & policy_name) | ||
| { | ||
| if (isGlobalContext()) | ||
| throw Exception(ErrorCodes::LOGICAL_ERROR, "Global context cannot have query access info"); |
There was a problem hiding this comment.
| throw Exception(ErrorCodes::LOGICAL_ERROR, "Global context cannot have query access info"); | |
| throw Exception(ErrorCodes::LOGICAL_ERROR, "Global context cannot have used row policies info"); |
There was a problem hiding this comment.
Made these change in new commits being pushed.
| } | ||
|
|
||
| void InterpreterSelectIntersectExceptQuery::extendQueryLogElemImpl(QueryLogElement & elem, const ASTPtr & /*ast*/, ContextPtr /*context_*/) const | ||
| void InterpreterSelectIntersectExceptQuery::extendQueryLogElemImpl(QueryLogElement & /*elem*/, const ASTPtr & /*ast*/, ContextPtr /*context_*/) const |
There was a problem hiding this comment.
This overriden method now has an empty body. Just remove it then.
There was a problem hiding this comment.
This makes sense. I think the base class IInterpreter.h seems to have empty function which should handle calls here for select queries.
I pushed the changes.
|
@nikitamikhaylov Thanks for the review! I pushed all the changes. The CI seems okay except for the stress test which has been failing for all PRs. Let me know if you can approve and whether I can go ahead and merge the PR. |
|
The Stress test (arm_msan) failure is fixed by #101239, which should be merged first. After it is merged, please update the branch to include the fix. |
|
The failures of "Flaky check" in "functions_bad_arguments" will be fixed by #101994. |
|
The MSan stress test failure (MemorySanitizer: use-of-uninitialized-value, STID 4179-5154 or 4148-3044) is a known pre-existing issue unrelated to this PR. Fix: #102158 |
| { | ||
| auto name = row_policy->getFullName().toString(); | ||
| if (query_context->hasQueryContext()) | ||
| query_context->getQueryContext()->addUsedRowPolicy(name); |
There was a problem hiding this comment.
Please add a regression case that covers multiple source tables with different row policies in one query (e.g. JOIN), to confirm used_row_policies is accumulated from all table-expression filters and not only the first encountered source.
| SELECT 'Nested subquery'; | ||
| SELECT * FROM (SELECT * FROM (SELECT * FROM t_row_policy)) ORDER BY x; | ||
|
|
||
| -- Test: INSERT SELECT |
There was a problem hiding this comment.
Thanks for adding coverage for views, nested subqueries, and INSERT SELECT. Since this PR also removes extendQueryLogElemImpl from InterpreterSelectWithUnionQuery and InterpreterSelectIntersectExceptQuery, please add a regression that verifies used_row_policies for UNION/INTERSECT/EXCEPT queries too.
Without this, the exact paths changed in those interpreters are still untested, so a future regression in set-operation logging could slip through.
LLVM Coverage Report
Changed lines: 88.89% (64/72) | lost baseline coverage: 19 line(s) · Uncovered code |
|
Hi — this PR may need backporting to Affected code: InterpreterSelectQuery::extendQueryLogElemImpl, InterpreterSelectQueryAnalyzer::extendQueryLogElemImpl, executeQuery.cpp query log population — core code present in all supported branches. Why: This fixes a user-visible bug where used_row_policies in system.query_log was empty for views, subqueries, and INSERT SELECT. The affected code (InterpreterSelectQuery::extendQueryLogElemImpl, InterpreterSelectQueryAnalyzer::extendQueryLogElemImpl, executeQuery.cpp logging) has existed since before all supported branches. The fix is safe — it only moves where row policy names are stored during query planning. If this should be backported, consider adding |
- Fix typo: `behavoir` → `behavior` (also `prevent` → `prevents`). - Replace placeholder entry for `#100909` with description of the `processAndOptimizeTextIndexFunctions` fix when `query_plan_merge_expressions = 0`. - Replace placeholder entry for `#101230` with description of the `S3Queue` stale processing nodes cleanup fix. - Rewrite the row-policies-in-`query_log` entry (`#101044`) for clarity, fixing typos (`sub queries`, `etc..to`, `palnner`, `were planner`). PR: #103729 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Row policies were not populated for views, sub queries, insert select etc..to query_log. Even though row policies were used in the query planning, they were not propagated from sub palnner to the parent planner for logging. This change fixes this bug by keeping row_policies(only for logging) inside QueryAccessInfo, were planner and sub planners can access and populate.
Resolves #99456
Documentation entry for user-facing changes
Version info
26.4.1.816