Translating Canonical SQL to Imperative Code in Coq
V\'eronique Benzaken, \'Evelyne Contejean, Mohammed Houssem, Hachmaoui, Chantal Keller, Louis Mandel, Avraham Shinnar and, J\'er\^ome Sim\'eon

TL;DR
This paper presents DBCert, the first mechanically verified compiler translating canonical SQL queries into imperative code in Coq, addressing bugs and divergence in SQL implementations for key features.
Contribution
It introduces a formal, verified translation pipeline from SQL to imperative code, including a complete SQL-to-Nested Relational Algebra translation and a mechanized algebra-to-Imp translation.
Findings
Verified correctness of SQL to imperative code translation
Supports SQL features like correlated queries and NULL semantics
Enables bug-free, reliable query compilation
Abstract
SQL is by far the most widely used and implemented query language. Yet, on some key features, such as correlated queries and NULL value semantics, many implementations diverge or contain bugs. We leverage recent advances in the formalization of SQL and query compilers to develop DBCert, the first mechanically verified compiler from SQL queries written in a canonical form to imperative code. Building DBCert required several new contributions which are described in this paper. First, we specify and mechanize a complete translation from SQL to the Nested Relational Algebra which can be used for query optimization. Second, we define Imp, a small imperative language sufficient to express SQL and which can target several execution languages including JavaScript. Finally, we develop a mechanized translation from the nested relational algebra to Imp, using the nested relational calculus as an…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Code & Models
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsAdvanced Database Systems and Queries · Service-Oriented Architecture and Web Services · Semantic Web and Ontologies
