diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 91a96365b..61458f894 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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) diff --git a/src/sqlancer/tidb/TiDBErrors.java b/src/sqlancer/tidb/TiDBErrors.java index fa09f11a9..bb3d3ca62 100644 --- a/src/sqlancer/tidb/TiDBErrors.java +++ b/src/sqlancer/tidb/TiDBErrors.java @@ -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"); @@ -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 diff --git a/src/sqlancer/tidb/TiDBSchema.java b/src/sqlancer/tidb/TiDBSchema.java index 4d04369c2..a611543fc 100644 --- a/src/sqlancer/tidb/TiDBSchema.java +++ b/src/sqlancer/tidb/TiDBSchema.java @@ -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": @@ -223,6 +225,7 @@ private static TiDBCompositeDataType getColumnType(String typeString) { break; case "blob": case "longblob": + case "tinyblob": primitiveType = TiDBDataType.BLOB; break; default: diff --git a/src/sqlancer/tidb/gen/TiDBAlterTableGenerator.java b/src/sqlancer/tidb/gen/TiDBAlterTableGenerator.java index e6ebe4dac..3d33a4dbc 100644 --- a/src/sqlancer/tidb/gen/TiDBAlterTableGenerator.java +++ b/src/sqlancer/tidb/gen/TiDBAlterTableGenerator.java @@ -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( @@ -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) { @@ -101,7 +113,6 @@ public static SQLQueryAdapter getQuery(TiDBGlobalState globalState) { default: throw new AssertionError(a); } - return new SQLQueryAdapter(sb.toString(), errors, true); } diff --git a/src/sqlancer/tidb/gen/TiDBAnalyzeTableGenerator.java b/src/sqlancer/tidb/gen/TiDBAnalyzeTableGenerator.java index 85525b6ff..b52e2cc25 100644 --- a/src/sqlancer/tidb/gen/TiDBAnalyzeTableGenerator.java +++ b/src/sqlancer/tidb/gen/TiDBAnalyzeTableGenerator.java @@ -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 + */)); } } diff --git a/src/sqlancer/tidb/gen/TiDBDeleteGenerator.java b/src/sqlancer/tidb/gen/TiDBDeleteGenerator.java index 6c194a010..f6eea4671 100644 --- a/src/sqlancer/tidb/gen/TiDBDeleteGenerator.java +++ b/src/sqlancer/tidb/gen/TiDBDeleteGenerator.java @@ -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);