From e22b7b8b1aa6e099992544d13cf1a597fa03c147 Mon Sep 17 00:00:00 2001 From: Meng Xin Date: Thu, 25 Nov 2021 17:43:51 +0800 Subject: [PATCH] cherry pick #30154 to release-5.1 Signed-off-by: ti-srebot --- expression/expr_to_pb_test.go | 3 +++ expression/expression.go | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/expression/expr_to_pb_test.go b/expression/expr_to_pb_test.go index b4288a4bcba1c..00f24d710b5dd 100644 --- a/expression/expr_to_pb_test.go +++ b/expression/expr_to_pb_test.go @@ -842,10 +842,13 @@ func (s *testEvaluatorSuite) TestExprPushDownToFlash(c *C) { c.Assert(err, IsNil) c.Assert(function.(*ScalarFunction).Function.PbCode(), Equals, tipb.ScalarFuncSig_SubDateDatetimeInt) exprs = append(exprs, function) +<<<<<<< HEAD function, err = NewFunction(mock.NewContext(), ast.DateSub, types.NewFieldType(mysql.TypeDatetime), stringColumn, intColumn, stringColumn) c.Assert(err, IsNil) c.Assert(function.(*ScalarFunction).Function.PbCode(), Equals, tipb.ScalarFuncSig_SubDateStringInt) exprs = append(exprs, function) +======= +>>>>>>> e15b76875... expression : prevent function DATE_ADD/SUB_STRING_XXX pushed down to TiFlash (#30154) function, err = NewFunction(mock.NewContext(), ast.SubDate, types.NewFieldType(mysql.TypeDatetime), datetimeColumn, intColumn, stringColumn) c.Assert(err, IsNil) c.Assert(function.(*ScalarFunction).Function.PbCode(), Equals, tipb.ScalarFuncSig_SubDateDatetimeInt) diff --git a/expression/expression.go b/expression/expression.go index 795661b98df62..ecb8866458010 100644 --- a/expression/expression.go +++ b/expression/expression.go @@ -1038,12 +1038,16 @@ func scalarExprSupportedByFlash(function *ScalarFunction) bool { } case ast.DateAdd, ast.AddDate: switch function.Function.PbCode() { +<<<<<<< HEAD case tipb.ScalarFuncSig_AddDateDatetimeInt, tipb.ScalarFuncSig_AddDateStringInt: +======= + case tipb.ScalarFuncSig_AddDateDatetimeInt: +>>>>>>> e15b76875... expression : prevent function DATE_ADD/SUB_STRING_XXX pushed down to TiFlash (#30154) return true } case ast.DateSub, ast.SubDate: switch function.Function.PbCode() { - case tipb.ScalarFuncSig_SubDateDatetimeInt, tipb.ScalarFuncSig_SubDateStringInt: + case tipb.ScalarFuncSig_SubDateDatetimeInt: return true } case ast.UnixTimestamp: