Skip to main content
Log in

Verification supported refactoring of embedded sql

  • Published:
Software Quality Journal Aims and scope Submit manuscript

Abstract

Improving code quality without changing its functionality, e.g., by refactoring or optimization, is an everyday programming activity. Good programming practice requires that each such change should be followed by a check if the change really preserves the code behavior. If such a check is performed by testing, it can be time consuming and still cannot guarantee the absence of differences in behavior between two versions of the code. Hence, tools that could automatically verify code equivalence would be of great help. An area that we are focused on is embedded sql programming. There are a number of approaches for dealing with equivalence of either pairs of imperative code fragments or pairs of sql statements. However, in database-driven applications, simultaneous changes (changes that include both sql and a host language code) are also present and important. Such changes can preserve the overall equivalence without preserving equivalence of these two parts considered separately. In this paper, we propose an automated approach for dealing with equivalence of programs after such changes, a problem that is hardly tackled in literature. Our approach uses our custom first-order logic modeling of sql queries that corresponds to imperative semantics. The approach generates equivalence conditions that can be efficiently checked using smt solvers or first-order logic provers. We implemented the proposed approach as a framework sqlav, which is publicly available and open source.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Fig. 1
Fig. 2
Fig. 3
Fig. 4
Fig. 5
Fig. 6
Fig. 7
Fig. 8
Fig. 9
Fig. 10
Fig. 11
Fig. 12
Fig. 13
Fig. 14
Fig. 15
Fig. 16
Fig. 17
Fig. 18
Fig. 19
Fig. 20
Fig. 21
Fig. 22

Similar content being viewed by others

Notes

  1. In presence of recursive functions, at most k calls are applicable.

  2. Developer survey results for 2019, StackOverflow https://insights.stackoverflow.com/survey/2019This conclusion is based on answers given by 87,354 developers.

  3. Survey results can be found here: https://scalegrid.io/blog/2019-database-trends-sql-vs-nosql-top-databases-single-vs-multiple-database-use/

  4. Including both primary and forked repositories.

  5. At this point we do not specify the type of numbers (apart from assumption that for each number n it holds n ≥ 0 or n < 0). However, in our implementation we treat this type as integer or fixed width bit-vector integer.

  6. Unary plus corresponds to the unary plus in sql, but could be omitted.

  7. If names of columns in different tables are not different, table names are concatenated to column names, making names of uninterpreted functions unique.

  8. Equivalence is possible if, for example, one code has a part of the common filter implemented on the host language level. However, such situations are seldom, as filters are usually implemented as part of sql queries.

  9. This should not be considered as the comparison of solvers Z3 and Vampire.

  10. https://github.com/features/actions

References

Download references

Funding

This work was partially supported by the Serbian Ministry of Science grant 174021 and by COST action CA15123.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Mirko Spasić.

Additional information

Publisher’s note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Rights and permissions

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Spasić, M., Janičić, M.V. Verification supported refactoring of embedded sql. Software Qual J 29, 629–665 (2021). https://doi.org/10.1007/s11219-020-09517-y

Download citation

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s11219-020-09517-y

Keywords

Navigation