From fcfd8387bfb4241a0d4b23212f82faebadb9163a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=99=8E?= Date: Wed, 29 Dec 2021 17:19:50 +0800 Subject: [PATCH] expression: enable strcmp for tiflash (#30983) --- expression/expr_to_pb_test.go | 5 +++++ expression/expression.go | 2 +- tools/check/ut.go | 6 +++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/expression/expr_to_pb_test.go b/expression/expr_to_pb_test.go index 134a7b076aeea..840c7fd4cf7ef 100644 --- a/expression/expr_to_pb_test.go +++ b/expression/expr_to_pb_test.go @@ -993,6 +993,11 @@ func TestExprPushDownToFlash(t *testing.T) { require.NoError(t, err) exprs = append(exprs, function) + // strcmp + function, err = NewFunction(mock.NewContext(), ast.Strcmp, types.NewFieldType(mysql.TypeLonglong), stringColumn, stringColumn) + require.NoError(t, err) + exprs = append(exprs, function) + pushed, remained = PushDownExprs(sc, exprs, client, kv.TiFlash) require.Len(t, pushed, len(exprs)) require.Len(t, remained, 0) diff --git a/expression/expression.go b/expression/expression.go index c67705b03b57b..eea4f0a604bb5 100644 --- a/expression/expression.go +++ b/expression/expression.go @@ -1035,7 +1035,7 @@ func scalarExprSupportedByFlash(function *ScalarFunction) bool { } case ast.LogicOr, ast.LogicAnd, ast.UnaryNot, ast.BitNeg, ast.Xor, ast.And, ast.Or, - ast.GE, ast.LE, ast.EQ, ast.NE, ast.LT, ast.GT, ast.In, ast.IsNull, ast.Like, + ast.GE, ast.LE, ast.EQ, ast.NE, ast.LT, ast.GT, ast.In, ast.IsNull, ast.Like, ast.Strcmp, ast.Plus, ast.Minus, ast.Div, ast.Mul, ast.Abs, ast.Mod, ast.If, ast.Ifnull, ast.Case, ast.Concat, ast.ConcatWS, diff --git a/tools/check/ut.go b/tools/check/ut.go index bcb9eb81296e8..6a3882a233a57 100644 --- a/tools/check/ut.go +++ b/tools/check/ut.go @@ -15,9 +15,9 @@ package main import ( - "io" "bytes" "fmt" + "io" "math/rand" "os" "os/exec" @@ -354,7 +354,7 @@ func (n *numa) worker(wg *sync.WaitGroup, ch chan task) { } type testResult struct { - err error + err error output bytes.Buffer } @@ -449,7 +449,7 @@ func numactlExist() bool { func testFileName(pkg string) string { _, file := path.Split(pkg) - return file+".test.bin" + return file + ".test.bin" } func testFileFullPath(pkg string) string {