pingcap/tidb
GitHub で見るArithmetic results are not consistent with MySQL when overflow occurs
Open
#4,475 opened on 2017年9月8日
component/expressionhelp wantedpriority/P4type/compatibility
説明
Please answer these questions before submitting your issue. Thanks!
- What did you do? If possible, provide a recipe for reproducing the error.
SET @a:=999999999999999;
select @a + @a; -- 1999999999999998
SET @a:=9999999999999999;
select @a + @a; -- 20000000000000000
SET @a:=99999999999999999;
select @a + @a; -- 20000000000000000
select @a * @a; -- 1000000000000000000000000000000000000
SELECT -@a - @a; -- -2000000000000000000
SELECT @a / 0.5; -- 2000000000000000000
select round(999999999999999999, -18); -- tidb: 999999999999999872, mysql: 1000000000000000000
select round(9999999999999999999, -18); -- tidb: 10446744073709552640, mysql: 100000000000000000000
- What did you expect to see?
@a + @a
1999999999999998
@a + @a
19999999999999998
@a + @a
199999999999999998
ERROR 1690 (22003) at line 7: BIGINT value is out of range in '((@`a`) * (@`a`))'
-@a - @a
-199999999999999998
@a / 0.5
199999999999999998.0000
round(999999999999999999, -18)
1000000000000000000
round(9999999999999999999, -18)
10000000000000000000
- What did you see instead?
@a + @a
1999999999999998
@a + @a
20000000000000000
@a + @a
200000000000000000
@a * @a
10000000000000000000000000000000000
-@a - @a
-200000000000000000
@a / 0.5
200000000000000000
round(999999999999999999, -18)
999999999999999872
round(9999999999999999999, -18)
10446744073709552640
- What version of TiDB are you using (
tidb-server -V)?