Skip to content

Commit d27c86a

Browse files
committed
Address the newly-appearing expected errors
1 parent 669569e commit d27c86a

10 files changed

Lines changed: 20 additions & 13 deletions

src/sqlancer/cockroachdb/gen/CockroachDBIndexGenerator.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public void buildStatement() {
2828
errors.add("schema change statement cannot follow a statement that has written in the same transaction");
2929
errors.add("https://github.com/cockroachdb/cockroach/issues/35730"); // some array types are not indexable
3030
errors.add("cannot determine type of empty array. Consider annotating with the desired type");
31+
errors.add("incompatible IF expression"); // TODO: investigate; seems to be a bug
3132
CockroachDBTable table = globalState.getSchema().getRandomTable(t -> !t.isView());
3233
sb.append("CREATE ");
3334
if (Randomly.getBoolean()) {

src/sqlancer/mariadb/gen/MariaDBSetGenerator.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import sqlancer.MainOptions;
99
import sqlancer.Randomly;
10+
import sqlancer.common.query.ExpectedErrors;
1011
import sqlancer.common.query.Query;
1112
import sqlancer.common.query.QueryAdapter;
1213

@@ -190,7 +191,8 @@ private Query get() {
190191
sb.append(a.name);
191192
sb.append(" = ");
192193
sb.append(a.prod.apply(r));
193-
return new QueryAdapter(sb.toString());
194+
return new QueryAdapter(sb.toString(), ExpectedErrors
195+
.from("At least one of the 'in_to_exists' or 'materialization' optimizer_switch flags must be 'on'"));
194196
}
195197

196198
}

src/sqlancer/postgres/gen/PostgresSetGenerator.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ private enum ConfigurationOption {
6666
// https://www.postgresql.org/docs/devel/runtime-config-query.html
6767
ENABLE_BITMAPSCAN("enable_bitmapscan", (r) -> Randomly.fromOptions(1, 0)),
6868
ENABLE_GATHERMERGE("enable_gathermerge", (r) -> Randomly.fromOptions(1, 0)),
69-
ENABLE_HASHAGG("enable_hashagg", (r) -> Randomly.fromOptions(1, 0)),
70-
ENABLE_HASHAGG_DISK("enable_hashagg_disk", (r) -> Randomly.fromOptions(1, 0)),
7169
ENABLE_HASHJOIN("enable_hashjoin", (r) -> Randomly.fromOptions(1, 0)),
7270
ENABLE_INDEXSCAN("enable_indexscan", (r) -> Randomly.fromOptions(1, 0)),
7371
ENABLE_INDEXONLYSCAN("enable_indexonlyscan", (r) -> Randomly.fromOptions(1, 0)),

src/sqlancer/sqlite3/SQLite3Provider.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public boolean canBeRetried() {
9898
CHECK_RTREE_TABLE((g) -> {
9999
SQLite3Table table = g.getSchema().getRandomTableOrBailout(t -> t.getName().startsWith("r"));
100100
String format = String.format("SELECT rtreecheck('%s');", table.getName());
101-
return new QueryAdapter(format);
101+
return new QueryAdapter(format, ExpectedErrors.from("The database file is locked"));
102102
}), //
103103
VIRTUAL_TABLE_ACTION(SQLite3VirtualFTSTableCommandGenerator::create), //
104104
CREATE_VIEW(SQLite3ViewGenerator::generate), //
@@ -120,6 +120,8 @@ public boolean canBeRetried() {
120120
}
121121
indexName = rs.getString("name");
122122
}
123+
} catch (SQLException e) {
124+
throw new IgnoreMeException();
123125
}
124126
sb.append(" VALUES");
125127
sb.append("('");
@@ -154,7 +156,8 @@ public boolean canBeRetried() {
154156
sb.append(" noskipscan");
155157
}
156158
sb.append("')");
157-
return new QueryAdapter(sb.toString(), ExpectedErrors.from("no such table"));
159+
return new QueryAdapter(sb.toString(),
160+
ExpectedErrors.from("no such table", "The database file is locked"));
158161
}
159162
});
160163

