Translation of a query into SQL for SQLite: one recursive common table expression per local predicate, over the base tables. Source:
sql.rs.Sources: SPEC-007 Sophia Query Language §7; SQLite, The WITH Clause. code:
sql.rs
- Positive literals become
FROMitems, shared variables become equalities, negation becomesNOT EXISTS,startswithbecomessubstr(…) = …,countbecomescount(DISTINCT …)withGROUP BY. - Parameters and constants are inlined as literals (
X'…'for ids). - Mutual recursion and non-linear recursion return
Error::Unsupported. The native executor still runs those queries: SQL is a target, not the definition. - The generated SQL reads the base tables (
t_*) so their indexes apply; it runs throughSqlite::query_compiled, which keeps the read-only authorizer and the step budget.