Proving the Safety of SQL Queries

  • Authors:
  • Stefan Brass;Christian Goldberg

  • Affiliations:
  • Martin-Luther-Universitat Halle-Wittenberg, Germany;Martin-Luther-Universitat Halle-Wittenberg, Germany

  • Venue:
  • QSIC '05 Proceedings of the Fifth International Conference on Quality Software
  • Year:
  • 2005

Quantified Score

Hi-index 0.00

Visualization

Abstract

Many programs need to access data in a relational database. This is usually done by means of queries written in SQL. Although the language SQL is declarative, certain runtime errors are possible. Since the occurrence of these errors depend on the data, they are not easily found during testing. The question whether a query is safe can be reduced to a consistency check. It is well known that consistency is in general undecidable, and that this applies also to SQL queries. However, in this paper, we propose a consistency check that can handle a surprisingly large subset of SQL (it uses Skolemization with sorted Skolem functions, and a few other tricks). This consistency check is also the basis for generating other semantic warnings. Furthermore, it can be used to generate test data for SQL queries.