@@ -284,7 +287,8 @@ private void checkTablesForGeneratedColumnLoops(SQLite3GlobalState globalState)
284287
Query q = new QueryAdapter("SELECT * FROM " + table.getName(),
285288
ExpectedErrors.from("needs an odd number of arguments", " requires an even number of arguments",
286289
"generated column loop", "integer overflow", "malformed JSON",
287-
"JSON cannot hold BLOB values", "JSON path error", "labels must be TEXT"));
290+
"JSON cannot hold BLOB values", "JSON path error", "labels must be TEXT",
291+
"table does not support scanning"));
288292
if (!q.execute(globalState)) {
289293
throw new IgnoreMeException();
290294
}

src/sqlancer/sqlite3/gen/SQLite3ReindexGenerator.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public static Query executeReindex(SQLite3GlobalState globalState) {
2323
SQLite3Schema s = globalState.getSchema();
2424
StringBuilder sb = new StringBuilder("REINDEX");
2525
ExpectedErrors errors = new ExpectedErrors();
26+
errors.add("The database file is locked");
2627
Target t = Randomly.fromOptions(Target.values());
2728
if (Randomly.getBoolean()) {
2829
sb.append(" ");

src/sqlancer/sqlite3/gen/SQLite3VacuumGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public static Query executeVacuum(SQLite3GlobalState globalState) {
2121
sb.append(Randomly.fromOptions("temp", "main"));
2222
}
2323
return new QueryAdapter(sb.toString(), ExpectedErrors.from("cannot VACUUM from within a transaction",
24-
"cannot VACUUM - SQL statements in progress"));
24+
"cannot VACUUM - SQL statements in progress", "The database file is locked"));
2525
}
2626

2727
}

src/sqlancer/sqlite3/gen/ddl/SQLite3IndexGenerator.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ private Query create() throws SQLException {
4444
errors.add("non-deterministic use of julianday() in an index");
4545
errors.add("non-deterministic use of date() in an index");
4646
errors.add("non-deterministic use of datetime() in an index");
47+
errors.add("The database file is locked");
4748
SQLite3Errors.addExpectedExpressionErrors(errors);
4849
if (!SQLite3Provider.mustKnowResult) {
4950
// can only happen when PRAGMA case_sensitive_like=ON;

src/sqlancer/sqlite3/gen/ddl/SQLite3ViewGenerator.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public static Query generate(SQLite3GlobalState globalState) throws SQLException
4444
ExpectedErrors errors = new ExpectedErrors();
4545
errors.add("is circularly defined");
4646
errors.add("unsupported frame specification");
47+
errors.add("The database file is locked");
4748
if (Randomly.getBoolean()) {
4849
SQLite3PivotedQuerySynthesisOracle queryGen = new SQLite3PivotedQuerySynthesisOracle(globalState);
4950
try {

src/sqlancer/sqlite3/schema/SQLite3Schema.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ public static int getNrRows(SQLite3GlobalState globalState, String table) throws
355355
errors.addAll(Arrays.asList("second argument to nth_value must be a positive integer",
356356
"ON clause references tables to its right", "no such table", "no query solution", "no such index",
357357
"GROUP BY term", "is circularly defined", "misuse of aggregate", "no such column",
358-
"misuse of window function"));
358+
"misuse of window function", "table does not support scanning"));
359359
SQLite3Errors.addExpectedExpressionErrors(errors);
360360
QueryAdapter q = new QueryAdapter(string, errors);
361361
try (SQLancerResultSet query = q.executeAndGet(globalState)) {

src/sqlancer/tidb/gen/TiDBViewGenerator.java

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

3+
import sqlancer.IgnoreMeException;
34
import sqlancer.Randomly;
45
import sqlancer.common.query.ExpectedErrors;
56
import sqlancer.common.query.Query;
@@ -40,11 +41,9 @@ public static Query getQuery(TiDBGlobalState globalState) {
4041
errors.add(
4142
"references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them");
4243
errors.add("Unknown column ");
43-
if (Randomly.getBoolean()) {
44-
sb.append(" WITH ");
45-
sb.append(Randomly.fromOptions("CASCADED", "LOCAL"));
46-
sb.append(" ");
47-
sb.append(" CHECK OPTION");
44+
if (sb.toString().contains("\\\\")) {
45+
// TODO: CREATE VIEW v0(c0) AS SELECT '\\' FROM t0; causes an unexpected failure
46+
throw new IgnoreMeException();
4847
}
4948
return new QueryAdapter(sb.toString(), errors, true);
5049
}

0 commit comments

Comments
 (0)