-
Notifications
You must be signed in to change notification settings - Fork 397
Expand file tree
/
Copy pathCitusOracleFactory.java
More file actions
70 lines (65 loc) · 3.18 KB
/
CitusOracleFactory.java
File metadata and controls
70 lines (65 loc) · 3.18 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.citus;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import sqlancer.OracleFactory;
import sqlancer.citus.gen.CitusCommon;
import sqlancer.citus.oracle.tlp.CitusTLPAggregateOracle;
import sqlancer.citus.oracle.tlp.CitusTLPHavingOracle;
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.postgres.PostgresGlobalState;
import sqlancer.postgres.gen.PostgresCommon;
import sqlancer.postgres.gen.PostgresExpressionGenerator;
import sqlancer.postgres.oracle.PostgresPivotedQuerySynthesisOracle;
public enum CitusOracleFactory implements OracleFactory<PostgresGlobalState> {
NOREC {
@Override
public TestOracle<PostgresGlobalState> create(PostgresGlobalState globalState) throws SQLException {
PostgresExpressionGenerator gen = new PostgresExpressionGenerator(globalState);
ExpectedErrors errors = ExpectedErrors.newErrors().with(PostgresCommon.getCommonExpressionErrors())
.with(PostgresCommon.getCommonFetchErrors())
.withRegex(PostgresCommon.getCommonExpressionRegexErrors())
.with(CitusCommon.getCitusErrors().toArray(new String[0])).build();
return new NoRECOracle<>(globalState, gen, errors);
}
},
PQS {
@Override
public TestOracle<PostgresGlobalState> create(PostgresGlobalState globalState) throws SQLException {
return new PostgresPivotedQuerySynthesisOracle(globalState);
}
},
WHERE {
@Override
public TestOracle<PostgresGlobalState> create(PostgresGlobalState globalState) throws SQLException {
PostgresExpressionGenerator gen = new PostgresExpressionGenerator(globalState);
ExpectedErrors expectedErrors = ExpectedErrors.newErrors().with(PostgresCommon.getCommonExpressionErrors())
.with(PostgresCommon.getCommonFetchErrors())
.withRegex(PostgresCommon.getCommonExpressionRegexErrors()).with(CitusCommon.getCitusErrors())
.build();
return new TLPWhereOracle<>(globalState, gen, expectedErrors);
}
},
HAVING {
@Override
public TestOracle<PostgresGlobalState> create(PostgresGlobalState globalState) throws SQLException {
CitusGlobalState citusGlobalState = (CitusGlobalState) globalState;
return new CitusTLPHavingOracle(citusGlobalState);
}
},
QUERY_PARTITIONING {
@Override
public TestOracle<PostgresGlobalState> create(PostgresGlobalState globalState) throws Exception {
CitusGlobalState citusGlobalState = (CitusGlobalState) globalState;
List<TestOracle<PostgresGlobalState>> oracles = new ArrayList<>();
oracles.add(WHERE.create(citusGlobalState));
oracles.add(HAVING.create(citusGlobalState));
oracles.add(new CitusTLPAggregateOracle(citusGlobalState));
return new CompositeTestOracle<PostgresGlobalState>(oracles, globalState);
}
};
}