8000 fix(prepared): prepared queries use the database's rule limits (#679) by adityamukho · Pull Request #682 · project-minigraf/minigraf · GitHub
[go: up one dir, main page]

Skip to content

fix(prepared): prepared queries use the database's rule limits (#679) - #682

Merged
adityamukho merged 1 commit into
mainfrom
fix/679-prepared-limits
Oct 21, 2026
Merged

adityamukho merged 1 commit into
mainfrom
fix/679-prepared-limits

Conversation

@adityamukho
Copy link
Copy Markdown
Collaborator

Backport of the v3 fix in #676 (#549) for #679.

PreparedQuery::execute built its DatalogExecutor without set_limits, so a prepared rule query ran with the default max_derived_facts and max_results (1,000,000) whatever OpenOptions set. prepare now passes the database's (max_derived_facts, max_results) to prepare_query, and execute sets them on its executor, like every other read path in db.rs.

Differences from v3: v2.x has both limits (v3 has max_derived_facts and query_memory_limit), and PreparedQuery::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-020 from execute and from the prepared query (failed before the fix)
  • max_results(9) → same (failed before the fix)
  • both limits at 10 → both succeed

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

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
codecov Bot commented Oct 21, 2026
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@adityamukho
adityamukho merged commit efe2609 into main Oct 21, 2026
22 checks passed
@adityamukho
adityamukho deleted the fix/679-prepared-limits branch October 21, 2026 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0