forked from sqlancer/sqlancer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMaterializeOracleFactory.java
More file actions
70 lines (63 loc) · 2.96 KB
/
Copy pathMaterializeOracleFactory.java
File metadata and controls
70 lines (63 loc) · 2.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package sqlancer.materialize;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import sqlancer.OracleFactory;
import sqlancer.common.oracle.CompositeTestOracle;
import sqlancer.common.oracle.NoRECOracle;
import sqlancer.common.oracle.TLPWhereOracle;
import sqlancer.common.oracle.TestOracle;
import sqlancer.common.query.ExpectedErrors;
import sqlancer.materialize.gen.MaterializeCommon;
import sqlancer.materialize.gen.MaterializeExpressionGenerator;
import sqlancer.materialize.oracle.MaterializePivotedQuerySynthesisOracle;
import sqlancer.materialize.oracle.tlp.MaterializeTLPAggregateOracle;
import sqlancer.materialize.oracle.tlp.MaterializeTLPHavingOracle;
public enum MaterializeOracleFactory implements OracleFactory<MaterializeGlobalState> {
NOREC {
@Override
public TestOracle<MaterializeGlobalState> create(MaterializeGlobalState globalState) throws SQLException {
MaterializeExpressionGenerator gen = new MaterializeExpressionGenerator(globalState);
ExpectedErrors errors = ExpectedErrors.newErrors().with(MaterializeCommon.getCommonExpressionErrors())
.with(MaterializeCommon.getCommonFetchErrors()).with("canceling statement due to statement timeout")
.build();
return new NoRECOracle<>(globalState, gen, errors);
}
},
PQS {
@Override
public TestOracle<MaterializeGlobalState> create(MaterializeGlobalState globalState) throws SQLException {
return new MaterializePivotedQuerySynthesisOracle(globalState);
}
@Override
public boolean requiresAllTablesToContainRows() {
return true;
}
},
WHERE {
@Override
public TestOracle<MaterializeGlobalState> create(MaterializeGlobalState globalState) throws SQLException {
MaterializeExpressionGenerator gen = new MaterializeExpressionGenerator(globalState);
ExpectedErrors expectedErrors = ExpectedErrors.newErrors()
.with(MaterializeCommon.getCommonExpressionErrors()).with(MaterializeCommon.getCommonFetchErrors())
.build();
return new TLPWhereOracle<>(globalState, gen, expectedErrors);
}
},
HAVING {
@Override
public TestOracle<MaterializeGlobalState> create(MaterializeGlobalState globalState) throws SQLException {
return new MaterializeTLPHavingOracle(globalState);
}
},
QUERY_PARTITIONING {
@Override
public TestOracle<MaterializeGlobalState> create(MaterializeGlobalState globalState) throws Exception {
List<TestOracle<MaterializeGlobalState>> oracles = new ArrayList<>();
oracles.add(WHERE.create(globalState));
oracles.add(HAVING.create(globalState));
oracles.add(new MaterializeTLPAggregateOracle(globalState));
return new CompositeTestOracle<MaterializeGlobalState>(oracles, globalState);
}
};
}