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
6 changes: 4 additions & 2 deletions pkg/ddl/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,8 @@ func TestTxnSavepointWithDDL(t *testing.T) {
tk2.MustExec("alter table t2 add index idx2(c2)")
tk.MustExec("commit")
tk.MustQuery("select * from t2").Check(testkit.Rows())
tk.MustExec("admin check table t1, t2")
tk.MustExec("admin check table t1")
tk.MustExec("admin check table t2")

prepareFn()
tk.MustExec("truncate table t1")
Expand All @@ -649,7 +650,8 @@ func TestTxnSavepointWithDDL(t *testing.T) {
require.Error(t, err)
require.Regexp(t, ".*8028.*Information schema is changed during the execution of the statement.*", err.Error())
tk.MustQuery("select * from t1").Check(testkit.Rows())
tk.MustExec("admin check table t1, t2")
tk.MustExec("admin check table t1")
tk.MustExec("admin check table t2")
}

func TestSnapshotVersion(t *testing.T) {
Expand Down
4 changes: 4 additions & 0 deletions pkg/executor/test/admintest/admin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1495,6 +1495,10 @@ func TestAdminCheckTableFailed(t *testing.T) {
require.EqualError(t, err, "[admin:8223]data inconsistency in table: admin_test, index: c2, handle: ‹10›, index-values:‹\"handle: 10, values: [KindInt64 19]\"› != record-values:‹\"handle: 10, values: [KindInt64 20]\"›")
tk.MustExec("set @@tidb_redact_log=0;")

tk.MustExec("create table other (a int);")
tk.MustGetErrMsg("admin check table other, admin_test;",
"admin check only supports one table at a time")

// Recover records.
txn, err = store.Begin()
require.NoError(t, err)
Expand Down
5 changes: 2 additions & 3 deletions pkg/executor/test/executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2630,9 +2630,8 @@ func TestAdmin(t *testing.T) {
// check table test
tk.MustExec("create table admin_test1 (c1 int, c2 int default 1, index (c1))")
tk.MustExec("insert admin_test1 (c1) values (21),(22)")
r, err = tk.Exec("admin check table admin_test, admin_test1")
require.NoError(t, err)
require.Nil(t, r)
tk.MustExec("admin check table admin_test")
tk.MustExec("admin check table admin_test1")
// error table name
require.Error(t, tk.ExecToErr("admin check table admin_test_error"))
// different index values
Expand Down
3 changes: 3 additions & 0 deletions pkg/planner/core/planbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -1857,6 +1857,9 @@ func (b *PlanBuilder) buildPhysicalIndexLookUpReaders(ctx context.Context, dbNam
}

func (b *PlanBuilder) buildAdminCheckTable(ctx context.Context, as *ast.AdminStmt) (*CheckTable, error) {
if len(as.Tables) > 1 {
return nil, errors.New("admin check only supports one table at a time")
}
tblName := as.Tables[0]
tnW := b.resolveCtx.GetTableName(tblName)
tableInfo := tnW.TableInfo
Expand Down
3 changes: 2 additions & 1 deletion tests/integrationtest/r/ddl/foreign_key.result
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ id b
select * from t2;
id b
2 2
admin check table t1,t2;
admin check table t1;
admin check table t2;
create database test_db_1;
create database test_db_2;
create database test_db_3;
Expand Down
3 changes: 2 additions & 1 deletion tests/integrationtest/t/ddl/foreign_key.test
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,8 @@ alter table t2 rename index idx to idx0;
delete from t1 where id=1;
select * from t1;
select * from t2;
admin check table t1,t2;
admin check table t1;
admin check table t2;

# TestCheckFKDatabaseRefWithSchemaSimpleTableInfos
create database test_db_1;
Expand Down