Skip to content

Commit

Permalink
ddl: fix admin bug by unflatten clear i. cherry-pick from #7359. (#7457)
Browse files Browse the repository at this point in the history
  • Loading branch information
crazycs520 authored and ngaut committed Aug 22, 2018
1 parent 143b525 commit a530575
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
9 changes: 9 additions & 0 deletions executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,15 @@ 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 t1;")
tk.MustExec("CREATE TABLE t1 (c2 BOOL, PRIMARY KEY (c2));")
tk.MustExec("INSERT INTO t1 SET c2 = '0';")
tk.MustExec("ALTER TABLE t1 ADD COLUMN c3 DATETIME NULL DEFAULT '2668-02-03 17:19:31';")
tk.MustExec("ALTER TABLE t1 ADD INDEX idx2 (c3);")
tk.MustExec("ALTER TABLE t1 ADD COLUMN c4 bit(10) default 127;")
tk.MustExec("ALTER TABLE t1 ADD INDEX idx3 (c4);")
tk.MustExec("admin check table t1;")
}

func (s *testSuite) fillData(tk *testkit.TestKit, table string) {
Expand Down
2 changes: 2 additions & 0 deletions tablecodec/tablecodec.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ func unflatten(datum types.Datum, ft *types.FieldType, loc *time.Location) (type
return datum, errors.Trace(err)
}
}
datum.SetUint64(0)
datum.SetMysqlTime(t)
return datum, nil
case mysql.TypeDuration: //duration should read fsp from column meta data
Expand All @@ -446,6 +447,7 @@ func unflatten(datum types.Datum, ft *types.FieldType, loc *time.Location) (type
case mysql.TypeBit:
val := datum.GetUint64()
byteSize := (ft.Flen + 7) >> 3
datum.SetUint64(0)
datum.SetMysqlBit(types.NewBinaryLiteralFromUint(val, byteSize))
}
return datum, nil
Expand Down

0 comments on commit a530575

Please sign in to comment.