@@ -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