Skip to content

Commit a79b291

Browse files
improve
1 parent 62adb13 commit a79b291

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

_posts/2023-07-22-gsoc-sqlancer-final.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ tags:
1010

1111
## Overview
1212

13-
SQLancer generates a large number of statements, but not all of them are relevant to the bug. To automatically reduce the test cases, [Yutan Yang](https://github.com/ColinYoungTaro) implemented two reducers in SQLancer, the statement reducer and the AST-based reducer.
13+
SQLancer generates a large number of statements, but not all of them are relevant to the bug. To automatically reduce the test cases, I implemented two reducers in SQLancer, the statement reducer and the AST-based reducer.
1414

1515

1616
## Statement Reducer
@@ -26,21 +26,31 @@ Using the statement reducer, SQLancer reduces the set of statements to a minimal
2626
## AST-Based Reducer
2727

2828
The AST-based reducer can shorten a statement by applying AST level transformations. They are mostly implemented using [JSQLParser](https://github.com/JSQLParser/JSqlParser), a RDBMS agnostic SQL statement parser that can translate SQL statements into a traversable hierarchy of Java classes. JSQLParser provides support for the SQL standard as well as major SQL dialects. The AST-based reducer works for any SQL dialects that can be parsed by this tool.
29-
q
3029

3130
Currently, the AST-based transformations include:
3231

3332
+ Remove union selects. e.g.,
33+
3434
`SELECT 1 UNION SELECT 2` -> `SELECT 1`
35+
3536
+ Remove irrelevant clauses. e.g.,
37+
3638
`SELECT * FROM t OFFSET 20 LIMIT 5` -> `SELECT * FROM t`
39+
3740
+ Remove list elements. e.g.,
41+
3842
`SELECT a, b, c FROM t` -> `SELECT a FROM t`
39-
+ Remove rows of an insert statement. e.g.,
43+
44+
+ Remove rows of an insert statement. e.g.,
45+
4046
`INSERT INTO t VALUES (1, 2), (3, 4)` -> `INSERT INTO t VALUES (1, 2)`
47+
4148
+ Replace complicated expressions with their sub expressions. e.g.,
49+
4250
`(a+b)+c` -> `c`
43-
+ Simplify constant values. e.g.,
51+
52+
+ Simplify constant values. e.g.,
53+
4454
`3.27842156` -> `3.278`
4555

4656
The AST-based reducer is designed with extensibility. It walks through the list of transformations and applies them to statements until a fixed point is reached. Adding new transformations is straightforward. Simply create a new transformation and include it in the list. This flexibility allows for easy customization and expansion of the reducer's functionality. Additionally, it is also possible to support transformations that do not depend on JSQLParser.
@@ -49,7 +59,7 @@ The AST-based reducer is designed with extensibility. It walks through the list
4959

5060
## Framework for reducers Testing
5161

52-
Yutan designed a virtual database engine to facilitate the testing of reducers. Instead of executing the statements, this engine records them for analysis. One of its notable features is the ability to customize the conditions that trigger a bug. For instance, the testing framework allows specifying an interestingness check that tests whether certain words are part of the reduced SQL test case.
62+
I designed a virtual database engine to facilitate the testing of reducers. Instead of executing the statements, this engine records them for analysis. One of its notable features is the ability to customize the conditions that trigger a bug. For instance, the testing framework allows specifying an interestingness check that tests whether certain words are part of the reduced SQL test case.
5363

5464
This approach provides a testing environment and allows for thorough evaluation of the reducers' performance. It offers convenience and flexibility in refining and polishing the functionality of the reducers without impacting real databases.
5565

@@ -68,4 +78,4 @@ Note: if `--reduce-ast` is set, `--use-reducer` option must be enabled first.
6878

6979
There are also options to define timeout seconds and max steps of reduction for both statement reducer and AST-based reducer.
7080

71-
For more details, you can refer to this [doc](https://github.com/sqlancer/sqlancer/blob/main/docs/testCaseReduction.md).
81+
For more details, you can refer to this [doc](https://github.com/sqlancer/sqlancer/blob/7804a3adec0962ad6d24687c42ec473aa49669fe/docs/testCaseReduction.md).

0 commit comments

Comments
 (0)