Skip to content

Commit

Permalink
Bump SQLite version to 3.40.0.0 (#652)
Browse files Browse the repository at this point in the history
* bump SQLite to 3.40.0.0

* Support RIGHT/FULL JOINs
  • Loading branch information
bajinsheng committed Dec 17, 2022
1 parent ec1cbe2 commit 5533c4e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -299,7 +299,7 @@
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.36.0.3</version>
<version>3.40.0.0</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
Expand Down
6 changes: 6 additions & 0 deletions src/sqlancer/sqlite3/SQLite3ToStringVisitor.java
Expand Up @@ -237,6 +237,12 @@ public void visit(Join join) {
case OUTER:
sb.append("LEFT OUTER");
break;
case RIGHT:
sb.append("RIGHT OUTER");
break;
case FULL:
sb.append("FULL OUTER");
break;
default:
throw new AssertionError(join.getType());
}
Expand Down
2 changes: 1 addition & 1 deletion src/sqlancer/sqlite3/ast/SQLite3Expression.java
Expand Up @@ -131,7 +131,7 @@ public SQLite3CollateSequence getExplicitCollateSequence() {
public static class Join extends SQLite3Expression {

public enum JoinType {
INNER, CROSS, OUTER, NATURAL;
INNER, CROSS, OUTER, NATURAL, RIGHT, FULL;
}

private final SQLite3Table table;
Expand Down
14 changes: 10 additions & 4 deletions src/sqlancer/sqlite3/gen/SQLite3ExpressionGenerator.java
Expand Up @@ -139,19 +139,25 @@ public List<Join> getRandomJoinClauses(List<SQLite3Table> tables) {
if (!globalState.getDbmsSpecificOptions().testJoins) {
return joinStatements;
}
List<JoinType> options = new ArrayList<>(Arrays.asList(JoinType.values()));
if (Randomly.getBoolean() && tables.size() > 1) {
int nrJoinClauses = (int) Randomly.getNotCachedInteger(0, tables.size());
// Natural join is incompatible with other joins
// because it needs unique column names
// while other joins will produce duplicate column names
if (nrJoinClauses > 1) {
options.remove(JoinType.NATURAL);
}
for (int i = 0; i < nrJoinClauses; i++) {
SQLite3Expression joinClause = generateExpression();
SQLite3Table table = Randomly.fromList(tables);
tables.remove(table);
JoinType options;
options = Randomly.fromOptions(JoinType.INNER, JoinType.CROSS, JoinType.OUTER, JoinType.NATURAL);
if (options == JoinType.NATURAL) {
JoinType selectedOption = Randomly.fromList(options);
if (selectedOption == JoinType.NATURAL) {
// NATURAL joins do not have an ON clause
joinClause = null;
}
Join j = new SQLite3Expression.Join(table, joinClause, options);
Join j = new SQLite3Expression.Join(table, joinClause, selectedOption);
joinStatements.add(j);
}

Expand Down

0 comments on commit 5533c4e

Please sign in to comment.