Skip to content

Commit 781b1e6

Browse files
authored
Merge pull request #1354 from splf-jojo/fix/postgres-tablespace-qpg-path
Do not return null when PostgreSQL tablespaces are disabled
2 parents fc442ec + 9b739c0 commit 781b1e6

2 files changed

Lines changed: 30 additions & 2 deletions

File tree

src/sqlancer/postgres/gen/PostgresTableSpaceGenerator.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package sqlancer.postgres.gen;
22

3+
import sqlancer.IgnoreMeException;
34
import sqlancer.common.query.ExpectedErrors;
45
import sqlancer.common.query.SQLQueryAdapter;
56
import sqlancer.postgres.PostgresGlobalState;
@@ -19,10 +20,12 @@ public PostgresTableSpaceGenerator(PostgresGlobalState globalState) {
1920
}
2021

2122
public static SQLQueryAdapter generate(PostgresGlobalState globalState) {
22-
// Skip tablespace generation if the option is disabled
23+
// PostgresProvider.mapActions does not schedule this action when the option is disabled, but QPG
24+
// selects actions by index without consulting the schedule, so the generator has to report that
25+
// it has nothing to generate.
2326
PostgresOptions options = globalState.getDbmsSpecificOptions();
2427
if (!options.isTestTablespaces()) {
25-
return null;
28+
throw new IgnoreMeException();
2629
}
2730
return new PostgresTableSpaceGenerator(globalState).generateTableSpace();
2831
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package sqlancer.postgres.gen;
2+
3+
import static org.junit.jupiter.api.Assertions.assertThrows;
4+
5+
import org.junit.jupiter.api.Test;
6+
7+
import sqlancer.IgnoreMeException;
8+
import sqlancer.postgres.PostgresGlobalState;
9+
import sqlancer.postgres.PostgresOptions;
10+
11+
class TestPostgresTableSpaceGenerator {
12+
13+
@Test
14+
void generateIsSkippedWhenTablespacesAreDisabled() {
15+
PostgresGlobalState state = new PostgresGlobalState();
16+
state.setDbmsSpecificOptions(new PostgresOptions() {
17+
@Override
18+
public boolean isTestTablespaces() {
19+
return false;
20+
}
21+
});
22+
23+
assertThrows(IgnoreMeException.class, () -> PostgresTableSpaceGenerator.generate(state));
24+
}
25+
}

0 commit comments

Comments
 (0)