Skip to content

Commit 133bb08

Browse files
sre-botzz-jason
authored andcommitted
expression: make regex binary and rlike binary be case sen… (#11504)
1 parent 69727fd commit 133bb08

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

expression/builtin_like.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func (c *regexpFunctionClass) getFunction(ctx sessionctx.Context, args []Express
9595
bf := newBaseBuiltinFuncWithTp(ctx, args, types.ETInt, types.ETString, types.ETString)
9696
bf.tp.Flen = 1
9797
var sig builtinFunc
98-
if types.IsBinaryStr(args[0].GetType()) {
98+
if types.IsBinaryStr(args[0].GetType()) || types.IsBinaryStr(args[1].GetType()) {
9999
sig = &builtinRegexpBinarySig{bf}
100100
} else {
101101
sig = &builtinRegexpSig{bf}

expression/integration_test.go

+6
Original file line numberDiff line numberDiff line change
@@ -2475,18 +2475,24 @@ func (s *testIntegrationSuite) TestBuiltin(c *C) {
24752475
result.Check(testkit.Rows("1"))
24762476
result = tk.MustQuery(`select b regexp 'Xt' from t;`)
24772477
result.Check(testkit.Rows("1"))
2478+
result = tk.MustQuery(`select b regexp binary 'Xt' from t;`)
2479+
result.Check(testkit.Rows("0"))
24782480
result = tk.MustQuery(`select c regexp 'Xt' from t;`)
24792481
result.Check(testkit.Rows("0"))
24802482
result = tk.MustQuery(`select d regexp 'Xt' from t;`)
24812483
result.Check(testkit.Rows("0"))
24822484
result = tk.MustQuery(`select a rlike 'Xt' from t;`)
24832485
result.Check(testkit.Rows("1"))
2486+
result = tk.MustQuery(`select a rlike binary 'Xt' from t;`)
2487+
result.Check(testkit.Rows("0"))
24842488
result = tk.MustQuery(`select b rlike 'Xt' from t;`)
24852489
result.Check(testkit.Rows("1"))
24862490
result = tk.MustQuery(`select c rlike 'Xt' from t;`)
24872491
result.Check(testkit.Rows("0"))
24882492
result = tk.MustQuery(`select d rlike 'Xt' from t;`)
24892493
result.Check(testkit.Rows("0"))
2494+
result = tk.MustQuery(`select 'a' regexp 'A', 'a' regexp binary 'A'`)
2495+
result.Check(testkit.Rows("1 0"))
24902496

24912497
// testCase is for like and regexp
24922498
type testCase struct {

0 commit comments

Comments
 (0)