Skip to content

Commit b8dbd9d

Browse files
committed
fix the false positive in CODDTest for SQLite
1 parent 2f0c1ee commit b8dbd9d

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/sqlancer/sqlite3/oracle/SQLite3CODDTestOracle.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ public SQLite3CODDTestOracle(SQLite3GlobalState globalState) {
9494
public void check() throws SQLException {
9595
reproducer = null;
9696

97+
joinsInExpr = null;
98+
tablesFromOuterContext.clear();
99+
97100
useSubqueryAsFoldedExpr = useSubquery();
98101
useCorrelatedSubqueryAsFoldedExpr = useCorrelatedSubquery();
99102

@@ -168,8 +171,7 @@ else if (auxiliaryQueryResult.size() == 1 && auxiliaryQueryResult.get(auxiliaryQ
168171
foldedResult = getQueryResult(foldedQueryString, state);
169172
}
170173
// one column
171-
else if (auxiliaryQueryResult.size() == 1 && Randomly.getBooleanWithRatherLowProbability()) {
172-
// else if (auxiliaryQueryResult.size() == 1 && false) {
174+
else if (auxiliaryQueryResult.size() == 1 && Randomly.getBooleanWithRatherLowProbability() && testInOperator()) {
173175
// original query
174176
List<SQLite3Column> columns = s.getRandomTableNonEmptyTables().getColumns();
175177
SQLite3ColumnName selectedColumn = new SQLite3ColumnName(Randomly.fromList(columns), null);
@@ -277,9 +279,11 @@ private SQLite3Select genSelectExpression(SQLite3Table tempTable, SQLite3Express
277279
gen = new SQLite3ExpressionGenerator(state).setColumns(columns);
278280
List<SQLite3Table> tables = randomTables.getTables();
279281
List<Join> joinStatements = new ArrayList<>();
280-
if ((!useSubqueryAsFoldedExpr || (useSubqueryAsFoldedExpr && useCorrelatedSubqueryAsFoldedExpr)) && this.joinsInExpr != null) {
281-
joinStatements.addAll(this.joinsInExpr);
282-
this.joinsInExpr = null;
282+
if (!useSubqueryAsFoldedExpr || (useSubqueryAsFoldedExpr && useCorrelatedSubqueryAsFoldedExpr)) {
283+
if (this.joinsInExpr != null) {
284+
joinStatements.addAll(this.joinsInExpr);
285+
this.joinsInExpr = null;
286+
}
283287
}
284288
else if (Randomly.getBoolean()) {
285289
joinStatements = genJoinExpression(gen, tables, Randomly.getBooleanWithRatherLowProbability() ? specificCondition : null, false);
@@ -950,6 +954,9 @@ public boolean testDerivedTable() {
950954
public boolean testInsert() {
951955
return false;
952956
}
957+
public boolean testInOperator() {
958+
return false;
959+
}
953960

954961
@Override
955962
public String getLastQueryString() {

0 commit comments

Comments
 (0)