Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expression: make regex binary and rlike binary be case sensitive #11502

Merged
merged 1 commit into from
Jul 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion expression/builtin_like.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
6 changes: 6 additions & 0 deletions expression/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2545,18 +2545,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 {
Expand Down