Skip to content

Commit ebda730

Browse files
committed
Add boolean flag for drop db force
1 parent 5766078 commit ebda730

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/sqlancer/postgres/PostgresProvider.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,8 @@ public SQLConnection createDatabase(PostgresGlobalState globalState) throws SQLE
277277
globalState.getState().logStatement(String.format("\\c %s;", entryDatabaseName));
278278

279279
String dropCommand = "DROP DATABASE";
280-
if (Randomly.getBoolean()) {
280+
boolean forceDrop = Randomly.getBoolean();
281+
if (forceDrop) {
281282
dropCommand += " FORCE";
282283
}
283284
dropCommand += " IF EXISTS " + databaseName;
@@ -287,7 +288,7 @@ public SQLConnection createDatabase(PostgresGlobalState globalState) throws SQLE
287288
s.execute(dropCommand);
288289
} catch (SQLException e) {
289290
// If force fails, fall back to regular drop
290-
if (dropCommand.contains("FORCE")) {
291+
if (forceDrop) {
291292
String fallbackDrop = "DROP DATABASE IF EXISTS " + databaseName;
292293
globalState.getState().logStatement(fallbackDrop + ";");
293294
try (Statement s = con.createStatement()) {

0 commit comments

Comments
 (0)