Skip to content

Commit

Permalink
cherry pick pingcap#20266 to release-4.0
Browse files Browse the repository at this point in the history
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
  • Loading branch information
lzmhhh123 authored and ti-srebot committed Sep 30, 2020
1 parent 7dd1c94 commit 0431dc9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
9 changes: 9 additions & 0 deletions planner/core/expression_rewriter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,15 @@ func (s *testExpressionRewriterSuite) TestCompareSubquery(c *C) {
"<nil> 2",
))
tk.MustQuery("select * from t t1 where b = all (select a from t t2)").Check(testkit.Rows())

// for issue 20059
tk.MustExec("DROP TABLE IF EXISTS `t`")
tk.MustExec("CREATE TABLE `t` ( `a` int(11) DEFAULT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;")
tk.MustExec("INSERT INTO `t` VALUES (1);")
tk.MustExec("DROP TABLE IF EXISTS `table_40_utf8_4`;")
tk.MustExec("CREATE TABLE `table_40_utf8_4` (`col_tinyint_key_unsigned` tinyint(4) DEFAULT NULL, `col_bit64_key_signed` bit(64) DEFAULT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;")
tk.MustExec("INSERT INTO `table_40_utf8_4` VALUES (31, -18);")
tk.MustQuery("select count(1) from table_40_utf8_4 where ( select count(1) from t where table_40_utf8_4.col_bit64_key_signed!=table_40_utf8_4.col_tinyint_key_unsigned)").Check(testkit.Rows("1"))
}

func (s *testExpressionRewriterSuite) TestCheckFullGroupBy(c *C) {
Expand Down
5 changes: 5 additions & 0 deletions types/datum.go
Original file line number Diff line number Diff line change
Expand Up @@ -1570,6 +1570,11 @@ func (d *Datum) ToDecimal(sc *stmtctx.StatementContext) (*MyDecimal, error) {

// ToInt64 converts to a int64.
func (d *Datum) ToInt64(sc *stmtctx.StatementContext) (int64, error) {
switch d.Kind() {
case KindMysqlBit:
uintVal, err := d.GetBinaryLiteral().ToInt(sc)
return int64(uintVal), err
}
return d.toSignedInteger(sc, mysql.TypeLonglong)
}

Expand Down

0 comments on commit 0431dc9

Please sign in to comment.