|
8 | 8 | import sqlancer.Randomly; |
9 | 9 | import sqlancer.common.ast.BinaryOperatorNode; |
10 | 10 | import sqlancer.common.gen.NoRECGenerator; |
| 11 | +import sqlancer.common.gen.TLPWhereGenerator; |
11 | 12 | import sqlancer.common.gen.TypedExpressionGenerator; |
12 | 13 | import sqlancer.common.schema.AbstractTables; |
13 | 14 | import sqlancer.hsqldb.HSQLDBProvider; |
|
26 | 27 |
|
27 | 28 | public final class HSQLDBExpressionGenerator extends |
28 | 29 | TypedExpressionGenerator<HSQLDBExpression, HSQLDBSchema.HSQLDBColumn, HSQLDBSchema.HSQLDBCompositeDataType> |
29 | | - implements NoRECGenerator<HSQLDBSelect, HSQLDBJoin, HSQLDBExpression, HSQLDBTable, HSQLDBColumn> { |
| 30 | + implements NoRECGenerator<HSQLDBSelect, HSQLDBJoin, HSQLDBExpression, HSQLDBTable, HSQLDBColumn>, |
| 31 | + TLPWhereGenerator<HSQLDBSelect, HSQLDBJoin, HSQLDBExpression, HSQLDBTable, HSQLDBColumn> { |
30 | 32 |
|
31 | 33 | List<HSQLDBTable> tables; |
32 | 34 |
|
@@ -205,8 +207,7 @@ public List<HSQLDBExpression> generateOrderBys() { |
205 | 207 | } |
206 | 208 |
|
207 | 209 | @Override |
208 | | - public NoRECGenerator<HSQLDBSelect, HSQLDBJoin, HSQLDBExpression, HSQLDBTable, HSQLDBColumn> setTablesAndColumns( |
209 | | - AbstractTables<HSQLDBTable, HSQLDBColumn> tables) { |
| 210 | + public HSQLDBExpressionGenerator setTablesAndColumns(AbstractTables<HSQLDBTable, HSQLDBColumn> tables) { |
210 | 211 | this.columns = tables.getColumns(); |
211 | 212 | this.tables = tables.getTables(); |
212 | 213 |
|
@@ -289,4 +290,13 @@ public String generateUnoptimizedQueryString(HSQLDBSelect select, HSQLDBExpressi |
289 | 290 | select.setWhereClause(null); |
290 | 291 | return "SELECT SUM(count) FROM (" + select.asString() + ") as res"; |
291 | 292 | } |
| 293 | + |
| 294 | + @Override |
| 295 | + public List<HSQLDBExpression> generateFetchColumns(boolean shouldCreateDummy) { |
| 296 | + if (shouldCreateDummy) { |
| 297 | + return List.of(new HSQLDBColumnReference(new HSQLDBSchema.HSQLDBColumn("*", null, null))); |
| 298 | + } |
| 299 | + return Randomly |
| 300 | + .nonEmptySubset(columns.stream().map(c -> new HSQLDBColumnReference(c)).collect(Collectors.toList())); |
| 301 | + } |
292 | 302 | } |
0 commit comments