Repository navigation
Conversation
try_dispatch picked a query function with sql.to_uppercase().contains(...) on
the raw statement, so a keyword inside a string literal, quoted identifier, or
comment hijacked the statement and failed with a misleading 42601 - e.g.
INSERT ... VALUES ('tmp_verify_balance_x', ...) answered
"VERIFY_BALANCE requires (collection, column)".
Blank quoted regions and comments before the keyword checks: add scan_code and
route through recognized_function, keeping the pgwire recognition order. Real
SELECT VERIFY_BALANCE(...) calls still route.
Tests pin the routing decision (literals, escapes, comments, unterminated
regions, token fusion, keyword order, real calls) and a wire regression holds
both directions; the wire case seeds with the parenthesised INSERT so it
reaches the router, which the brace form does not.
Issue 349.
EnRaiha
force-pushed
the
fix/qf-router-literal-scan
branch
from
September 19, 2026 14:34
9951a93 to
28cf60d
Compare
Member
|
Closing. The fix keeps routing by substring and adds a second quote/comment scanner beside the existing one. The correct fix routes on the parsed function name, so literals, identifiers, and comments cannot match at all. The maintainers will fix #349 in-tree. |
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.
Why
query_functions::router::try_dispatchpicked a query function withsql.to_uppercase().contains(...)over the raw statement, so any keywordinside a string literal, quoted identifier, or comment hijacked the statement.
Any statement that does not parse as typed DDL and whose text contains one of
six substrings failed with a misleading
42601, found while replaying aknowledge-graph backfill:
INSERT INTO kg (id) VALUES ('tmp_verify_balance_x')VERIFY_BALANCE requires (collection, column)INSERT INTO kg (id) VALUES ('tmp_plain_x')INSERT INTO kg (id) VALUES ('tmp_z', 'verify_balance')(keyword in a label)INSERT INTO kg { id: 'tmp_verify_balance_y', ... }(brace form)Issue: #349.
What
scan_code: blanks'...'(with''escapes),"...",--, and/* */before the keyword checks; all other characters pass through verbatimrecognized_function(the routing decision) so it is testable;try_dispatchmatches on it; recognition order unchanged; a realSELECT VERIFY_BALANCE(...)still routesTests
query_functions::routernow pin the routing decision(
recognized_function): literal, escaped quote, quoted identifier, line andblock comment, token fusion, first-keyword order, and real calls
nodedb/tests/wire/cases/router_misroute_literals.rs(
value_carrying_verify_balance_does_not_misroute): a parenthesised INSERTwhose value carries the token stores verbatim — the brace form is intercepted
before the router, so it cannot guard this — and the anchored call still
reaches the function arm
cargo test -p nodedb --lib query_functions::router-> 9 passed;cargo test -p nodedb --test wire value_carrying_verify_balance_does_not_misroute-> 1 passed
Test Suiteworkflow runs only with therun-cilabel (
.github/workflows/ci.ymlgates it), so it reportsskippingby designSurvey with c2g on the branch: diff-impact = the decision helper and its call
site; no exported surface change.
Notes
''escapes), quoted identifiers(
""),--and/* */comments. Not handled: nested block comments,E-string backslash escapes, and dollar-quoted strings — pre-existing class,
not regressions of this change.
planner/procedural/executor/core/sql_literal_concat.rs(
consume_quoted_region,parse_single_quoted_literal) — requires avisibility change.