Skip to content

Commit d0b4218

Browse files
committed
Add a method to allow the oracle factory to indicate that each table must contains at least one row
1 parent 44fe7d8 commit d0b4218

File tree

5 files changed

+34
-4
lines changed

5 files changed

+34
-4
lines changed

src/sqlancer/OracleFactory.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,13 @@ public interface OracleFactory<G extends GlobalState<?, ?>> {
88

99
TestOracle create(G globalState) throws SQLException;
1010

11+
/**
12+
* Indicates whether the test oracle requires that all tables (including views) contain at least one row.
13+
*
14+
* @return whether the test oracle requires at least one row per table
15+
*/
16+
default boolean requiresAllTablesToContainRows() {
17+
return false;
18+
}
19+
1120
}

src/sqlancer/common/oracle/TestOracle.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,4 @@ public interface TestOracle {
66

77
void check() throws SQLException;
88

9-
default boolean onlyWorksForNonEmptyTables() {
10-
return false;
11-
}
12-
139
}

src/sqlancer/mysql/MySQLOptions.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import sqlancer.OracleFactory;
1212
import sqlancer.common.oracle.TestOracle;
1313
import sqlancer.mysql.MySQLOptions.MySQLOracleFactory;
14+
import sqlancer.mysql.oracle.MySQLPivotedQuerySynthesisOracle;
1415
import sqlancer.mysql.oracle.MySQLTLPWhereOracle;
1516

1617
@Parameters
@@ -28,6 +29,19 @@ public TestOracle create(MySQLGlobalState globalState) throws SQLException {
2829
return new MySQLTLPWhereOracle(globalState);
2930
}
3031

32+
},
33+
PQS {
34+
35+
@Override
36+
public TestOracle create(MySQLGlobalState globalState) throws SQLException {
37+
return new MySQLPivotedQuerySynthesisOracle(globalState);
38+
}
39+
40+
@Override
41+
public boolean requiresAllTablesToContainRows() {
42+
return true;
43+
}
44+
3145
}
3246
}
3347

src/sqlancer/postgres/PostgresOptions.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ public TestOracle create(PostgresGlobalState globalState) throws SQLException {
4646
public TestOracle create(PostgresGlobalState globalState) throws SQLException {
4747
return new PostgresPivotedQuerySynthesisOracle(globalState);
4848
}
49+
50+
@Override
51+
public boolean requiresAllTablesToContainRows() {
52+
return true;
53+
}
4954
},
5055
HAVING {
5156

src/sqlancer/sqlite3/SQLite3Options.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ public enum SQLite3OracleFactory implements OracleFactory<SQLite3GlobalState> {
9494
public TestOracle create(SQLite3GlobalState globalState) throws SQLException {
9595
return new SQLite3PivotedQuerySynthesisOracle(globalState);
9696
}
97+
98+
@Override
99+
public boolean requiresAllTablesToContainRows() {
100+
return true;
101+
}
102+
97103
},
98104
NoREC {
99105
@Override

0 commit comments

Comments
 (0)