Repository navigation
fix(query_engine): limit the nesting of queries - #1828
Conversation
|
This is a preview of the changelog of the next release. If this branch is not up-to-date with the current main branch, the changelog may not be accurate. Rebase your branch on the main branch to get the most accurate changelog. Note that this might contain changes that are on main, but not yet released. Changelog: 0.17.6 (2026-11-18)FeaturesBug Fixes |
64fa0bb to
ce790b4
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The parser can still create over-depth ASTs through parenthesized postfix chains, and a regression test retains a dangling string_view that can trigger use-after-free under ASAN.
2 open issues
What changed in this PR
This PR addresses #1812 by adding nesting guards to the SaneQL parser to reject deeply nested queries before they stall or exhaust the query engine’s stack.
Changes:
- Introduces a 100-level parser nesting limit, including postfix chains.
- Adds parser boundary tests, deep-input tests, endpoint checks, and user documentation.
- Avoids expensive filter string formatting when trace logging is disabled.
| File | Description |
|---|---|
src/rhydb/query_engine/scalar_expressions/int_between.cpp |
Guards trace-only string formatting. |
src/rhydb/query_engine/scalar_expressions/and.cpp |
Skips diagnostic string construction when trace logging is disabled. |
src/rhydb/query_engine/saneql/parser.test.cpp |
Tests nesting boundaries, excessive depth, and flat logical chains. |
src/rhydb/query_engine/saneql/parser.h |
Declares the nesting limit, recursion guard, and postfix helper. |
src/rhydb/query_engine/saneql/parser.cpp |
Implements nesting checks and recursive postfix parsing. |
endToEndTests/test/query.test.js |
Checks rejection of deeply nested queries and subsequent server health. |
documentation/query_documentation.md |
Documents the nesting limit and counting rules. |
Review effort: Balanced
ce790b4 to
7feb90b
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The unary-expression depth guard double-counts the current !, rejecting 99 negations despite their allowed tree depth of 100; its scope needs correction and boundary tests.
1 open issue
2 resolved since last review
Review effort: Balanced
2134cf6 to
780ba07
Compare
780ba07 to
aad9998
Compare
🤖 I have created a release *beep* *boop* --- ## [0.17.6](v0.17.5...v0.17.6) (2026-11-18) ### Features * **query_engine:** add type casts at query execution time ([#1799](#1799)) ([f7acdf0](f7acdf0)) ### Bug Fixes * **query_engine:** do not decompress every row before applying a limit ([#1833](#1833)) ([d3c06a2](d3c06a2)) * **query_engine:** evaluate out-of-bound `.at()` expressions to null for null inputs ([#1839](#1839)) ([511d2ee](511d2ee)) * **query_engine:** limit the nesting of queries ([#1828](#1828)) ([599d3a4](599d3a4)) * **query_engine:** treat Unicode whitespace as whitespace and report non-ASCII errors ([#1816](#1816)) ([edc1c02](edc1c02)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>



resolves #1812
Summary
This adds a recursion-guard to the parser of queries which is at the start of every recursive function. This recursion-guard is used to limit the maximum depth of queries to 100 levels. (postfix expressions like
x.f().f().f()also count as one nesting as per Uniform-Function-Call-Syntax)PR Checklist