Repository navigation
fix(query): run an expression reading an or-bound variable after the ors (#625, backport) - #630
Merged
Merged
Conversation
…ors (#625, backport) Backport of #629 from v3. optimizer::plan appended an expression whose variable only an or / or-join binds to the end of the planned list, and the ors run after that list, so the expression saw the variable unbound and dropped every row, in queries and in rule bodies. plan now defers an expression that reads a variable no pattern in the list and no expression placed before it binds, ahead of the deferred nots and in text order. Both executor deferred passes run it after apply_or_clauses (via apply_expr_clauses; expressions cost 0, so the stable cheapest-first sort keeps them first), and the rule-body evaluator applies it after its or pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PtCdzbJMSS1V8qEPaJ4jXz
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
Backport of #629 (v3) to
mainfor the next v2.0.x patch. #625 is a data-integrity known issue and stays open until that patch is published.Problem
optimizer::planappended an expression whose variable only anor/or-joinbinds to the end of the planned list, and theors run after that list, so the expression dropped every row:Fix (hand-port;
mainhas no streaming engine, seeded planning orBinders)optimizer::plandefers an expression that reads a variable no pattern in the list and no expression placed before it binds. Deferred expressions come first in the deferred list, in text order, ahead of the deferrednots.apply_or_clausesruns them viaapply_expr_clauses. Expressions cost 0, so the stable cheapest-first sort keeps them ahead of thenots. Under thewasmfeature there is no sort, and the list order already puts them first.orpass viaapply_expr_clauses_in_evaluator.Tests
tests/disjunction_test.rs(+2, same as on v3): the issue's query, anotafter a deferred binding expression, a query calling a rule, and a rule body. Both fail without the fix.optimizerunit tests (+3, replacingtest_expr_unbound_var_goes_to_end).cargo test: 1293 tests (1284 passing, 9 ignored). clippy (default and--all-features) and fmt are clean. The per-module coverage gates pass locally (evaluator.rsbranches 85.48%,executor.rs78.00%).--features wasm, 3 perf: short-circuit or/or-join branch evaluation using cost model #250 short-circuit tests indisjunction_test.rsfail onmainwith and without this change. They were already failing before this PR.Review
Codex (read-only): no correctness bug found.
🤖 Generated with Claude Code
https://claude.ai/code/session_01PtCdzbJMSS1V8qEPaJ4jXz