Skip to content

Commit 2f0c1ee

Browse files
committed
fix a typo and remove some redundant code of CODDTest for sqlite3
1 parent 17952a4 commit 2f0c1ee

File tree

4 files changed

+22
-61
lines changed

4 files changed

+22
-61
lines changed

src/sqlancer/sqlite3/SQLite3ExpectedValueVisitor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ public void visit(SQLite3SetClause set) {
313313
@Override
314314
public void visit(SQLite3Alias alias) {
315315
print(alias);
316-
print(alias.getOrigonalExpression());
316+
print(alias.getOriginalExpression());
317317
print(alias.getAliasExpression());
318318
}
319319

src/sqlancer/sqlite3/SQLite3ToStringVisitor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ public void visit(SQLite3SetClause set) {
512512
@Override
513513
public void visit(SQLite3Alias alias) {
514514
sb.append("(");
515-
visit(alias.getOrigonalExpression());
515+
visit(alias.getOriginalExpression());
516516
sb.append(")");
517517
sb.append(" AS ");
518518
visit(alias.getAliasExpression());

src/sqlancer/sqlite3/ast/SQLite3Expression.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1593,11 +1593,11 @@ public SQLite3CollateSequence getExplicitCollateSequence() {
15931593

15941594
public static class SQLite3Alias extends SQLite3Expression {
15951595

1596-
private SQLite3Expression origonalExpression;
1596+
private SQLite3Expression originalExpression;
15971597
private SQLite3Expression aliasExpression;
15981598

1599-
public SQLite3Alias(SQLite3Expression origonalExpression, SQLite3Expression aliasExpression) {
1600-
this.origonalExpression = origonalExpression;
1599+
public SQLite3Alias(SQLite3Expression originalExpression, SQLite3Expression aliasExpression) {
1600+
this.originalExpression = originalExpression;
16011601
this.aliasExpression = aliasExpression;
16021602
}
16031603

@@ -1606,8 +1606,8 @@ public SQLite3CollateSequence getExplicitCollateSequence() {
16061606
return null;
16071607
}
16081608

1609-
public SQLite3Expression getOrigonalExpression() {
1610-
return origonalExpression;
1609+
public SQLite3Expression getOriginalExpression() {
1610+
return originalExpression;
16111611
}
16121612

16131613
public SQLite3Expression getAliasExpression() {

src/sqlancer/sqlite3/oracle/SQLite3CODDTestOracle.java

Lines changed: 15 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public void check() throws SQLException {
100100
SQLite3Select auxiliaryQuery = null;
101101
if (useSubqueryAsFoldedExpr) {
102102
if (useCorrelatedSubqueryAsFoldedExpr) {
103-
auxiliaryQuery = genSelectWithCorrelatedSubquery(null, null);
103+
auxiliaryQuery = genSelectWithCorrelatedSubquery();
104104
auxiliaryQueryString = SQLite3Visitor.asString(auxiliaryQuery);
105105

106106
auxiliaryQueryResult.putAll(selectResult);
@@ -110,7 +110,7 @@ public void check() throws SQLException {
110110
auxiliaryQueryResult = getQueryResult(auxiliaryQueryString, state);
111111
}
112112
} else {
113-
auxiliaryQuery = genSimpleSelect(null, null);
113+
auxiliaryQuery = genSimpleSelect();
114114
auxiliaryQueryString = SQLite3Visitor.asString(auxiliaryQuery);
115115

116116
auxiliaryQueryResult.putAll(selectResult);
@@ -334,40 +334,18 @@ else if (Randomly.getBoolean()) {
334334
}
335335

336336
// For expression test
337-
private SQLite3Select genSimpleSelect(SQLite3Table tempTable, SQLite3Expression specificCondition) {
337+
private SQLite3Select genSimpleSelect() {
338338
SQLite3Tables randomTables = s.getRandomTableNonEmptyTables();
339-
if (tempTable != null) {
340-
randomTables.addTable(tempTable);
341-
}
342-
if (!useSubqueryAsFoldedExpr) {
343-
for (SQLite3Table t : this.tablesFromOuterContext) {
344-
randomTables.addTable(t);
345-
}
346-
if (this.joinsInExpr != null) {
347-
for (Join j : this.joinsInExpr) {
348-
SQLite3Table t = j.getTable();
349-
randomTables.removeTable(t);
350-
}
351-
}
352-
}
353-
354339
List<SQLite3Column> columns = randomTables.getColumns();
355-
if (!useSubqueryAsFoldedExpr && this.joinsInExpr != null) {
356-
for (Join j : this.joinsInExpr) {
357-
SQLite3Table t = j.getTable();
358-
columns.addAll(t.getColumns());
359-
}
360-
}
340+
361341
gen = new SQLite3ExpressionGenerator(state).setColumns(columns);
362342
List<SQLite3Table> tables = randomTables.getTables();
363343
tablesFromOuterContext = randomTables.getTables();
364344

365-
if (joinsInExpr == null) {
366-
if (Randomly.getBooleanWithRatherLowProbability()) {
367-
joinsInExpr = genJoinExpression(gen, tables, null, true);
368-
} else {
369-
joinsInExpr = new ArrayList<Join>();
370-
}
345+
if (Randomly.getBooleanWithRatherLowProbability()) {
346+
joinsInExpr = genJoinExpression(gen, tables, null, true);
347+
} else {
348+
joinsInExpr = new ArrayList<Join>();
371349
}
372350

373351
List<SQLite3Expression> tableRefs = SQLite3Common.getTableRefs(tables, s);
@@ -378,10 +356,6 @@ private SQLite3Select genSimpleSelect(SQLite3Table tempTable, SQLite3Expression
378356
}
379357

380358
SQLite3Expression whereCondition = gen.generateExpression();
381-
if (specificCondition != null) {
382-
BinaryOperator operator = BinaryOperator.getRandomOperator();
383-
whereCondition = new SQLite3Expression.Sqlite3BinaryOperation(whereCondition, specificCondition, operator);
384-
}
385359
this.foldedExpr = whereCondition;
386360

387361
List<SQLite3Expression> fetchColumns = new ArrayList<>();
@@ -401,11 +375,9 @@ private SQLite3Select genSimpleSelect(SQLite3Table tempTable, SQLite3Expression
401375

402376
select.setFetchColumns(fetchColumns);
403377

404-
originalQueryString = SQLite3Visitor.asString(select);
405-
406378
Map<String, List<SQLite3Constant>> queryRes = null;
407379
try {
408-
queryRes = getQueryResult(originalQueryString, state);
380+
queryRes = getQueryResult(SQLite3Visitor.asString(select), state);
409381
} catch (SQLException e) {
410382
if (errors.errorIsExpected(e.getMessage())) {
411383
throw new IgnoreMeException();
@@ -429,7 +401,7 @@ private SQLite3Select genSimpleSelect(SQLite3Table tempTable, SQLite3Expression
429401
for (int i = 0; i < fetchColumns.size() - 1; ++i) {
430402
// do not put the last fetch column to values
431403
SQLite3Alias cAlias = (SQLite3Alias) fetchColumns.get(i);
432-
SQLite3ColumnName cRef = (SQLite3ColumnName) cAlias.getOrigonalExpression();
404+
SQLite3ColumnName cRef = (SQLite3ColumnName) cAlias.getOriginalExpression();
433405
SQLite3Column column = cRef.getColumn();
434406
String columnName = SQLite3Visitor.asString(cAlias.getAliasExpression());
435407
SQLite3Column newColumn = new SQLite3Column(columnName, column.getType(), false, false, null);
@@ -448,17 +420,10 @@ private SQLite3Select genSimpleSelect(SQLite3Table tempTable, SQLite3Expression
448420
return select;
449421
}
450422

451-
private SQLite3Select genSelectWithCorrelatedSubquery(SQLite3Table selectedTable, SQLite3Expression specificCondition) {
452-
// do not support join now
453-
this.joinsInExpr = new ArrayList<Join>();
454-
423+
private SQLite3Select genSelectWithCorrelatedSubquery() {
455424
SQLite3Tables outerQueryRandomTables = s.getRandomTableNonEmptyTables();
456425
SQLite3Tables innerQueryRandomTables = s.getRandomTableNonEmptyTables();
457426

458-
if (selectedTable != null) {
459-
innerQueryRandomTables.addTable(selectedTable);
460-
}
461-
462427
List<SQLite3Expression> innerQueryFromTables = new ArrayList<>();
463428
for (SQLite3Table t : innerQueryRandomTables.getTables()) {
464429
if (!outerQueryRandomTables.isContained(t)) {
@@ -494,10 +459,6 @@ private SQLite3Select genSelectWithCorrelatedSubquery(SQLite3Table selectedTable
494459
innerQuery.setFromList(innerQueryFromTables);
495460

496461
SQLite3Expression innerQueryWhereCondition = gen.generateExpression();
497-
if (specificCondition != null) {
498-
BinaryOperator operator = BinaryOperator.getRandomOperator();
499-
innerQueryWhereCondition = new SQLite3Expression.Sqlite3BinaryOperation(innerQueryWhereCondition, specificCondition, operator);
500-
}
501462
innerQuery.setWhereClause(innerQueryWhereCondition);
502463

503464
// use aggregate function in fetch column
@@ -506,10 +467,10 @@ private SQLite3Select genSelectWithCorrelatedSubquery(SQLite3Table selectedTable
506467
SQLite3Expression innerQueryAggrName = new SQLite3Aggregate(Arrays.asList(innerQueryAggr), SQLite3Aggregate.SQLite3AggregateFunction.getRandom());
507468
innerQuery.setFetchColumns(Arrays.asList(innerQueryAggrName));
508469
if (Randomly.getBooleanWithRatherLowProbability()) {
509-
List<SQLite3Expression> groupByClause = genGroupByClause(innerQueryColumns, specificCondition);
470+
List<SQLite3Expression> groupByClause = genGroupByClause(innerQueryColumns, null);
510471
innerQuery.setGroupByClause(groupByClause);
511472
if (groupByClause.size() > 0 && Randomly.getBooleanWithRatherLowProbability()) {
512-
innerQuery.setHavingClause(genHavingClause(innerQueryColumns, specificCondition));
473+
innerQuery.setHavingClause(genHavingClause(innerQueryColumns, null));
513474
}
514475
}
515476

@@ -566,7 +527,7 @@ private SQLite3Select genSelectWithCorrelatedSubquery(SQLite3Table selectedTable
566527
for (int i = 0; i < outerQueryFetchColumns.size() - 1; ++i) {
567528
// do not put the last fetch column to values
568529
SQLite3Alias cAlias = (SQLite3Alias) outerQueryFetchColumns.get(i);
569-
SQLite3ColumnName cRef = (SQLite3ColumnName) cAlias.getOrigonalExpression();
530+
SQLite3ColumnName cRef = (SQLite3ColumnName) cAlias.getOriginalExpression();
570531
SQLite3Column column = cRef.getColumn();
571532
String columnName = SQLite3Visitor.asString(cAlias.getAliasExpression());
572533
SQLite3Column newColumn = new SQLite3Column(columnName, column.getType(), false, false, null);
@@ -930,7 +891,7 @@ private Map<Integer, SQLite3DataType> getColumnTypeFromSelect(SQLite3Select sele
930891
for(SQLite3Expression column : fetchColumns) {
931892
newFetchColumns.add(column);
932893
SQLite3Alias columnAlias = (SQLite3Alias) column;
933-
SQLite3Expression typeofColumn = new SQLite3Typeof(columnAlias.getOrigonalExpression());
894+
SQLite3Expression typeofColumn = new SQLite3Typeof(columnAlias.getOriginalExpression());
934895
newFetchColumns.add(typeofColumn);
935896
}
936897
SQLite3Select newSelect = new SQLite3Select(select);

0 commit comments

Comments
 (0)