Skip to content

Commit 1bbbe79

Browse files
committed
clean comments
1 parent 120bc07 commit 1bbbe79

14 files changed

Lines changed: 28 additions & 64 deletions

src/sqlancer/ComparatorHelper.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,10 @@ public static List<String> getResultSetFirstColumnAsString(String queryString, E
5959
while (result.next()) {
6060
String resultTemp = result.getString(1);
6161
if (resultTemp != null) {
62-
resultTemp = resultTemp.replaceAll("[\\.]0+$", "");
62+
resultTemp = resultTemp.replaceAll("[\\.]0+$", ""); // Remove the trailing zeros as many DBMS treat
63+
// it as non-bugs
6364
}
64-
resultSet.add(resultTemp); // Remove the trailing zeros as many DBMS treat it as non-bugs
65+
resultSet.add(resultTemp);
6566
}
6667
} catch (Exception e) {
6768
if (e instanceof IgnoreMeException) {

src/sqlancer/SQLProviderAdapter.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,19 @@ protected void checkViewsAreValid(G globalState) {
2626
SQLQueryAdapter q = new SQLQueryAdapter("SELECT 1 FROM " + view.getName() + " LIMIT 1");
2727
try {
2828
if (!q.execute(globalState)) {
29-
throw new AssertionError();
29+
dropView(globalState, view.getName());
3030
}
3131
} catch (Throwable t) {
32-
try {
33-
globalState.executeStatement(new SQLQueryAdapter("DROP VIEW " + view.getName(), true));
34-
} catch (Throwable t2) {
35-
throw new IgnoreMeException();
36-
}
32+
dropView(globalState, view.getName());
3733
}
3834
}
3935
}
36+
37+
private void dropView(G globalState, String viewName) {
38+
try {
39+
globalState.executeStatement(new SQLQueryAdapter("DROP VIEW " + viewName, true));
40+
} catch (Throwable t2) {
41+
throw new IgnoreMeException();
42+
}
43+
}
4044
}

