From 6948237c09bb8f5a3524f7a9039b7f6898dd7073 Mon Sep 17 00:00:00 2001 From: lysu Date: Mon, 29 Jul 2019 16:26:18 +0800 Subject: [PATCH] expression: make `regex binary` and `rlike binary` be case sensitive --- expression/builtin_like.go | 2 +- expression/integration_test.go | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/expression/builtin_like.go b/expression/builtin_like.go index f64df725d6129..093dfaf2abd97 100644 --- a/expression/builtin_like.go +++ b/expression/builtin_like.go @@ -95,7 +95,7 @@ func (c *regexpFunctionClass) getFunction(ctx sessionctx.Context, args []Express bf := newBaseBuiltinFuncWithTp(ctx, args, types.ETInt, types.ETString, types.ETString) bf.tp.Flen = 1 var sig builtinFunc - if types.IsBinaryStr(args[0].GetType()) { + if types.IsBinaryStr(args[0].GetType()) || types.IsBinaryStr(args[1].GetType()) { sig = &builtinRegexpBinarySig{bf} } else { sig = &builtinRegexpSig{bf} diff --git a/expression/integration_test.go b/expression/integration_test.go index 8e4f7e3fb107a..710fa471da86d 100644 --- a/expression/integration_test.go +++ b/expression/integration_test.go @@ -2475,18 +2475,24 @@ func (s *testIntegrationSuite) TestBuiltin(c *C) { result.Check(testkit.Rows("1")) result = tk.MustQuery(`select b regexp 'Xt' from t;`) result.Check(testkit.Rows("1")) + result = tk.MustQuery(`select b regexp binary 'Xt' from t;`) + result.Check(testkit.Rows("0")) result = tk.MustQuery(`select c regexp 'Xt' from t;`) result.Check(testkit.Rows("0")) result = tk.MustQuery(`select d regexp 'Xt' from t;`) result.Check(testkit.Rows("0")) result = tk.MustQuery(`select a rlike 'Xt' from t;`) result.Check(testkit.Rows("1")) + result = tk.MustQuery(`select a rlike binary 'Xt' from t;`) + result.Check(testkit.Rows("0")) result = tk.MustQuery(`select b rlike 'Xt' from t;`) result.Check(testkit.Rows("1")) result = tk.MustQuery(`select c rlike 'Xt' from t;`) result.Check(testkit.Rows("0")) result = tk.MustQuery(`select d rlike 'Xt' from t;`) result.Check(testkit.Rows("0")) + result = tk.MustQuery(`select 'a' regexp 'A', 'a' regexp binary 'A'`) + result.Check(testkit.Rows("1 0")) // testCase is for like and regexp type testCase struct {