Skip to content

Commit 4b45629

Browse files
committed
adding the help text and modifing the default values of host and port
1 parent 17e79ae commit 4b45629

13 files changed

Lines changed: 39 additions & 39 deletions

src/sqlancer/MainOptions.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ public class MainOptions {
5050
private String password = "sqlancer"; // NOPMD
5151

5252
@Parameter(names = "--host", description = "The host used to log into the DBMS")
53-
private String host = "sqlancer"; // NOPMD
53+
private String host = null; // NOPMD
5454

5555
@Parameter(names = "--port", description = "The port used to log into the DBMS")
56-
private String port = "sqlancer"; // NOPMD
56+
private int port = -1; // NOPMD
5757

5858
@Parameter(names = "--print-progress-information", description = "Whether to print progress information such as the number of databases generated or queries issued", arity = 1)
5959
private boolean printProgressInformation = true; // NOPMD
@@ -161,7 +161,7 @@ public String getHost() {
161161
return host;
162162
}
163163

164-
public String getPort() {
164+
public int getPort() {
165165
return port;
166166
}
167167

src/sqlancer/clickhouse/ClickHouseOptions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import sqlancer.clickhouse.oracle.tlp.ClickHouseTLPWhereOracle;
1919
import sqlancer.common.oracle.TestOracle;
2020

21-
@Parameters(separators = "=", commandDescription = "ClickHouse")
21+
@Parameters(separators = "=", commandDescription = "ClickHouse (default port: 8123, default host: localhost)")
2222
public class ClickHouseOptions implements DBMSSpecificOptions<ClickHouseOracleFactory> {
2323

2424
@Parameter(names = "--oracle")

src/sqlancer/clickhouse/ClickHouseProvider.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
public class ClickHouseProvider extends SQLProviderAdapter<ClickHouseGlobalState, ClickHouseOptions> {
2424
protected String host;
25-
protected String port;
25+
protected int port;
2626

2727
public ClickHouseProvider() {
2828
super(ClickHouseGlobalState.class, ClickHouseOptions.class);
@@ -106,17 +106,17 @@ public void generateDatabase(ClickHouseGlobalState globalState) throws Exception
106106
public SQLConnection createDatabase(ClickHouseGlobalState globalState) throws SQLException {
107107
host = globalState.getOptions().getHost();
108108
port = globalState.getOptions().getPort();
109-
if ("sqlancer".equals(host)) {
109+
if (host == null) {
110110
host = "localhost";
111111
}
112-
if ("sqlancer".equals(port)) {
113-
port = "8123";
112+
if (port == -1) {
113+
port = 8123;
114114
}
115115

116116
ClickHouseOptions clickHouseOptions = globalState.getDmbsSpecificOptions();
117117
globalState.setClickHouseOptions(clickHouseOptions);
118118
// String url = "jdbc:clickhouse://localhost:8123/default";
119-
String url = String.format("jdbc:clickhouse://%s:%s/default", host, port);
119+
String url = String.format("jdbc:clickhouse://%s:%d/default", host, port);
120120
// String url = "jdbc:clickhouse://" + host + ":" + port + "/default";
121121
String databaseName = globalState.getDatabaseName();
122122
Connection con = DriverManager.getConnection(url, globalState.getOptions().getUserName(),

src/sqlancer/cockroachdb/CockroachDBOptions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import sqlancer.common.oracle.CompositeTestOracle;
2424
import sqlancer.common.oracle.TestOracle;
2525

26-
@Parameters(separators = "=", commandDescription = "Test CockroachDB")
26+
@Parameters(separators = "=", commandDescription = "CockroachDB (default port: 26257, default host: localhost)")
2727
public class CockroachDBOptions implements DBMSSpecificOptions<CockroachDBOracleFactory> {
2828

2929
@Parameter(names = "--oracle")

src/sqlancer/cockroachdb/CockroachDBProvider.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
public class CockroachDBProvider extends SQLProviderAdapter<CockroachDBGlobalState, CockroachDBOptions> {
3838
protected String host;
39-
protected String port;
39+
protected int port;
4040

4141
public CockroachDBProvider() {
4242
super(CockroachDBGlobalState.class, CockroachDBOptions.class);
@@ -252,16 +252,16 @@ public void generateDatabase(CockroachDBGlobalState globalState) throws Exceptio
252252
public SQLConnection createDatabase(CockroachDBGlobalState globalState) throws SQLException {
253253
host = globalState.getOptions().getHost();
254254
port = globalState.getOptions().getPort();
255-
if ("sqlancer".equals(host)) {
255+
if (host == null) {
256256
host = "localhost";
257257
}
258-
if ("sqlancer".equals(port)) {
259-
port = "26257";
258+
if (port == -1) {
259+
port = 26257;
260260
}
261261
String databaseName = globalState.getDatabaseName();
262262
// String url = "jdbc:postgresql://localhost:26257/test";
263263
// String url = "jdbc:postgresql://" + host + ":" + port + "/test";
264-
String url = String.format("jdbc:postgresql://%s:%s/test", host, port);
264+
String url = String.format("jdbc:postgresql://%s:%d/test", host, port);
265265
Connection con = DriverManager.getConnection(url, globalState.getOptions().getUserName(),
266266
globalState.getOptions().getPassword());
267267
globalState.getState().logStatement("USE test");

src/sqlancer/mariadb/MariaDBOptions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import sqlancer.mariadb.MariaDBProvider.MariaDBGlobalState;
1515
import sqlancer.mariadb.oracle.MariaDBNoRECOracle;
1616

17-
@Parameters
17+
@Parameters(separators = "=", commandDescription = "MariaDB (default port: 3306, default host: localhost)")
1818
public class MariaDBOptions implements DBMSSpecificOptions<MariaDBOracleFactory> {
1919

2020
@Parameter(names = "--oracle")

src/sqlancer/mariadb/MariaDBProvider.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class MariaDBProvider extends SQLProviderAdapter<MariaDBGlobalState, Mari
3030
protected String username;
3131
protected String password;
3232
protected String host;
33-
protected String port;
33+
protected int port;
3434

3535
public MariaDBProvider() {
3636
super(MariaDBGlobalState.class, MariaDBOptions.class);
@@ -177,14 +177,14 @@ public SQLConnection createDatabase(MariaDBGlobalState globalState) throws SQLEx
177177
password = globalState.getOptions().getPassword();
178178
host = globalState.getOptions().getHost();
179179
port = globalState.getOptions().getPort();
180-
if ("sqlancer".equals(host)) {
180+
if (host == null) {
181181
host = "localhost";
182182
}
183-
if ("sqlancer".equals(port)) {
184-
port = "3306";
183+
if (port == -1) {
184+
port = 3306;
185185
}
186186
// String url = "jdbc:mariadb://" + host + ":" + port;
187-
String url = String.format("jdbc:mariadb://%s:%s", host, port);
187+
String url = String.format("jdbc:mariadb://%s:%d", host, port);
188188
Connection con = DriverManager.getConnection(url, username, password);
189189
try (Statement s = con.createStatement()) {
190190
s.execute("DROP DATABASE IF EXISTS " + globalState.getDatabaseName());

src/sqlancer/mysql/MySQLOptions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import sqlancer.mysql.oracle.MySQLPivotedQuerySynthesisOracle;
1515
import sqlancer.mysql.oracle.MySQLTLPWhereOracle;
1616

17-
@Parameters
17+
@Parameters(separators = "=", commandDescription = "MySQL (default port: 3306, default host: localhost)")
1818
public class MySQLOptions implements DBMSSpecificOptions<MySQLOracleFactory> {
1919

2020
@Parameter(names = "--oracle")

src/sqlancer/mysql/MySQLProvider.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class MySQLProvider extends SQLProviderAdapter<MySQLGlobalState, MySQLOpt
3434
protected String username;
3535
protected String password;
3636
protected String host;
37-
protected String port;
37+
protected int port;
3838

3939
public MySQLProvider() {
4040
super(MySQLGlobalState.class, MySQLOptions.class);
@@ -157,19 +157,19 @@ public SQLConnection createDatabase(MySQLGlobalState globalState) throws SQLExce
157157
password = globalState.getOptions().getPassword();
158158
host = globalState.getOptions().getHost();
159159
port = globalState.getOptions().getPort();
160-
if ("sqlancer".equals(host)) {
160+
if (host == null) {
161161
host = "localhost";
162162
}
163-
if ("sqlancer".equals(port)) {
164-
port = "3306";
163+
if (port == -1) {
164+
port = 3306;
165165
}
166166
String databaseName = globalState.getDatabaseName();
167167
globalState.getState().logStatement("DROP DATABASE IF EXISTS " + databaseName);
168168
globalState.getState().logStatement("CREATE DATABASE " + databaseName);
169169
globalState.getState().logStatement("USE " + databaseName);
170170
// String url = "jdbc:mysql://" + host + ":" + port
171171
// + "?serverTimezone=UTC&useSSL=false&allowPublicKeyRetrieval=true";
172-
String url = String.format("jdbc:mysql://%s:%s?serverTimezone=UTC&useSSL=false&allowPublicKeyRetrieval=true",
172+
String url = String.format("jdbc:mysql://%s:%d?serverTimezone=UTC&useSSL=false&allowPublicKeyRetrieval=true",
173173
host, port);
174174
Connection con = DriverManager.getConnection(url, username, password);
175175
try (Statement s = con.createStatement()) {

src/sqlancer/postgres/PostgresOptions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import sqlancer.postgres.oracle.tlp.PostgresTLPHavingOracle;
2020
import sqlancer.postgres.oracle.tlp.PostgresTLPWhereOracle;
2121

22-
@Parameters
22+
@Parameters(separators = "=", commandDescription = "PostgreSQL (default port: 5432, default host: localhost)")
2323
public class PostgresOptions implements DBMSSpecificOptions<PostgresOracleFactory> {
2424

2525
@Parameter(names = "--bulk-insert", description = "Specifies whether INSERT statements should be issued in bulk", arity = 1)

0 commit comments

Comments
 (0)