Skip to content

Commit

Permalink
admin: fix admin check table false alarm in the case that index conta…
Browse files Browse the repository at this point in the history
…ins pkIsHandle column (#7317)
  • Loading branch information
winkyao authored Aug 9, 2018
1 parent 22519ae commit 702a116
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,11 @@ func (s *testSuite) TestAdmin(c *C) {
// For "checksum_with_index", we have two checksums, so the result will be 1^1 = 0.
// For "checksum_without_index", we only have one checksum, so the result will be 1.
res.Sort().Check(testkit.Rows("test checksum_with_index 0 2 2", "test checksum_without_index 1 1 1"))

tk.MustExec("drop table if exists t")
tk.MustExec("create table t(a bigint unsigned primary key, b int, c int, index idx(a, b));")
tk.MustExec("insert into t values(1, 1, 1)")
tk.MustExec("admin check table t")
}

func (s *testSuite) fillData(tk *testkit.TestKit, table string) {
Expand Down
6 changes: 5 additions & 1 deletion util/admin/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,11 @@ func iterRecords(sessCtx sessionctx.Context, retriever kv.Retriever, t table.Tab
data := make([]types.Datum, 0, len(cols))
for _, col := range cols {
if col.IsPKHandleColumn(t.Meta()) {
data = append(data, types.NewIntDatum(handle))
if mysql.HasUnsignedFlag(col.Flag) {
data = append(data, types.NewUintDatum(uint64(handle)))
} else {
data = append(data, types.NewIntDatum(handle))
}
} else {
data = append(data, rowMap[col.ID])
}
Expand Down

0 comments on commit 702a116

Please sign in to comment.