From d325681c08fe9a0f117e366ddf9eaf7879ccc418 Mon Sep 17 00:00:00 2001 From: Yu Shuaipeng Date: Thu, 29 Jun 2017 16:07:21 +0800 Subject: [PATCH 1/2] fix unhex error --- executor/executor_test.go | 5 +++++ expression/builtin_string.go | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/executor/executor_test.go b/executor/executor_test.go index 52ebc67b7a598..18139ed6deffd 100644 --- a/executor/executor_test.go +++ b/executor/executor_test.go @@ -887,6 +887,11 @@ func (s *testSuite) TestBuiltin(c *C) { result.Check(testkit.Rows("1267")) result = tk.MustQuery("select hex(unhex(1267))") result.Check(testkit.Rows("1267")) + tk.MustExec("drop table if exists t") + tk.MustExec("create table t(a binary(8))") + tk.MustExec(`insert into t values('test')`) + result = tk.MustQuery("select unhex(a) from t") + result.Check(testkit.Rows("")) // select from_unixtime result = tk.MustQuery("select from_unixtime(1451606400)") diff --git a/expression/builtin_string.go b/expression/builtin_string.go index 3d1d6c08ddcc9..07512118c2502 100644 --- a/expression/builtin_string.go +++ b/expression/builtin_string.go @@ -989,7 +989,7 @@ func (b *builtinUnHexSig) eval(row []types.Datum) (d types.Datum, err error) { switch args[0].Kind() { case types.KindNull: return d, nil - case types.KindString: + case types.KindString, types.KindBytes: x, err := args[0].ToString() if err != nil { return d, errors.Trace(err) From 024a2482930ec1bd83eef017cdff85a2d85ad6a5 Mon Sep 17 00:00:00 2001 From: Yu Shuaipeng Date: Thu, 29 Jun 2017 17:46:22 +0800 Subject: [PATCH 2/2] fix indent --- executor/executor_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/executor/executor_test.go b/executor/executor_test.go index 3efe03604c81e..c6371ee78b8eb 100644 --- a/executor/executor_test.go +++ b/executor/executor_test.go @@ -892,7 +892,7 @@ func (s *testSuite) TestBuiltin(c *C) { tk.MustExec(`insert into t values('test')`) result = tk.MustQuery("select hex(a) from t") result.Check(testkit.Rows("7465737400000000")) - result = tk.MustQuery("select unhex(a) from t") + result = tk.MustQuery("select unhex(a) from t") result.Check(testkit.Rows("")) // select from_unixtime