Repository navigation
Fix foreign keys smtlib gen - #1829
Merged
Merged
Conversation
agusaldasoro
added this pull request to stack #1831
October 6, 2026 13:34
agusaldasoro
marked this pull request as ready for review
October 6, 2026 16:55
jgaleotti
approved these changes
Oct 6, 2026
arcuri82
approved these changes
Oct 6, 2026
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.
Problem
The SMT-LIB formula always asserts every foreign key in the schema, so each row of a referencing table must point at a row of the referenced table.
get-value, however, only requested rows of the tables named in the query. ForSELECT * FROM book WHERE pages > 10, Z3 returned abookrow whoseauthormatched anauthorrow that was never requested or inserted. The database rejected theINSERT, and the query stayed empty.A second problem was hidden behind the first.
SMTResultParserstores the rows in aHashMap, so they came back in arbitrary order. Even with every row requested, a row could be inserted before the row it references.Fix
SmtLibGenerator: the tables passed toget-valuenow include every table reachable through foreign keys from the tables in the query.SMTLibZ3DbConstraintSolver: the rows of a solution are sorted so that each row comes after the rows it references, and rows of the same table come by row index. Self-references and cycles are ignored for ordering, because no order can satisfy them.sqlZ3NumberOfRows(k) still applies to every table, including the tables added through foreign keys. A query now yields kINSERTs for each table in the query and for each table those tables reference, directly or indirectly.