@@ -18,6 +18,7 @@ import (
18
18
"fmt"
19
19
"math"
20
20
21
+ "github.com/pingcap/errors"
21
22
"github.com/pingcap/tidb/pkg/parser/mysql"
22
23
"github.com/pingcap/tidb/pkg/parser/terror"
23
24
"github.com/pingcap/tidb/pkg/types"
@@ -225,25 +226,25 @@ func (s *builtinArithmeticPlusIntSig) evalInt(ctx EvalContext, row chunk.Row) (v
225
226
switch {
226
227
case isLHSUnsigned && isRHSUnsigned :
227
228
if uint64 (a ) > math .MaxUint64 - uint64 (b ) {
228
- return 0 , true , types .ErrOverflow .GenWithStackByArgs ("BIGINT UNSIGNED" , fmt .Sprintf ("(%s + %s)" , s .args [0 ].String ( ), s .args [1 ].String ( )))
229
+ return 0 , true , types .ErrOverflow .GenWithStackByArgs ("BIGINT UNSIGNED" , fmt .Sprintf ("(%s + %s)" , s .args [0 ].StringWithCtx ( errors . RedactLogDisable ), s .args [1 ].StringWithCtx ( errors . RedactLogDisable )))
229
230
}
230
231
case isLHSUnsigned && ! isRHSUnsigned :
231
232
if b < 0 && uint64 (- b ) > uint64 (a ) {
232
- return 0 , true , types .ErrOverflow .GenWithStackByArgs ("BIGINT UNSIGNED" , fmt .Sprintf ("(%s + %s)" , s .args [0 ].String ( ), s .args [1 ].String ( )))
233
+ return 0 , true , types .ErrOverflow .GenWithStackByArgs ("BIGINT UNSIGNED" , fmt .Sprintf ("(%s + %s)" , s .args [0 ].StringWithCtx ( errors . RedactLogDisable ), s .args [1 ].StringWithCtx ( errors . RedactLogDisable )))
233
234
}
234
235
if b > 0 && uint64 (a ) > math .MaxUint64 - uint64 (b ) {
235
- return 0 , true , types .ErrOverflow .GenWithStackByArgs ("BIGINT UNSIGNED" , fmt .Sprintf ("(%s + %s)" , s .args [0 ].String ( ), s .args [1 ].String ( )))
236
+ return 0 , true , types .ErrOverflow .GenWithStackByArgs ("BIGINT UNSIGNED" , fmt .Sprintf ("(%s + %s)" , s .args [0 ].StringWithCtx ( errors . RedactLogDisable ), s .args [1 ].StringWithCtx ( errors . RedactLogDisable )))
236
237
}
237
238
case ! isLHSUnsigned && isRHSUnsigned :
238
239
if a < 0 && uint64 (- a ) > uint64 (b ) {
239
- return 0 , true , types .ErrOverflow .GenWithStackByArgs ("BIGINT UNSIGNED" , fmt .Sprintf ("(%s + %s)" , s .args [0 ].String ( ), s .args [1 ].String ( )))
240
+ return 0 , true , types .ErrOverflow .GenWithStackByArgs ("BIGINT UNSIGNED" , fmt .Sprintf ("(%s + %s)" , s .args [0 ].StringWithCtx ( errors . RedactLogDisable ), s .args [1 ].StringWithCtx ( errors . RedactLogDisable )))
240
241
}
241
242
if a > 0 && uint64 (b ) > math .MaxUint64 - uint64 (a ) {
242
- return 0 , true , types .ErrOverflow .GenWithStackByArgs ("BIGINT UNSIGNED" , fmt .Sprintf ("(%s + %s)" , s .args [0 ].String ( ), s .args [1 ].String ( )))
243
+ return 0 , true , types .ErrOverflow .GenWithStackByArgs ("BIGINT UNSIGNED" , fmt .Sprintf ("(%s + %s)" , s .args [0 ].StringWithCtx ( errors . RedactLogDisable ), s .args [1 ].StringWithCtx ( errors . RedactLogDisable )))
243
244
}
244
245
case ! isLHSUnsigned && ! isRHSUnsigned :
245
246
if (a > 0 && b > math .MaxInt64 - a ) || (a < 0 && b < math .MinInt64 - a ) {
246
- return 0 , true , types .ErrOverflow .GenWithStackByArgs ("BIGINT" , fmt .Sprintf ("(%s + %s)" , s .args [0 ].String ( ), s .args [1 ].String ( )))
247
+ return 0 , true , types .ErrOverflow .GenWithStackByArgs ("BIGINT" , fmt .Sprintf ("(%s + %s)" , s .args [0 ].StringWithCtx ( errors . RedactLogDisable ), s .args [1 ].StringWithCtx ( errors . RedactLogDisable )))
247
248
}
248
249
}
249
250
@@ -273,7 +274,7 @@ func (s *builtinArithmeticPlusDecimalSig) evalDecimal(ctx EvalContext, row chunk
273
274
err = types .DecimalAdd (a , b , c )
274
275
if err != nil {
275
276
if err == types .ErrOverflow {
276
- err = types .ErrOverflow .GenWithStackByArgs ("DECIMAL" , fmt .Sprintf ("(%s + %s)" , s .args [0 ].String ( ), s .args [1 ].String ( )))
277
+ err = types .ErrOverflow .GenWithStackByArgs ("DECIMAL" , fmt .Sprintf ("(%s + %s)" , s .args [0 ].StringWithCtx ( errors . RedactLogDisable ), s .args [1 ].StringWithCtx ( errors . RedactLogDisable )))
277
278
}
278
279
return nil , true , err
279
280
}
@@ -303,7 +304,7 @@ func (s *builtinArithmeticPlusRealSig) evalReal(ctx EvalContext, row chunk.Row)
303
304
return 0 , true , nil
304
305
}
305
306
if ! mathutil .IsFinite (a + b ) {
306
- return 0 , true , types .ErrOverflow .GenWithStackByArgs ("DOUBLE" , fmt .Sprintf ("(%s + %s)" , s .args [0 ].String ( ), s .args [1 ].String ( )))
307
+ return 0 , true , types .ErrOverflow .GenWithStackByArgs ("DOUBLE" , fmt .Sprintf ("(%s + %s)" , s .args [0 ].StringWithCtx ( errors . RedactLogDisable ), s .args [1 ].StringWithCtx ( errors . RedactLogDisable )))
307
308
}
308
309
return a + b , false , nil
309
310
}
@@ -368,7 +369,7 @@ func (s *builtinArithmeticMinusRealSig) evalReal(ctx EvalContext, row chunk.Row)
368
369
return 0 , isNull , err
369
370
}
370
371
if ! mathutil .IsFinite (a - b ) {
371
- return 0 , true , types .ErrOverflow .GenWithStackByArgs ("DOUBLE" , fmt .Sprintf ("(%s - %s)" , s .args [0 ].String ( ), s .args [1 ].String ( )))
372
+ return 0 , true , types .ErrOverflow .GenWithStackByArgs ("DOUBLE" , fmt .Sprintf ("(%s - %s)" , s .args [0 ].StringWithCtx ( errors . RedactLogDisable ), s .args [1 ].StringWithCtx ( errors . RedactLogDisable )))
372
373
}
373
374
return a - b , false , nil
374
375
}
@@ -396,7 +397,7 @@ func (s *builtinArithmeticMinusDecimalSig) evalDecimal(ctx EvalContext, row chun
396
397
err = types .DecimalSub (a , b , c )
397
398
if err != nil {
398
399
if err == types .ErrOverflow {
399
- err = types .ErrOverflow .GenWithStackByArgs ("DECIMAL" , fmt .Sprintf ("(%s - %s)" , s .args [0 ].String ( ), s .args [1 ].String ( )))
400
+ err = types .ErrOverflow .GenWithStackByArgs ("DECIMAL" , fmt .Sprintf ("(%s - %s)" , s .args [0 ].StringWithCtx ( errors . RedactLogDisable ), s .args [1 ].StringWithCtx ( errors . RedactLogDisable )))
400
401
}
401
402
return nil , true , err
402
403
}
@@ -434,7 +435,7 @@ func (s *builtinArithmeticMinusIntSig) evalInt(ctx EvalContext, row chunk.Row) (
434
435
}
435
436
overflow := s .overflowCheck (isLHSUnsigned , isRHSUnsigned , signed , a , b )
436
437
if overflow {
437
- return 0 , true , types .ErrOverflow .GenWithStackByArgs (errType , fmt .Sprintf ("(%s - %s)" , s .args [0 ].String ( ), s .args [1 ].String ( )))
438
+ return 0 , true , types .ErrOverflow .GenWithStackByArgs (errType , fmt .Sprintf ("(%s - %s)" , s .args [0 ].StringWithCtx ( errors . RedactLogDisable ), s .args [1 ].StringWithCtx ( errors . RedactLogDisable )))
438
439
}
439
440
440
441
return a - b , false , nil
@@ -578,7 +579,7 @@ func (s *builtinArithmeticMultiplyRealSig) evalReal(ctx EvalContext, row chunk.R
578
579
}
579
580
result := a * b
580
581
if math .IsInf (result , 0 ) {
581
- return 0 , true , types .ErrOverflow .GenWithStackByArgs ("DOUBLE" , fmt .Sprintf ("(%s * %s)" , s .args [0 ].String ( ), s .args [1 ].String ( )))
582
+ return 0 , true , types .ErrOverflow .GenWithStackByArgs ("DOUBLE" , fmt .Sprintf ("(%s * %s)" , s .args [0 ].StringWithCtx ( errors . RedactLogDisable ), s .args [1 ].StringWithCtx ( errors . RedactLogDisable )))
582
583
}
583
584
return result , false , nil
584
585
}
@@ -596,7 +597,7 @@ func (s *builtinArithmeticMultiplyDecimalSig) evalDecimal(ctx EvalContext, row c
596
597
err = types .DecimalMul (a , b , c )
597
598
if err != nil && ! terror .ErrorEqual (err , types .ErrTruncated ) {
598
599
if err == types .ErrOverflow {
599
- err = types .ErrOverflow .GenWithStackByArgs ("DECIMAL" , fmt .Sprintf ("(%s * %s)" , s .args [0 ].String ( ), s .args [1 ].String ( )))
600
+ err = types .ErrOverflow .GenWithStackByArgs ("DECIMAL" , fmt .Sprintf ("(%s * %s)" , s .args [0 ].StringWithCtx ( errors . RedactLogDisable ), s .args [1 ].StringWithCtx ( errors . RedactLogDisable )))
600
601
}
601
602
return nil , true , err
602
603
}
@@ -616,7 +617,7 @@ func (s *builtinArithmeticMultiplyIntUnsignedSig) evalInt(ctx EvalContext, row c
616
617
unsignedB := uint64 (b )
617
618
result := unsignedA * unsignedB
618
619
if unsignedA != 0 && result / unsignedA != unsignedB {
619
- return 0 , true , types .ErrOverflow .GenWithStackByArgs ("BIGINT UNSIGNED" , fmt .Sprintf ("(%s * %s)" , s .args [0 ].String ( ), s .args [1 ].String ( )))
620
+ return 0 , true , types .ErrOverflow .GenWithStackByArgs ("BIGINT UNSIGNED" , fmt .Sprintf ("(%s * %s)" , s .args [0 ].StringWithCtx ( errors . RedactLogDisable ), s .args [1 ].StringWithCtx ( errors . RedactLogDisable )))
620
621
}
621
622
return int64 (result ), false , nil
622
623
}
@@ -632,7 +633,7 @@ func (s *builtinArithmeticMultiplyIntSig) evalInt(ctx EvalContext, row chunk.Row
632
633
}
633
634
result := a * b
634
635
if (a != 0 && result / a != b ) || (result == math .MinInt64 && a == - 1 ) {
635
- return 0 , true , types .ErrOverflow .GenWithStackByArgs ("BIGINT" , fmt .Sprintf ("(%s * %s)" , s .args [0 ].String ( ), s .args [1 ].String ( )))
636
+ return 0 , true , types .ErrOverflow .GenWithStackByArgs ("BIGINT" , fmt .Sprintf ("(%s * %s)" , s .args [0 ].StringWithCtx ( errors . RedactLogDisable ), s .args [1 ].StringWithCtx ( errors . RedactLogDisable )))
636
637
}
637
638
return result , false , nil
638
639
}
@@ -697,7 +698,7 @@ func (s *builtinArithmeticDivideRealSig) evalReal(ctx EvalContext, row chunk.Row
697
698
}
698
699
result := a / b
699
700
if math .IsInf (result , 0 ) {
700
- return 0 , true , types .ErrOverflow .GenWithStackByArgs ("DOUBLE" , fmt .Sprintf ("(%s / %s)" , s .args [0 ].String ( ), s .args [1 ].String ( )))
701
+ return 0 , true , types .ErrOverflow .GenWithStackByArgs ("DOUBLE" , fmt .Sprintf ("(%s / %s)" , s .args [0 ].StringWithCtx ( errors . RedactLogDisable ), s .args [1 ].StringWithCtx ( errors . RedactLogDisable )))
701
702
}
702
703
return result , false , nil
703
704
}
@@ -726,7 +727,7 @@ func (s *builtinArithmeticDivideDecimalSig) evalDecimal(ctx EvalContext, row chu
726
727
err = c .Round (c , s .baseBuiltinFunc .tp .GetDecimal (), types .ModeHalfUp )
727
728
}
728
729
} else if err == types .ErrOverflow {
729
- err = types .ErrOverflow .GenWithStackByArgs ("DECIMAL" , fmt .Sprintf ("(%s / %s)" , s .args [0 ].String ( ), s .args [1 ].String ( )))
730
+ err = types .ErrOverflow .GenWithStackByArgs ("DECIMAL" , fmt .Sprintf ("(%s / %s)" , s .args [0 ].StringWithCtx ( errors . RedactLogDisable ), s .args [1 ].StringWithCtx ( errors . RedactLogDisable )))
730
731
}
731
732
return c , false , err
732
733
}
@@ -857,14 +858,14 @@ func (s *builtinArithmeticIntDivideDecimalSig) evalInt(ctx EvalContext, row chun
857
858
ret = int64 (0 )
858
859
return ret , false , nil
859
860
}
860
- return 0 , true , types .ErrOverflow .GenWithStackByArgs ("BIGINT UNSIGNED" , fmt .Sprintf ("(%s DIV %s)" , s .args [0 ].String ( ), s .args [1 ].String ( )))
861
+ return 0 , true , types .ErrOverflow .GenWithStackByArgs ("BIGINT UNSIGNED" , fmt .Sprintf ("(%s DIV %s)" , s .args [0 ].StringWithCtx ( errors . RedactLogDisable ), s .args [1 ].StringWithCtx ( errors . RedactLogDisable )))
861
862
}
862
863
ret = int64 (val )
863
864
} else {
864
865
ret , err = c .ToInt ()
865
866
// err returned by ToInt may be ErrTruncated or ErrOverflow, only handle ErrOverflow, ignore ErrTruncated.
866
867
if err == types .ErrOverflow {
867
- return 0 , true , types .ErrOverflow .GenWithStackByArgs ("BIGINT" , fmt .Sprintf ("(%s DIV %s)" , s .args [0 ].String ( ), s .args [1 ].String ( )))
868
+ return 0 , true , types .ErrOverflow .GenWithStackByArgs ("BIGINT" , fmt .Sprintf ("(%s DIV %s)" , s .args [0 ].StringWithCtx ( errors . RedactLogDisable ), s .args [1 ].StringWithCtx ( errors . RedactLogDisable )))
868
869
}
869
870
}
870
871
0 commit comments