Repository navigation
fix(tinql): cap query length and nesting like tin - #19
Merged
Merged
Conversation
eeeebbbbrrrr
added this pull request to stack #20
October 6, 2026 18:25
claude
Bot
force-pushed
the
tinql-parse-limits
branch
from
October 6, 2026 18:33
808b29a to
c0877b5
Compare
Every TINQL parse in the backend now goes through postgres/src/tinql.rs, ported from tin: text over 2048 bytes or nested deeper than 64 `(`/`[` levels fails with SQLSTATE 54000 (program_limit_exceeded) before pest runs. The parser recurses per bracket and the lowering per term, so unbounded text could overflow the backend's stack and crash it. The `==>` operator, score and highlight binds, tin.highlight's query argument, tin.score_inspect, and tin.ql_parse all use the guarded parse. tinql gains tin's max_bracket_depth and its unit tests. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012mKGtrg7DEhVPgqYrJtHGg
evaluate_text now reaches the guarded parse, which raises through PostgreSQL's error machinery. That code references backend data symbols, which the standalone test binary cannot resolve when it loads, so these tests move to #[pg_test] like tin's tests of its guarded parse. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012mKGtrg7DEhVPgqYrJtHGg
claude
Bot
force-pushed
the
tinql-parse-limits
branch
from
October 6, 2026 19:03
c0877b5 to
0c132a5
Compare
eeeebbbbrrrr
approved these changes
Oct 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before: Lead hands any TINQL text straight to pest. In a debug build, 700 nested parentheses (1.4 KB) or a 600-term OR chain (4.8 KB) overflows the stack and crashes the backend (SIGSEGV).
After: Every backend parse goes through
postgres/src/tinql.rs, ported from tin'spostgres/src/tinql.rson develop. Text over 2048 bytes, or nested deeper than 64(/[levels, fails with SQLSTATE 54000 (program_limit_exceeded) before the parser runs. Messages and details match tin:tinql query is too long/The query is N bytes; the limit is 2048 bytes.tinql query is nested too deeply/The query nests N levels deep; the limit is 64.It covers
==>, the score and highlight binds,tin.highlight(query => …),tin.score_inspectandtin.ql_parse. Thetinqlcrate gains tin'smax_bracket_depthand its unit tests.The operator's evaluation tests move to
#[pg_test]. They now reach PostgreSQL's error path, which a standalone test binary cannot load.A debug build can still overflow on a 2 KB run of one-letter terms (
a a a …). Release builds hold.Tests: a session test mirrors tin's
tinql_query_length_limitregress test across every entry point, including a generic-plan parameter. It fails before the fix.Stacked on #18.