Skip to content

Commit db6cab5

Browse files
committed
Add a OracleFactory interface
1 parent 15fb835 commit db6cab5

File tree

8 files changed

+31
-27
lines changed

8 files changed

+31
-27
lines changed

src/sqlancer/OracleFactory.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package sqlancer;
2+
3+
import java.sql.SQLException;
4+
5+
public interface OracleFactory<G extends GlobalState<?, ?>> {
6+
7+
TestOracle create(G globalState) throws SQLException;
8+
9+
}

src/sqlancer/citus/CitusOptions.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.beust.jcommander.Parameter;
99

1010
import sqlancer.CompositeTestOracle;
11+
import sqlancer.OracleFactory;
1112
import sqlancer.TestOracle;
1213
import sqlancer.citus.oracle.CitusNoRECOracle;
1314
import sqlancer.citus.oracle.tlp.CitusTLPAggregateOracle;
@@ -23,9 +24,9 @@ public class CitusOptions extends PostgresOptions {
2324
public boolean repartition = true;
2425

2526
@Parameter(names = "--citusoracle")
26-
public List<CitusOracle> citusOracle = Arrays.asList(CitusOracle.QUERY_PARTITIONING);
27+
public List<CitusOracleFactory> citusOracle = Arrays.asList(CitusOracleFactory.QUERY_PARTITIONING);
2728

28-
public enum CitusOracle {
29+
public enum CitusOracleFactory implements OracleFactory<PostgresGlobalState> {
2930
NOREC {
3031
@Override
3132
public TestOracle create(PostgresGlobalState globalState) throws SQLException {
@@ -60,8 +61,6 @@ public TestOracle create(PostgresGlobalState globalState) throws SQLException {
6061
}
6162
};
6263

63-
public abstract TestOracle create(PostgresGlobalState globalState) throws SQLException;
64-
6564
}
6665

6766
}

src/sqlancer/clickhouse/ClickHouseOptions.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
import com.beust.jcommander.Parameters;
99

1010
import sqlancer.DBMSSpecificOptions;
11+
import sqlancer.OracleFactory;
1112
import sqlancer.TestOracle;
13+
import sqlancer.clickhouse.ClickHouseProvider.ClickHouseGlobalState;
1214
import sqlancer.clickhouse.oracle.tlp.ClickHouseTLPAggregateOracle;
1315
import sqlancer.clickhouse.oracle.tlp.ClickHouseTLPDistinctOracle;
1416
import sqlancer.clickhouse.oracle.tlp.ClickHouseTLPGroupByOracle;
@@ -19,12 +21,12 @@
1921
public class ClickHouseOptions implements DBMSSpecificOptions {
2022

2123
@Parameter(names = "--oracle")
22-
public List<ClickHouseOracle> oracle = Arrays.asList(ClickHouseOracle.TLPWhere);
24+
public List<ClickHouseOracleFactory> oracle = Arrays.asList(ClickHouseOracleFactory.TLPWhere);
2325

2426
@Parameter(names = { "--test-joins" }, description = "Allow the generation of JOIN clauses", arity = 1)
2527
public boolean testJoins = true;
2628

27-
public enum ClickHouseOracle {
29+
public enum ClickHouseOracleFactory implements OracleFactory<ClickHouseGlobalState> {
2830
TLPWhere {
2931
@Override
3032
public TestOracle create(ClickHouseProvider.ClickHouseGlobalState globalState) throws SQLException {
@@ -56,6 +58,5 @@ public TestOracle create(ClickHouseProvider.ClickHouseGlobalState globalState) t
5658
}
5759
};
5860

59-
public abstract TestOracle create(ClickHouseProvider.ClickHouseGlobalState globalState) throws SQLException;
6061
}
6162
}

src/sqlancer/cockroachdb/CockroachDBOptions.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import sqlancer.CompositeTestOracle;
1111
import sqlancer.DBMSSpecificOptions;
12+
import sqlancer.OracleFactory;
1213
import sqlancer.TestOracle;
1314
import sqlancer.cockroachdb.CockroachDBProvider.CockroachDBGlobalState;
1415
import sqlancer.cockroachdb.oracle.CockroachDBNoRECOracle;
@@ -24,9 +25,9 @@
2425
public class CockroachDBOptions implements DBMSSpecificOptions {
2526

2627
@Parameter(names = "--oracle")
27-
public CockroachDBOracle oracle = CockroachDBOracle.NOREC;
28+
public CockroachDBOracleFactory oracle = CockroachDBOracleFactory.NOREC;
2829

29-
public enum CockroachDBOracle {
30+
public enum CockroachDBOracleFactory implements OracleFactory<CockroachDBGlobalState> {
3031
NOREC {
3132
@Override
3233
public TestOracle create(CockroachDBGlobalState globalState) throws SQLException {
@@ -91,8 +92,6 @@ public TestOracle create(CockroachDBGlobalState globalState) throws SQLException
9192
}
9293
};
9394

94-
public abstract TestOracle create(CockroachDBGlobalState globalState) throws SQLException;
95-
9695
}
9796

9897
@Parameter(names = {

src/sqlancer/duckdb/DuckDBOptions.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import sqlancer.CompositeTestOracle;
1212
import sqlancer.DBMSSpecificOptions;
13+
import sqlancer.OracleFactory;
1314
import sqlancer.TestOracle;
1415
import sqlancer.duckdb.DuckDBProvider.DuckDBGlobalState;
1516
import sqlancer.duckdb.test.DuckDBNoRECOracle;
@@ -89,9 +90,9 @@ public class DuckDBOptions implements DBMSSpecificOptions {
8990
public int maxNumUpdates = 5;
9091

9192
@Parameter(names = "--oracle")
92-
public List<DuckDBOracle> oracle = Arrays.asList(DuckDBOracle.QUERY_PARTITIONING);
93+
public List<DuckDBOracleFactory> oracle = Arrays.asList(DuckDBOracleFactory.QUERY_PARTITIONING);
9394

94-
public enum DuckDBOracle {
95+
public enum DuckDBOracleFactory implements OracleFactory<DuckDBGlobalState> {
9596
NOREC {
9697

9798
@Override
@@ -145,8 +146,6 @@ public TestOracle create(DuckDBGlobalState globalState) throws SQLException {
145146
}
146147
};
147148

148-
public abstract TestOracle create(DuckDBGlobalState globalState) throws SQLException;
149-
150149
}
151150

152151
}

src/sqlancer/postgres/PostgresOptions.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import sqlancer.CompositeTestOracle;
1212
import sqlancer.DBMSSpecificOptions;
13+
import sqlancer.OracleFactory;
1314
import sqlancer.TestOracle;
1415
import sqlancer.postgres.oracle.PostgresNoRECOracle;
1516
import sqlancer.postgres.oracle.PostgresPivotedQuerySynthesisOracle;
@@ -24,15 +25,15 @@ public class PostgresOptions implements DBMSSpecificOptions {
2425
public boolean allowBulkInsert;
2526

2627
@Parameter(names = "--oracle")
27-
public List<PostgresOracle> oracle = Arrays.asList(PostgresOracle.QUERY_PARTITIONING);
28+
public List<PostgresOracleFactory> oracle = Arrays.asList(PostgresOracleFactory.QUERY_PARTITIONING);
2829

2930
@Parameter(names = "--test-collations", arity = 1)
3031
public boolean testCollations = true;
3132

3233
@Parameter(names = "--connection-url")
3334
public String connectionURL = "postgresql://localhost:5432/test";
3435

35-
public enum PostgresOracle {
36+
public enum PostgresOracleFactory implements OracleFactory<PostgresGlobalState> {
3637
NOREC {
3738
@Override
3839
public TestOracle create(PostgresGlobalState globalState) throws SQLException {
@@ -64,8 +65,6 @@ public TestOracle create(PostgresGlobalState globalState) throws SQLException {
6465
}
6566
};
6667

67-
public abstract TestOracle create(PostgresGlobalState globalState) throws SQLException;
68-
6968
}
7069

7170
}

src/sqlancer/sqlite3/SQLite3Options.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import sqlancer.CompositeTestOracle;
1111
import sqlancer.DBMSSpecificOptions;
12+
import sqlancer.OracleFactory;
1213
import sqlancer.TestOracle;
1314
import sqlancer.sqlite3.SQLite3Provider.SQLite3GlobalState;
1415
import sqlancer.sqlite3.oracle.SQLite3Fuzzer;
@@ -71,7 +72,7 @@ public class SQLite3Options implements DBMSSpecificOptions {
7172
public boolean testDistinctInView;
7273

7374
@Parameter(names = "--oracle")
74-
public SQLite3Oracle oracle = SQLite3Oracle.NoREC;
75+
public SQLite3OracleFactory oracle = SQLite3OracleFactory.NoREC;
7576

7677
@Parameter(names = {
7778
"--delete-existing-databases" }, description = "Delete a database file if it already exists", arity = 1)
@@ -85,7 +86,7 @@ public class SQLite3Options implements DBMSSpecificOptions {
8586
"--execute-queries" }, description = "Specifies whether the query in the fuzzer should be executed", arity = 1)
8687
public boolean executeQuery = true;
8788

88-
public enum SQLite3Oracle {
89+
public enum SQLite3OracleFactory implements OracleFactory<SQLite3GlobalState> {
8990
PQS {
9091
@Override
9192
public TestOracle create(SQLite3GlobalState globalState) throws SQLException {
@@ -151,8 +152,6 @@ public TestOracle create(SQLite3GlobalState globalState) throws SQLException {
151152
}
152153
};
153154

154-
public abstract TestOracle create(SQLite3GlobalState globalState) throws SQLException;
155-
156155
}
157156

158157
}

src/sqlancer/tidb/TiDBOptions.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import sqlancer.CompositeTestOracle;
1212
import sqlancer.DBMSSpecificOptions;
13+
import sqlancer.OracleFactory;
1314
import sqlancer.TestOracle;
1415
import sqlancer.tidb.TiDBProvider.TiDBGlobalState;
1516
import sqlancer.tidb.oracle.TiDBTLPHavingOracle;
@@ -19,9 +20,9 @@
1920
public class TiDBOptions implements DBMSSpecificOptions {
2021

2122
@Parameter(names = "--oracle")
22-
public List<TiDBOracle> oracle = Arrays.asList(TiDBOracle.QUERY_PARTITIONING);
23+
public List<TiDBOracleFactory> oracle = Arrays.asList(TiDBOracleFactory.QUERY_PARTITIONING);
2324

24-
public enum TiDBOracle {
25+
public enum TiDBOracleFactory implements OracleFactory<TiDBGlobalState> {
2526
HAVING {
2627
@Override
2728
public TestOracle create(TiDBGlobalState globalState) throws SQLException {
@@ -44,8 +45,6 @@ public TestOracle create(TiDBGlobalState globalState) throws SQLException {
4445
}
4546
};
4647

47-
public abstract TestOracle create(TiDBGlobalState globalState) throws SQLException;
48-
4948
}
5049

5150
}

0 commit comments

Comments
 (0)