To test all execution paths of this fragment, HTDGen collects the embedded SQL query Q (SELECT price FROM Product),
the schema SD of the target database (e.g., SD includes the schema of table Product and integrity constraints) and the results R of the SQL query (e.g., a table with three rows: −5, 5 and 15 for the attribute price of the table Product; either given by the testers or by running a code analyzer). Then HTDGen sends Q, SD and R to a reverse query processing engine called SPQR [2]. The reverse query processing engine reverse processes the query and generates a test database D that fulfills all the integrity constraints in SD and guarantees that R = Q(D). Essentially, SPQR transforms the inputs from HTDGen into a set of constraints and uses a model checker to find possible solutions. The results of SPQR are translated by HTDGen into a set of SQL INSERT statements and inserted the data into the test database.