From cb05ebb0b20fcb048406d65f87ba03ec320ad2c4 Mon Sep 17 00:00:00 2001 From: pingcap-github-bot Date: Tue, 30 Jul 2019 12:04:10 +0800 Subject: [PATCH] expression: make `regex binary` and `rlike binary` be case sensitive (#11505) All tests passed, auto merged by Bot --- 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 1409f6ec2cfd7..4d552473a240b 100644 --- a/expression/builtin_like.go +++ b/expression/builtin_like.go @@ -96,7 +96,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 f1d88eeaa0a49..4bbb12d4fa1cb 100644 --- a/expression/integration_test.go +++ b/expression/integration_test.go @@ -2373,18 +2373,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 {