Skip to content

Commit 5533c4e

Browse files
authored
Bump SQLite version to 3.40.0.0 (#652)
* bump SQLite to 3.40.0.0 * Support RIGHT/FULL JOINs
1 parent ec1cbe2 commit 5533c4e

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@
299299
<dependency>
300300
<groupId>org.xerial</groupId>
301301
<artifactId>sqlite-jdbc</artifactId>
302-
<version>3.36.0.3</version>
302+
<version>3.40.0.0</version>
303303
</dependency>
304304
<dependency>
305305
<groupId>mysql</groupId>

src/sqlancer/sqlite3/SQLite3ToStringVisitor.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,12 @@ public void visit(Join join) {
237237
case OUTER:
238238
sb.append("LEFT OUTER");
239239
break;
240+
case RIGHT:
241+
sb.append("RIGHT OUTER");
242+
break;
243+
case FULL:
244+
sb.append("FULL OUTER");
245+
break;
240246
default:
241247
throw new AssertionError(join.getType());
242248
}

src/sqlancer/sqlite3/ast/SQLite3Expression.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public SQLite3CollateSequence getExplicitCollateSequence() {
131131
public static class Join extends SQLite3Expression {
132132

133133
public enum JoinType {
134-
INNER, CROSS, OUTER, NATURAL;
134+
INNER, CROSS, OUTER, NATURAL, RIGHT, FULL;
135135
}
136136

137137
private final SQLite3Table table;

src/sqlancer/sqlite3/gen/SQLite3ExpressionGenerator.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,19 +139,25 @@ public List<Join> getRandomJoinClauses(List<SQLite3Table> tables) {
139139
if (!globalState.getDbmsSpecificOptions().testJoins) {
140140
return joinStatements;
141141
}
142+
List<JoinType> options = new ArrayList<>(Arrays.asList(JoinType.values()));
142143
if (Randomly.getBoolean() && tables.size() > 1) {
143144
int nrJoinClauses = (int) Randomly.getNotCachedInteger(0, tables.size());
145+
// Natural join is incompatible with other joins
146+
// because it needs unique column names
147+
// while other joins will produce duplicate column names
148+
if (nrJoinClauses > 1) {
149+
options.remove(JoinType.NATURAL);
150+
}
144151
for (int i = 0; i < nrJoinClauses; i++) {
145152
SQLite3Expression joinClause = generateExpression();
146153
SQLite3Table table = Randomly.fromList(tables);
147154
tables.remove(table);
148-
JoinType options;
149-
options = Randomly.fromOptions(JoinType.INNER, JoinType.CROSS, JoinType.OUTER, JoinType.NATURAL);
150-
if (options == JoinType.NATURAL) {
155+
JoinType selectedOption = Randomly.fromList(options);
156+
if (selectedOption == JoinType.NATURAL) {
151157
// NATURAL joins do not have an ON clause
152158
joinClause = null;
153159
}
154-
Join j = new SQLite3Expression.Join(table, joinClause, options);
160+
Join j = new SQLite3Expression.Join(table, joinClause, selectedOption);
155161
joinStatements.add(j);
156162
}
157163

0 commit comments

Comments
 (0)