Repository navigation
fix(prepared): prepared queries use the database's rule limits (#679) - #682
Merged
Merged
Conversation
Backport of the v3 fix in #676. PreparedQuery::execute built its DatalogExecutor without set_limits, so a prepared rule query ran with the default max_derived_facts and max_results whatever OpenOptions set: a lower limit did not stop it, and a higher one did not help it. prepare now hands the database's (max_derived_facts, max_results) to the PreparedQuery, which sets them on every execute, as every other read path in db.rs does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019kY61Y11gcRD91Y6b7jbGT
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 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 the v3 fix in #676 (#549) for #679.
PreparedQuery::executebuilt itsDatalogExecutorwithoutset_limits, so a prepared rule query ran with the defaultmax_derived_factsandmax_results(1,000,000) whateverOpenOptionsset.preparenow passes the database's(max_derived_facts, max_results)toprepare_query, andexecutesets them on its executor, like every other read path indb.rs.Differences from v3: v2.x has both limits (v3 has
max_derived_factsandquery_memory_limit), andPreparedQuery::query(cursor API) does not exist on v2.x.Tests
tests/prepared_statements_test.rs, on the issue's friend chain (10 derived facts; the last semi-naive pass re-derives all 10, so both limits trip at 9, not at 3 as the issue's repro says):max_derived_facts(9)→INT-020fromexecuteand from the prepared query (failed before the fix)max_results(9)→ same (failed before the fix)A test with a limit above the default would need over 1,000,000 derived facts, so the "higher limit" direction is covered by the at-limit test instead.
Docs: CHANGELOG
[Unreleased], test counts (1321 / 1312 passing), TEST_COVERAGE.Refs #679 (left open until the next v2.0.x patch ships).
🤖 Generated with Claude Code
https://claude.ai/code/session_019kY61Y11gcRD91Y6b7jbGT