Translating Canonical SQL to Imperative Code in Coq

Véronique Benzaken, Évelyne Contejean, Mohammed Houssem Hachmaoui, Chantal Keller, Louis Mandel +2 more
3/16/2022
cs.PLcs.DB

Official code: dbcert/dbcert (8 stars, OCaml, Apache-2.0, last commit 2023-10-19).

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.

Show full abstract

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 intermediate step.

View on arXivView PDF

Code Implementations(1)

dbcert/dbcertOfficial100%
Apache-2.0

Runtime and runner for a compiler from SQL to JavaScript

82OCaml, CoqMar 18, 20223 years agoApache-2.0

Similar Papers

Cite this paper

@article{benzaken2022translating,
  title  = {Translating Canonical SQL to Imperative Code in Coq},
  author = {Véronique Benzaken and Évelyne Contejean and Mohammed Houssem Hachmaoui and Chantal Keller and Louis Mandel and Avraham Shinnar and Jérôme Siméon},
  year   = {2022},
  eprint = {2203.08941},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2203.08941}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2203.08941.svg)](https://codeofpaper.com/paper/2203.08941)

Discussion