src/sqlancer/cockroachdb/CockroachDBErrors.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,6 @@ private static void addArrayErrors(ExpectedErrors errors) {
246246
errors.add("unimplemented: nested arrays not supported"); // e.g., casting a string {{1}} to an array
247247
errors.add("malformed array");
248248

249-
// errors.add("https://github.com/cockroachdb/cockroach/issues/35707"); // arrays don't support ORDER BY
250-
251249
errors.add("as bytes[], found type: varbit[]");
252250
errors.add("to be of type decimal[], found type float[]");
253251
errors.add("to be of type int[], found type decimal[]");

src/sqlancer/cockroachdb/CockroachDBSchema.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ public static CockroachDBSchema fromConnection(SQLConnection con, String databas
293293
for (CockroachDBColumn c : databaseColumns) {
294294
c.setTable(t);
295295
}
296-
// To avoid some situations that columns can not be got.
296+
// To avoid some situations that columns can not be retrieved.
297297
if (databaseColumns.isEmpty()) {
298298
continue;
299299
}

src/sqlancer/cockroachdb/gen/CockroachDBSetClusterSettingGenerator.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,9 @@ private CockroachDBSetClusterSettingGenerator() {
1515

1616
// https://www.cockroachlabs.com/docs/stable/set-vars.html
1717
private enum CockroachDBClusterSetting {
18-
// BUFFER_INCREMENT("kv.bulk_ingest.buffer_increment", (g) -> "'" + Randomly.getUncachedDouble() + "'"),
1918
BACKPRESSURE_RANGE_SIZE_MULTIPLIER(" kv.range.backpressure_range_size_multiplier",
2019
(g) -> Randomly.getNotCachedInteger(0, Integer.MAX_VALUE)),
2120
RANGE_DESCRIPTOR_CACHE_SIZE("kv.range_descriptor_cache.size", (g) -> Randomly.getNonCachedInteger()),
22-
// SQL_DEFAULTS_VECTORIZE_ROW_COUNT_THRESHOLD("sql.defaults.vectorize_row_count_threshold",
23-
// (g) -> Randomly.getNotCachedInteger(0, Integer.MAX_VALUE)),
24-
// SQL_DEFAULTS_EXPERIMENTAL_OPTIMIZER_FOREIGN_KEYS_ENABLED("sql.defaults.experimental_optimizer_foreign_keys.enabled",
25-
// CockroachDBSetSessionGenerator::onOff),
2621
SQL_QUERY_CACHE_ENABLED("sql.query_cache.enabled", CockroachDBSetSessionGenerator::onOff),
2722
SQL_STATS_HISTOGRAM_COLLECTION_ENABLED("sql.stats.histogram_collection.enabled",
2823
CockroachDBSetSessionGenerator::onOff);

src/sqlancer/cockroachdb/gen/CockroachDBSetSessionGenerator.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ private enum CockroachDBSetting {
2525
ENABLE_IMPLICIT_SELECT_FOR_UPDATE(CockroachDBSetSessionGenerator::onOff),
2626
ENABLE_INSERT_FAST_PATH(CockroachDBSetSessionGenerator::onOff),
2727
ENABLE_ZIGZAG_JOIN(CockroachDBSetSessionGenerator::onOff),
28-
// EXPERIMENTAL_ENABLE_HASH_SHARDED_INDEXES(CockroachDBSetSessionGenerator::onOff),
2928
SERIAL_NORMALIZATION((g) -> Randomly.fromOptions("'rowid'", "'virtual_sequence'")),
30-
// EXTRA_FLOAT_DIGITS((g) -> g.getRandomly().getInteger(-15, 3)),
3129
REORDER_JOINS_LIMIT((g) -> g.getRandomly().getInteger(0, Integer.MAX_VALUE)), //
3230
SQL_SAFE_UPDATES((g) -> "off"), TRACING(CockroachDBSetSessionGenerator::onOff),
3331
/*

src/sqlancer/cockroachdb/gen/CockroachDBTruncateGenerator.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ public static SQLQueryAdapter truncate(CockroachDBGlobalState globalState) {
1515
ExpectedErrors errors = new ExpectedErrors();
1616
errors.add("is referenced by foreign key");
1717

18-
// https://github.com/cockroachdb/cockroach/issues/47030
19-
// errors.add("unexpected value: <nil>");
2018
StringBuilder sb = new StringBuilder();
2119
sb.append("TRUNCATE");
2220
if (Randomly.getBoolean()) {

src/sqlancer/common/query/SQLQueryAdapter.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,17 @@ public String getUnterminatedQueryString() {
9696
}
9797

9898
public void checkException(Exception e) throws AssertionError {
99-
if (!expectedErrors.errorIsExpected(e.getMessage())) {
100-
throw new AssertionError(query, e);
99+
Throwable ex = e;
100+
101+
while (ex != null) {
102+
if (expectedErrors.errorIsExpected(ex.getMessage())) {
103+
return;
104+
} else {
105+
ex = ex.getCause();
106+
}
101107
}
108+
109+
throw new AssertionError(query, e);
102110
}
103111

104112
@Override

src/sqlancer/tidb/TiDBErrors.java

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,9 @@ public static void addExpressionErrors(ExpectedErrors errors) {
2121
// functions
2222
errors.add("BIGINT value is out of range");
2323
errors.add("doesn't have a default value"); // default
24-
2524
errors.add("is not valid for CHARACTER SET");
26-
27-
// known issue: https://github.com/pingcap/tidb/issues/14819
28-
// errors.add("Wrong plan type for dataReaderBuilder");
29-
3025
errors.add("DOUBLE value is out of range");
3126

32-
// errors.add("index out of range"); // https://github.com/pingcap/tidb/issues/15810
33-
// errors.add("baseBuiltinFunc.evalString() should never be called, please contact the TiDB team for help"); //
34-
// https://github.com/pingcap/tidb/issues/15847
35-
// errors.add("unsupport column type for encode 6"); // https://github.com/pingcap/tidb/issues/15850
36-
3727
errors.add("Data truncation: %s value is out of range in '%s'");
3828
errors.add("Truncated incorrect FLOAT value");
3929
errors.add("Bad Number");
@@ -47,13 +37,6 @@ public static void addExpressionErrors(ExpectedErrors errors) {
4737
errors.add("Can\'t find column"); // https://github.com/pingcap/tidb/issues/35527
4838
errors.add("Cannot convert"); // https://github.com/pingcap/tidb/issues/35652
4939

50-
// https://github.com/tidb-challenge-program/bug-hunting-issue/issues/57
51-
// errors.add("For input string: \"+Inf\"");
52-
53-
// errors.add("inconsistent index"); // https://github.com/tidb-challenge-program/bug-hunting-issue/issues/58
54-
55-
// errors.add("Illegal mix of collations");
56-
5740
if (TiDBBugs.bug35677) {
5841
errors.add("for function inet_aton");
5942
}
@@ -92,11 +75,6 @@ public static void addInsertErrors(ExpectedErrors errors) {
9275
errors.add("Incorrect decimal value");
9376
errors.add("error parsing regexp");
9477
errors.add("is not valid for CHARACTER SET");
95-
96-
// if (true) {
97-
// // https://github.com/tidb-challenge-program/bug-hunting-issue/issues/54
98-
// errors.add("Miss column");
99-
// }
10078
}
10179

10280
}

src/sqlancer/tidb/TiDBSchema.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,7 @@ private static List<TiDBColumn> getTableColumns(SQLConnection con, String tableN
334334
columns.add(c);
335335
}
336336
}
337-
} catch (SQLException e) {
338-
337+
} catch (SQLException e) { // Happens when
339338
}
340339
return columns;
341340
}

0 commit comments

Comments
 (0)