Automatically Repairing SQL Faults

SQL is the standard database language, yet SQL statements can be complex and expensive to debug by hand. Automatic program repair techniques have the potential to reduce cost significantly. A previous attempt to repair SQL faults automatically used a decision tree (DT) algorithm that succeeded in some cases, but also generated many patches that passed the automated tests but that were not acceptable to the engineers. This paper proposes a novel fault localization and repair technique to repair faulty SQL statements. It targets faults in two common SQL constructs, JOIN and WHERE. It identifies the fault location and type precisely, and then creates a patch to fix the fault. We implemented this technique in a tool, and evaluated it on five medium to large-scale databases using 825 faulty queries with various complexity and faulty types. Experimental results showed that this technique can identify and repair JOIN faults when the DT approach is infeasible, and repair WHERE faults at about the same rate as the DT approach. Moreover, patches generated by our approach are more acceptable to engineers, and the tool is much faster.

[1]  Name M. Lastname Automatically Finding Patches Using Genetic Programming , 2013 .

[2]  Alexander A. Sapozhenko,et al.  On Some Operations of Partial Monotone Boolean Function Simplifying , 1987, FCT.

[3]  Martin Monperrus,et al.  A critical review of "automatic patch generation learned from human-written patches": essay on the problem statement and the evaluation of automatic software repair , 2014, ICSE.

[4]  Hung Viet Nguyen,et al.  Database-Aware Fault Localization for Dynamic Web Applications , 2013, 2013 IEEE International Conference on Software Maintenance.

[5]  Amihai Motro,et al.  Localizing Faults in SQL Predicates , 2017, 2017 IEEE International Conference on Software Testing, Verification and Validation (ICST).

[6]  Rajiv Gupta,et al.  Fault localization using value replacement , 2008, ISSTA '08.

[7]  Mary Jean Harrold,et al.  Empirical evaluation of the tarantula automatic fault-localization technique , 2005, ASE.

[8]  Mangala Gowri Nanda,et al.  Fault localization for data-centric programs , 2011, ESEC/FSE '11.

[9]  Jaechang Nam,et al.  Automatic patch generation learned from human-written patches , 2013, 2013 35th International Conference on Software Engineering (ICSE).

[10]  Martin Monperrus,et al.  Automatic Software Repair , 2018, ACM Comput. Surv..

[11]  Sarfraz Khurshid,et al.  Data-guided repair of selection statements , 2014, ICSE.

[12]  A.J.C. van Gemund,et al.  On the Accuracy of Spectrum-based Fault Localization , 2007, Testing: Academic and Industrial Conference Practice and Research Techniques - MUTATION (TAICPART-MUTATION 2007).

[13]  W. Eric Wong,et al.  Using Mutation to Automatically Suggest Fixes for Faulty Programs , 2010, 2010 Third International Conference on Software Testing, Verification and Validation.

[14]  Gregory M. Kapfhammer,et al.  Localizing SQL faults in database applications , 2011, 2011 26th IEEE/ACM International Conference on Automated Software Engineering (ASE 2011).

[15]  A. Jefferson Offutt,et al.  Introduction to Software Testing , 2008 .

[16]  J. Ross Quinlan,et al.  Induction of Decision Trees , 1986, Machine Learning.

[17]  A. Jefferson Offutt,et al.  Test Oracle Strategies for Model-Based Testing , 2017, IEEE Transactions on Software Engineering.

[18]  David J. DeWitt,et al.  X-Diff: an effective change detection algorithm for XML documents , 2003, Proceedings 19th International Conference on Data Engineering (Cat. No.03CH37405).

[19]  Dawei Qi,et al.  SemFix: Program repair via semantic analysis , 2013, 2013 35th International Conference on Software Engineering (ICSE).

[20]  Rajiv Gupta,et al.  BugFix: A learning-based tool to assist developers in fixing bugs , 2009, 2009 IEEE 17th International Conference on Program Comprehension.