From 702a116a5eaab50e2e83b8adb18318fdfc6a2cc3 Mon Sep 17 00:00:00 2001 From: winkyao Date: Thu, 9 Aug 2018 17:37:47 +0800 Subject: [PATCH] admin: fix admin check table false alarm in the case that index contains pkIsHandle column (#7317) --- executor/executor_test.go | 5 +++++ util/admin/admin.go | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/executor/executor_test.go b/executor/executor_test.go index be9460a8ab..0fae51a6cc 100644 --- a/executor/executor_test.go +++ b/executor/executor_test.go @@ -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) { diff --git a/util/admin/admin.go b/util/admin/admin.go index 5a0a3f64a0..a1c6f48854 100644 --- a/util/admin/admin.go +++ b/util/admin/admin.go @@ -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]) }