diff --git a/src/sqlancer/stonedb/StoneDBErrors.java b/src/sqlancer/stonedb/StoneDBErrors.java index bdbd6a447..1e72e5685 100644 --- a/src/sqlancer/stonedb/StoneDBErrors.java +++ b/src/sqlancer/stonedb/StoneDBErrors.java @@ -1,6 +1,35 @@ package sqlancer.stonedb; +import sqlancer.common.query.ExpectedErrors; + public final class StoneDBErrors { private StoneDBErrors() { } + + public static void addExpectedExpressionErrors(ExpectedErrors errors) { + // java.sql.SQLException: Incorrect DATE value: '292269055-12-02' + errors.add("Incorrect DATE value: "); + // java.sql.SQLException: Incorrect string value: '\xBC\xE7\xC9\x91\x05R...' for column 'c1' at row 1 + errors.add("Incorrect string value: "); + // java.sql.SQLException: Incorrect integer value: 'ST' for column 'c1' at row 1 + errors.add("Incorrect integer value: "); + // com.mysql.cj.jdbc.exceptions.MysqlDataTruncation: Data truncation: Truncated incorrect INTEGER value: '#Q' + errors.add("Data truncation: Truncated incorrect INTEGER value: "); + // com.mysql.cj.jdbc.exceptions.MysqlDataTruncation: Data truncation: BIGINT value is out of range in + // '-((`database0`.`t0`.`c1` >> (not(`database0`.`t0`.`c1`))))' + errors.add("Data truncation: BIGINT value is out of range in "); + // com.mysql.cj.jdbc.exceptions.MysqlDataTruncation: Data truncation: BIGINT UNSIGNED value is out of range in + // '(`database10`.`t0`.`c0` + (`database10`.`t0`.`c0` & (not(0.5))))' + errors.add("Data truncation: BIGINT UNSIGNED value is out of range in "); + // com.mysql.cj.jdbc.exceptions.MysqlDataTruncation: Data truncation: Incorrect time value: '0Sly6xqF0' for + // column 'c1' at row 1 + errors.add("Data truncation: Incorrect time value: "); + // com.mysql.cj.jdbc.exceptions.MysqlDataTruncation: Data truncation: DOUBLE value is out of range in + // '(`database0`.`t0`.`c0` * `database0`.`t0`.`c0`)' + errors.add("Data truncation: DOUBLE value is out of range in "); + // java.sql.SQLException: Numeric result of an expression is too large and cannot be handled by tianmu. + errors.add("Numeric result of an expression is too large and cannot be handled by tianmu."); + // java.sql.SQLSyntaxErrorException: Unknown column '1020726100' in 'order clause' + errors.add("Unknown column "); + } } diff --git a/src/sqlancer/stonedb/gen/StoneDBTableAlterGenerator.java b/src/sqlancer/stonedb/gen/StoneDBTableAlterGenerator.java index 64ddefa1b..e9c283cc9 100644 --- a/src/sqlancer/stonedb/gen/StoneDBTableAlterGenerator.java +++ b/src/sqlancer/stonedb/gen/StoneDBTableAlterGenerator.java @@ -41,6 +41,14 @@ private SQLQueryAdapter getQuery() { private void addExpectedErrors() { // com.mysql.cj.jdbc.exceptions.MysqlDataTruncation: Data truncation: Data too long for column 'c0' at row 2 errors.addRegex(Pattern.compile("Data truncation: Data too long for column 'c\\d{1,3}' at row \\d{1,3}")); + // com.mysql.cj.jdbc.exceptions.MysqlDataTruncation: Data truncation: Incorrect datetime value: + // '0.571272522740968' for column 'c1' at row 1 + errors.add("Incorrect datetime value: "); + // java.sql.SQLSyntaxErrorException: Invalid default value for 'c0' + errors.add("Invalid default value for "); + // com.mysql.cj.jdbc.exceptions.MysqlDataTruncation: Data truncation: Out of range value for column 'c0' at row + // 2 + errors.add("Data truncation: Out of range value for column "); // java.sql.SQLSyntaxErrorException: Specified key was too long; max key length is 3072 bytes errors.add("Specified key was too long; max key length is 3072 bytes"); // java.sql.SQLSyntaxErrorException: You can't delete all columns with ALTER TABLE; use DROP TABLE instead @@ -98,12 +106,19 @@ private void appendAlterOption(Action action) { String oldColumnName = table.getRandomColumn().getName(); String newColumnName = table.getFreeColumnName(); sb.append(oldColumnName).append(" ").append(newColumnName).append(" "); + errors.add("Incorrect integer value: "); + // java.sql.SQLException: Data truncated for column 'c1' at row 1 + errors.add("Data truncated for column "); sb.append( StoneDBDataType.getTypeAndValue(StoneDBDataType.getRandomWithoutNull(), globalState.getRandomly())); // java.sql.SQLSyntaxErrorException: Column length too big for column 'c1' (max = 16383); use BLOB or TEXT // instead errors.addRegex(Pattern .compile("Column length too big for column 'c\\d{1,3}' (max = 16383); use BLOB or TEXT instead")); + // java.sql.SQLSyntaxErrorException: BLOB column 'c1' can't be used in key specification with the used table + // type + errors.addRegex(Pattern + .compile("BLOB column 'c\\d{1,3}' can't be used in key specification with the used table type")); if (Randomly.getBoolean()) { if (Randomly.getBoolean()) { sb.append(" FIRST"); diff --git a/src/sqlancer/stonedb/gen/StoneDBTableDeleteGenerator.java b/src/sqlancer/stonedb/gen/StoneDBTableDeleteGenerator.java index ab0828d30..16b9c1061 100644 --- a/src/sqlancer/stonedb/gen/StoneDBTableDeleteGenerator.java +++ b/src/sqlancer/stonedb/gen/StoneDBTableDeleteGenerator.java @@ -55,6 +55,12 @@ public SQLQueryAdapter getQuery() { sb.append(" LIMIT "); sb.append(r.getInteger(0, (int) randomTable.getNrRows(globalState))); } + addExpectedErrors(); return new SQLQueryAdapter(sb.toString(), errors); } + + private void addExpectedErrors() { + // java.sql.SQLException: Incorrect string value: '\xBC\xE7\xC9\x91\x05R...' for column 'c1' at row 1 + errors.add("Incorrect string value: "); + } } diff --git a/src/sqlancer/stonedb/gen/StoneDBTableInsertGenerator.java b/src/sqlancer/stonedb/gen/StoneDBTableInsertGenerator.java index f4435ec26..19b650b82 100644 --- a/src/sqlancer/stonedb/gen/StoneDBTableInsertGenerator.java +++ b/src/sqlancer/stonedb/gen/StoneDBTableInsertGenerator.java @@ -53,6 +53,10 @@ private SQLQueryAdapter getQuery() { } private void addExpectedErrors() { + // java.sql.SQLException: Incorrect DATE value: '292278994-08-17' + errors.add("Incorrect DATE value: '"); + // java.sql.SQLIntegrityConstraintViolationException: Duplicate entry '1970-01-14' for key 'PRIMARY' + errors.add("Duplicate entry "); // com.mysql.cj.jdbc.exceptions.MysqlDataTruncation: Data truncation: Out of range value for column 'c0' at row errors.add("Data truncation: Out of range value for column "); // java.sql.SQLSyntaxErrorException: Unknown column 'c0' in 'field list' diff --git a/src/sqlancer/stonedb/oracle/StoneDBAggregateOracle.java b/src/sqlancer/stonedb/oracle/StoneDBAggregateOracle.java index 652fa30ed..27ba91013 100644 --- a/src/sqlancer/stonedb/oracle/StoneDBAggregateOracle.java +++ b/src/sqlancer/stonedb/oracle/StoneDBAggregateOracle.java @@ -15,6 +15,7 @@ import sqlancer.common.ast.newast.Node; import sqlancer.common.query.SQLQueryAdapter; import sqlancer.common.query.SQLancerResultSet; +import sqlancer.stonedb.StoneDBErrors; import sqlancer.stonedb.StoneDBProvider.StoneDBGlobalState; import sqlancer.stonedb.StoneDBSchema.StoneDBCompositeDataType; import sqlancer.stonedb.StoneDBSchema.StoneDBDataType; @@ -30,6 +31,7 @@ public class StoneDBAggregateOracle extends StoneDBQueryPartitioningBase { public StoneDBAggregateOracle(StoneDBGlobalState state) { super(state); + StoneDBErrors.addExpectedExpressionErrors(errors); } @Override diff --git a/src/sqlancer/stonedb/oracle/StoneDBNoRECOracle.java b/src/sqlancer/stonedb/oracle/StoneDBNoRECOracle.java index 534bf030d..e042cd44a 100644 --- a/src/sqlancer/stonedb/oracle/StoneDBNoRECOracle.java +++ b/src/sqlancer/stonedb/oracle/StoneDBNoRECOracle.java @@ -21,6 +21,7 @@ import sqlancer.common.oracle.TestOracle; import sqlancer.common.query.SQLQueryAdapter; import sqlancer.common.query.SQLancerResultSet; +import sqlancer.stonedb.StoneDBErrors; import sqlancer.stonedb.StoneDBProvider.StoneDBGlobalState; import sqlancer.stonedb.StoneDBSchema; import sqlancer.stonedb.StoneDBSchema.StoneDBColumn; @@ -42,6 +43,7 @@ public class StoneDBNoRECOracle extends NoRECBase implements public StoneDBNoRECOracle(StoneDBGlobalState globalState) { super(globalState); this.schema = globalState.getSchema(); + StoneDBErrors.addExpectedExpressionErrors(errors); } @Override