Skip to content

Commit 8c93a22

Browse files
committed
[TiDB] Introduce a bug workaround class
1 parent 8110ca6 commit 8c93a22

3 files changed

Lines changed: 31 additions & 8 deletions

File tree

src/sqlancer/tidb/TiDBBugs.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package sqlancer.tidb;
2+
3+
public class TiDBBugs {
4+
5+
// https://github.com/pingcap/tidb/issues/15987
6+
public static boolean BUG_15987 = true;
7+
8+
// // https://github.com/pingcap/tidb/issues/15988
9+
public static boolean BUG_15988 = true;
10+
11+
// https://github.com/pingcap/tidb/issues/15994
12+
public static boolean BUG_15994 = true;
13+
14+
// https://github.com/pingcap/tidb/issues/16028
15+
public static boolean BUG_16028 = true;
16+
17+
// https://github.com/pingcap/tidb/issues/16020
18+
public static boolean BUG_16020 = true;
19+
20+
// https://github.com/pingcap/tidb/issues/15990
21+
public static boolean BUG_15990 = true;
22+
23+
24+
25+
}

src/sqlancer/tidb/TiDBExpressionGenerator.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ protected TiDBExpression generateExpression(int depth) {
7878
case REGEX:
7979
return new TiDBRegexOperation(generateExpression(depth + 1), generateExpression(depth + 1), TiDBRegexOperator.getRandom());
8080
case COLLATE:
81-
if (true) {
82-
// https://github.com/pingcap/tidb/issues/15988
81+
if (TiDBBugs.BUG_15988) {
8382
throw new IgnoreMeException();
8483
}
8584
return new TiDBCollate(generateExpression(depth + 1), Randomly.fromOptions("utf8mb4_bin", "latin1_bin", "binary", "ascii_bin", "utf8_bin"));
@@ -89,9 +88,7 @@ protected TiDBExpression generateExpression(int depth) {
8988
case BINARY_BIT:
9089
return new TiDBBinaryBitOperation(generateExpression(depth + 1), generateExpression(depth + 1), TiDBBinaryBitOperator.getRandom());
9190
case BINARY_LOGICAL:
92-
if (true) {
93-
// https://github.com/pingcap/tidb/issues/15990
94-
// https://github.com/pingcap/tidb/issues/15987
91+
if (TiDBBugs.BUG_15987 || TiDBBugs.BUG_15990) {
9592
throw new IgnoreMeException();
9693
}
9794
return new TiDBBinaryLogicalOperation(generateExpression(depth + 1), generateExpression(depth + 1), TiDBBinaryLogicalOperator.getRandom());

src/sqlancer/tidb/gen/TiDBTableGenerator.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import sqlancer.Query;
1111
import sqlancer.QueryAdapter;
1212
import sqlancer.Randomly;
13+
import sqlancer.tidb.TiDBBugs;
1314
import sqlancer.tidb.TiDBExpressionGenerator;
1415
import sqlancer.tidb.TiDBProvider.TiDBGlobalState;
1516
import sqlancer.tidb.TiDBSchema.TiDBColumn;
@@ -49,7 +50,7 @@ public Query getQuery(TiDBGlobalState globalState) throws SQLException {
4950
appendSizeSpecifiers(sb, type);
5051
sb.append(" ");
5152
boolean isGeneratedColumn = Randomly.getBooleanWithRatherLowProbability();
52-
if (isGeneratedColumn && false /* https://github.com/pingcap/tidb/issues/16020, https://github.com/pingcap/tidb/issues/15994 */) {
53+
if (isGeneratedColumn && !TiDBBugs.BUG_15994 & !TiDBBugs.BUG_16020) {
5354
sb.append(" AS (");
5455
sb.append(TiDBVisitor.asString(gen.generateExpression()));
5556
sb.append(") ");
@@ -98,10 +99,10 @@ public Query getQuery(TiDBGlobalState globalState) throws SQLException {
9899
}
99100

100101
private void appendSizeSpecifiers(StringBuilder sb, TiDBDataType type) {
101-
if (type.isNumeric() && Randomly.getBoolean() && false /* https://github.com/pingcap/tidb/issues/16028 */) {
102+
if (type.isNumeric() && Randomly.getBoolean() && !TiDBBugs.BUG_16028) {
102103
sb.append(" UNSIGNED");
103104
}
104-
if (type.isNumeric() && Randomly.getBoolean() && false /* seems to be the same bug as https://github.com/pingcap/tidb/issues/16028 */) {
105+
if (type.isNumeric() && Randomly.getBoolean() && !TiDBBugs.BUG_16028 /* seems to be the same bug as https://github.com/pingcap/tidb/issues/16028 */) {
105106
sb.append(" ZEROFILL");
106107
}
107108
}

0 commit comments

Comments
 (0)