Skip to content

Commit

Permalink
add more tidb error merssage
Browse files Browse the repository at this point in the history
add more tidb error merssage

format

checkstyle pass

Added some expected TiDB error messages

format

Update CockroachDB to v20.2.8 and enable tests

CockroachDB tests were disabled after they revealed a bug in v20.2.6,
cockroachdb/cockroach#62281. This bug was
fixed and v20.2.8. This commit updates the CockroachDB version and
enables the tests.
  • Loading branch information
wan1y committed Apr 27, 2021
1 parent 630a0c6 commit b40faf8
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 13 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,13 @@ jobs:
run: mvn -B package -DskipTests=true
- name: Set up CockroachDB
run: |
wget -qO- https://binaries.cockroachdb.com/cockroach-v20.2.6.linux-amd64.tgz | tar xvz
cd cockroach-v20.2.6.linux-amd64/ && ./cockroach start-single-node --insecure &
wget -qO- https://binaries.cockroachdb.com/cockroach-v20.2.8.linux-amd64.tgz | tar xvz
cd cockroach-v20.2.8.linux-amd64/ && ./cockroach start-single-node --insecure &
sleep 10
- name: Create SQLancer user
run: cd cockroach-v20.2.6.linux-amd64/ && ./cockroach sql --insecure -e "CREATE USER sqlancer; GRANT admin to sqlancer" && cd ..
run: cd cockroach-v20.2.8.linux-amd64/ && ./cockroach sql --insecure -e "CREATE USER sqlancer; GRANT admin to sqlancer" && cd ..
- name: Run Tests
run: COCKROACHDB_AVAILABLE=true mvn -Dtest=TestCockroachDB test

duckdb:
name: DBMS Tests (DuckDB)
Expand Down
3 changes: 3 additions & 0 deletions src/sqlancer/tidb/TiDBErrors.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public static void addExpressionErrors(ExpectedErrors errors) {
errors.add("BIGINT value is out of range");
errors.add("doesn't have a default value"); // default

errors.add("is not valid for CHARACTER SET");

// known issue: https://github.com/pingcap/tidb/issues/14819
errors.add("Wrong plan type for dataReaderBuilder");

Expand Down Expand Up @@ -69,6 +71,7 @@ public static void addInsertErrors(ExpectedErrors errors) {
errors.add("Incorrect bigint value");
errors.add("Incorrect decimal value");
errors.add("error parsing regexp");
errors.add("is not valid for CHARACTER SET");

if (true) {
// https://github.com/tidb-challenge-program/bug-hunting-issue/issues/54
Expand Down
3 changes: 3 additions & 0 deletions src/sqlancer/tidb/TiDBSchema.java
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,9 @@ private static TiDBCompositeDataType getColumnType(String typeString) {
} else {
switch (trimmedStringType) {
case "text":
case "mediumtext":
case "longtext":
case "tinytext":
primitiveType = TiDBDataType.TEXT;
break;
case "float":
Expand All @@ -223,6 +225,7 @@ private static TiDBCompositeDataType getColumnType(String typeString) {
break;
case "blob":
case "longblob":
case "tinyblob":
primitiveType = TiDBDataType.BLOB;
break;
default:
Expand Down
19 changes: 15 additions & 4 deletions src/sqlancer/tidb/gen/TiDBAlterTableGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static SQLQueryAdapter getQuery(TiDBGlobalState globalState) {
throw new IgnoreMeException();
}
sb.append(column.getName());
errors.add("with index covered now");
errors.add("with composite index covered or Primary Key covered now");
errors.add("Unsupported drop integer primary key");
errors.add("has a generated column dependency");
errors.add(
Expand All @@ -67,15 +67,27 @@ public static SQLQueryAdapter getQuery(TiDBGlobalState globalState) {
}
errors.add("Unsupported drop integer primary key");
errors.add("Unsupported drop primary key when alter-primary-key is false");
errors.add("Unsupported drop primary key when the table's pkIsHandle is true");
errors.add("Incorrect table definition; there can be only one auto column and it must be defined as a key");
sb.append(" DROP PRIMARY KEY");
break;
case ADD_PRIMARY_KEY:
sb.append("ADD PRIMARY KEY(");
sb.append(table.getRandomNonEmptyColumnSubset().stream().map(c -> c.getName())
.collect(Collectors.joining(", ")));
sb.append(table.getRandomNonEmptyColumnSubset().stream().map(c -> {
StringBuilder colName = new StringBuilder(c.getName());
if (c.getType().getPrimitiveDataType() == TiDBDataType.TEXT
|| c.getType().getPrimitiveDataType() == TiDBDataType.BLOB) {
TiDBTableGenerator.appendSpecifiers(colName, c.getType().getPrimitiveDataType());
}
return colName;
}).collect(Collectors.joining(", ")));
sb.append(")");
errors.add("Unsupported add primary key, alter-primary-key is false");
errors.add("Information schema is changed during the execution of the statement");
errors.add("Multiple primary key defined");
errors.add("Invalid use of NULL value");
errors.add("Duplicate entry");
errors.add("'Defining a virtual generated column as primary key' is not supported for generated columns");
break;
case CHANGE:
if (TiDBBugs.bug10) {
Expand All @@ -101,7 +113,6 @@ public static SQLQueryAdapter getQuery(TiDBGlobalState globalState) {
default:
throw new AssertionError(a);
}

return new SQLQueryAdapter(sb.toString(), errors, true);
}

Expand Down
13 changes: 7 additions & 6 deletions src/sqlancer/tidb/gen/TiDBAnalyzeTableGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ public static SQLQueryAdapter getQuery(TiDBGlobalState globalState) throws SQLEx
sb.append(Randomly.getNotCachedInteger(1, 1024));
sb.append(" BUCKETS");
}
return new SQLQueryAdapter(sb.toString(), ExpectedErrors.from("https://github.com/pingcap/tidb/issues/15993",
/* https://github.com/pingcap/tidb/issues/15993 */ "doesn't have a default value" /*
* https://github.
* com/pingcap/tidb/
* issues/15993
*/));
return new SQLQueryAdapter(sb.toString(),
ExpectedErrors.from("https://github.com/pingcap/tidb/issues/15993",
/* https://github.com/pingcap/tidb/issues/15993 */ "doesn't have a default value",
"Index 'PRIMARY' in field list does not exist in table" /*
* https://github. com/pingcap/tidb/
* issues/15993
*/));
}

}
2 changes: 2 additions & 0 deletions src/sqlancer/tidb/gen/TiDBDeleteGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public static SQLQueryAdapter getQuery(TiDBGlobalState globalState) throws SQLEx
sb.append(Randomly.getNotCachedInteger(0, Integer.MAX_VALUE));
}
errors.add("Bad Number");
errors.add("Truncated incorrect"); // https://github.com/pingcap/tidb/issues/24292
errors.add("is not valid for CHARACTER SET");
errors.add("Division by 0");
errors.add("error parsing regexp");
return new SQLQueryAdapter(sb.toString(), errors);
Expand Down

0 comments on commit b40faf8

Please sign in to comment.