From b0c9d19c5ebe2849a3cf9820cfcbdb3905ad239c Mon Sep 17 00:00:00 2001 From: wjHuang Date: Wed, 1 Sep 2021 19:36:13 +0800 Subject: [PATCH] expression: remove useless code (#27700) --- expression/builtin_arithmetic.go | 11 ----------- expression/builtin_arithmetic_test.go | 25 ------------------------- 2 files changed, 36 deletions(-) diff --git a/expression/builtin_arithmetic.go b/expression/builtin_arithmetic.go index 06a7f07d0ce99..9711f585ca0f4 100644 --- a/expression/builtin_arithmetic.go +++ b/expression/builtin_arithmetic.go @@ -86,13 +86,6 @@ func numericContextResultType(ft *types.FieldType) types.EvalType { return evalTp4Ft } -// setFlenDecimal4Int is called to set proper `Flen` and `Decimal` of return -// type according to the two input parameter's types. -func setFlenDecimal4Int(retTp, a, b *types.FieldType) { - retTp.Decimal = 0 - retTp.Flen = mysql.MaxIntWidth -} - // setFlenDecimal4RealOrDecimal is called to set proper `Flen` and `Decimal` of return // type according to the two input parameter's types. func setFlenDecimal4RealOrDecimal(retTp, a, b *types.FieldType, isReal bool, isMultiply bool) { @@ -190,7 +183,6 @@ func (c *arithmeticPlusFunctionClass) getFunction(ctx sessionctx.Context, args [ if mysql.HasUnsignedFlag(args[0].GetType().Flag) || mysql.HasUnsignedFlag(args[1].GetType().Flag) { bf.tp.Flag |= mysql.UnsignedFlag } - setFlenDecimal4Int(bf.tp, args[0].GetType(), args[1].GetType()) sig := &builtinArithmeticPlusIntSig{bf} sig.setPbCode(tipb.ScalarFuncSig_PlusInt) return sig, nil @@ -338,7 +330,6 @@ func (c *arithmeticMinusFunctionClass) getFunction(ctx sessionctx.Context, args if err != nil { return nil, err } - setFlenDecimal4Int(bf.tp, args[0].GetType(), args[1].GetType()) if (mysql.HasUnsignedFlag(args[0].GetType().Flag) || mysql.HasUnsignedFlag(args[1].GetType().Flag)) && !ctx.GetSessionVars().SQLMode.HasNoUnsignedSubtractionMode() { bf.tp.Flag |= mysql.UnsignedFlag } @@ -523,12 +514,10 @@ func (c *arithmeticMultiplyFunctionClass) getFunction(ctx sessionctx.Context, ar } if mysql.HasUnsignedFlag(lhsTp.Flag) || mysql.HasUnsignedFlag(rhsTp.Flag) { bf.tp.Flag |= mysql.UnsignedFlag - setFlenDecimal4Int(bf.tp, args[0].GetType(), args[1].GetType()) sig := &builtinArithmeticMultiplyIntUnsignedSig{bf} sig.setPbCode(tipb.ScalarFuncSig_MultiplyIntUnsigned) return sig, nil } - setFlenDecimal4Int(bf.tp, args[0].GetType(), args[1].GetType()) sig := &builtinArithmeticMultiplyIntSig{bf} sig.setPbCode(tipb.ScalarFuncSig_MultiplyInt) return sig, nil diff --git a/expression/builtin_arithmetic_test.go b/expression/builtin_arithmetic_test.go index e9c7ab959bce8..af0e0d27970d1 100644 --- a/expression/builtin_arithmetic_test.go +++ b/expression/builtin_arithmetic_test.go @@ -91,31 +91,6 @@ func (s *testEvaluatorSuite) TestSetFlenDecimal4RealOrDecimal(c *C) { c.Assert(ret.Flen, Equals, types.UnspecifiedLength) } -func (s *testEvaluatorSuite) TestSetFlenDecimal4Int(c *C) { - ret := &types.FieldType{} - a := &types.FieldType{ - Decimal: 1, - Flen: 3, - } - b := &types.FieldType{ - Decimal: 0, - Flen: 2, - } - setFlenDecimal4Int(ret, a, b) - c.Assert(ret.Decimal, Equals, 0) - c.Assert(ret.Flen, Equals, mysql.MaxIntWidth) - - b.Flen = mysql.MaxIntWidth + 1 - setFlenDecimal4Int(ret, a, b) - c.Assert(ret.Decimal, Equals, 0) - c.Assert(ret.Flen, Equals, mysql.MaxIntWidth) - - b.Flen = types.UnspecifiedLength - setFlenDecimal4Int(ret, a, b) - c.Assert(ret.Decimal, Equals, 0) - c.Assert(ret.Flen, Equals, mysql.MaxIntWidth) -} - func (s *testEvaluatorSuite) TestArithmeticPlus(c *C) { // case: 1 args := []interface{}{int64(12), int64(1)}