8000 tidb: fix wrong type judgement and analyze index by hawkingrei · Pull Request #1273 · sqlancer/sqlancer · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8000
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
< 8000 td class="blob-code blob-code-addition js-file-line"> docker pull hawkingrei/tidb-playground:nightly-2025-09-16
Original file line number Diff line number Diff line change
Expand Up @@ -609,8 +609,8 @@ jobs:
run: mvn -B package -DskipTests=true
- name: Set up TiDB
run: |
docker pull pingcap/tidb:v8.5.2
docker run --name tidb-server -d -p 4000:4000 pingcap/tidb:v8.5.2
docker run --name tidb-server -d -p 4000:4000 hawkingrei/tidb-playground:nightly-2025-09-16
sleep 10
- name: Create SQLancer user
run: sudo mysql -h 127.0.0.1 -P 4000 -u root -D test -e "CREATE USER 'sqlancer'@'%' IDENTIFIED WITH mysql_native_password BY 'sqlancer'; GRANT ALL PRIVILEGES ON *.* TO 'sqlancer'@'%' WITH GRANT OPTION; FLUSH PRIVILEGES;"
Expand All @@ -636,8 +636,8 @@ jobs:
run: mvn -B package -DskipTests=true
- name: Set up TiDB
run: |
docker pull pingcap/tidb:v8.5.2
docker run --name tidb-server -d -p 4000:4000 pingcap/tidb:v8.5.2
docker pull hawkingrei/tidb-playground:nightly-2025-09-16
docker run --name tidb-server -d -p 4000:4000 hawkingrei/tidb-playground:nightly-2025-09-16
sleep 10
- name: Create SQLancer user
run: sudo mysql -h 127.0.0.1 -P 4000 -u root -D test -e "CREATE USER 'sqlancer'@'%' IDENTIFIED WITH mysql_native_password BY 'sqlancer'; GRANT ALL PRIVILEGES ON *.* TO 'sqlancer'@'%' WITH GRANT OPTION; FLUSH PRIVILEGES;"
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 @@ -251,17 +251,20 @@ private static TiDBCompositeDataType getColumnType(String typeString) {
primitiveType = TiDBDataType.INT;
size = 1;
break;
case "tinyint":
case "tinyint(2)":
case "tinyint(3)":
case "tinyint(4)":
primitiveType = TiDBDataType.INT;
size = 1;
break;
case "smallint":
case "smallint(5)":
case "smallint(6)":
primitiveType = TiDBDataType.INT;
size = 2;
break;
case "int":
case "int(10)":
case "int(11)":
primitiveType = TiDBDataType.INT;
Expand Down
11 changes: 9 additions & 2 deletions src/sqlancer/tidb/gen/TiDBAnalyzeTableGenerator.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package sqlancer.tidb.gen;

import java.sql.SQLException;
import java.util.List;

import sqlancer.Randomly;
import sqlancer.common.query.ExpectedErrors;
import sqlancer.common.query.SQLQueryAdapter;
import sqlancer.common.schema.TableIndex;
import sqlancer.tidb.TiDBErrors;
import sqlancer.ti 855F db.TiDBProvider.TiDBGlobalState;
import sqlancer.tidb.TiDBSchema.TiDBTable;
Expand All @@ -17,12 +19,17 @@ private TiDBAnalyzeTableGenerator() {
public static SQLQueryAdapter getQuery(TiDBGlobalState globalState) throws SQLException {
ExpectedErrors errors = ExpectedErrors.newErrors().with(TiDBErrors.getExpressionErrors()).build();
TiDBTable table = globalState.getSchema().getRandomTable(t -> !t.isView());
boolean analyzeIndex = !table.getIndexes().isEmpty() && Randomly.getBoolean();
List<TableIndex> indexes = table.getIndexes();
indexes.removeIf(index -> index.getIndexName().contains("PRIMARY"));
boolean analyzeIndex = !indexes.isEmpty() && Randomly.getBoolean();
StringBuilder sb = new StringBuilder("ANALYZE TABLE ");
sb.append(table.getName());
if (analyzeIndex) {
sb.append(" INDEX ");
sb.append(table.getRandomIndex().getIndexName());
sb.append(Randomly.fromList(indexes).getIndexName());
}
if (!analyzeIndex && Randomly.getBoolean()) {
sb.append(" ALL COLUMNS");
}
if (Randomly.getBoolean()) {
sb.append(" WITH ");
Expand Down
Loading
0