forked from sqlancer/sqlancer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathYSQLOracleFactory.java
More file actions
72 lines (66 loc) · 2.74 KB
/
YSQLOracleFactory.java
File metadata and controls
72 lines (66 loc) · 2.74 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
71
72
package sqlancer.yugabyte.ysql;
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.TestOracle;
import sqlancer.common.query.ExpectedErrors;
import sqlancer.yugabyte.ysql.gen.YSQLExpressionGenerator;
import sqlancer.yugabyte.ysql.oracle.YSQLCatalog;
import sqlancer.yugabyte.ysql.oracle.YSQLFuzzer;
import sqlancer.yugabyte.ysql.oracle.YSQLPivotedQuerySynthesisOracle;
import sqlancer.yugabyte.ysql.oracle.tlp.YSQLTLPAggregateOracle;
import sqlancer.yugabyte.ysql.oracle.tlp.YSQLTLPHavingOracle;
import sqlancer.yugabyte.ysql.oracle.tlp.YSQLTLPWhereOracle;
public enum YSQLOracleFactory implements OracleFactory<YSQLGlobalState> {
FUZZER {
@Override
public TestOracle<YSQLGlobalState> create(YSQLGlobalState globalState) throws SQLException {
return new YSQLFuzzer(globalState);
}
},
CATALOG {
@Override
public TestOracle<YSQLGlobalState> create(YSQLGlobalState globalState) throws SQLException {
return new YSQLCatalog(globalState);
}
},
NOREC {
@Override
public TestOracle<YSQLGlobalState> create(YSQLGlobalState globalState) throws SQLException {
YSQLExpressionGenerator gen = new YSQLExpressionGenerator(globalState);
ExpectedErrors errors = ExpectedErrors.newErrors().with(YSQLErrors.getCommonExpressionErrors())
.with(YSQLErrors.getCommonFetchErrors()).with("canceling statement due to statement timeout")
.build();
return new NoRECOracle<>(globalState, gen, errors);
}
},
PQS {
@Override
public TestOracle<YSQLGlobalState> create(YSQLGlobalState globalState) throws SQLException {
return new YSQLPivotedQuerySynthesisOracle(globalState);
}
@Override
public boolean requiresAllTablesToContainRows() {
return true;
}
},
HAVING {
@Override
public TestOracle<YSQLGlobalState> create(YSQLGlobalState globalState) throws SQLException {
return new YSQLTLPHavingOracle(globalState);
}
},
QUERY_PARTITIONING {
@Override
public TestOracle<YSQLGlobalState> create(YSQLGlobalState globalState) throws SQLException {
List<TestOracle<YSQLGlobalState>> oracles = new ArrayList<>();
oracles.add(new YSQLTLPWhereOracle(globalState));
oracles.add(new YSQLTLPHavingOracle(globalState));
oracles.add(new YSQLTLPAggregateOracle(globalState));
return new CompositeTestOracle<YSQLGlobalState>(oracles, globalState);
}
}
}