FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Add Support for Merge Generator in Postgres v15 by yaojiejia · Pull Request #1255 · sqlancer/sqlancer · GitHub

Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .java  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
10 changes: 7 additions & 3 deletions src/sqlancer/postgres/PostgresProvider.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import sqlancer.postgres.gen.PostgresExplainGenerator;
import sqlancer.postgres.gen.PostgresIndexGenerator;
import sqlancer.postgres.gen.PostgresInsertGenerator;
import sqlancer.postgres.gen.PostgresMergeGenerator;
import sqlancer.postgres.gen.PostgresNotifyGenerator;
import sqlancer.postgres.gen.PostgresReindexGenerator;
import sqlancer.postgres.gen.PostgresSequenceGenerator;
Expand Down Expand Up @@ -104,6 +105,7 @@ public enum Action implements AbstractAction<PostgresGlobalState> {
DISCARD(PostgresDiscardGenerator::create), //
DROP_INDEX(PostgresDropIndexGenerator::create), //
INSERT(PostgresInsertGenerator::insert), //
MERGE(PostgresMergeGenerator::merge), //
UPDATE(PostgresUpdateGenerator::create), //
TRUNCATE(PostgresTruncateGenerator::create), //
VACUUM(PostgresVacuumGenerator::create), //
Expand Down Expand Up @@ -193,6 +195,9 @@ protected static int mapActions(PostgresGlobalState globalState, Action a) {
case UPDATE:
nrPerformed = r.getInteger(0, 10);
break;
case MERGE:
nrPerformed = r.getInteger(0, 5);
break;
case INSERT:
nrPerformed = r.getInteger(0, globalState.getOptions().getMaxNumberInserts());
break;
Expand Down Expand Up @@ -279,14 +284,13 @@ public SQLConnection createDatabase(PostgresGlobalState globalState) throws SQLE
}
Connection con = DriverManager.getConnection("jdbc:" + entryURL, username, password);
globalState.getState().logStatement(String.format("\\c %s;", entryDatabaseName));

String dropCommand = "DROP DATABASE";
boolean forceDrop = Randomly.getBoolean();
if (forceDrop) {
dropCommand += " FORCE";
}
dropCommand += " IF EXISTS " + databaseName;

globalState.getState().logStatement(dropCommand + ";");
try (Statement s = con.createStatement()) {
s.execute(dropCommand);
Expand All @@ -302,7 +306,7 @@ public SQLConnection createDatabase(PostgresGlobalState globalState) throws SQLE
throw e;
}
}

// Create database section
createDatabaseCommand = getCreateDatabaseCommand(globalState);
globalState.getState().logStatement(createDatabaseCommand + ";");
Expand Down
Loading

Back | FazBrowse Home | New Git URL