float type ?
Description
Please answer these questions before submitting your issue. Thanks!
- What did you do? If possible, provide a recipe for reproducing the error.
set @j = 1000.31231231200432;
set @k = 9381238.3123123120032;
set @i = @j - @k;
select @i;
float algorithm 2. What did you expect to see?
mysql> set @j = 1000.31231231200432;
Query OK, 0 rows affected (0.00 sec)
mysql> set @k = 9381238.3123123120032;
Query OK, 0 rows affected (0.00 sec)
mysql> set @i = @j - @k;
Query OK, 0 rows affected (0.00 sec)
mysql> select @i;
+-------------------------+
| @i |
+-------------------------+
| -9380237.99999999999888 |
+-------------------------+
1 row in set (0.00 sec)
- What did you see instead?
tidb> set @j = 1000.31231231200432;
Query OK, 0 rows affected (0.00 sec)
tidb> set @k = 9381238.3123123120032;
Query OK, 0 rows affected (0.01 sec)
tidb> set @i = @j - @k;
Query OK, 0 rows affected (0.00 sec)
tidb> select @i;
+----------+
| @i |
+----------+
| -9380238 |
+----------+
1 row in set (0.00 sec)
- What version of TiDB are you using (
tidb-server -Vor runselect tidb_version();on TiDB)?
tidb> select @@version;
+--------------------------------------+
| @@version |
+--------------------------------------+
| 5.7.10-TiDB-v2.1.0-alpha-59-g8bec188 |
+--------------------------------------+
1 row in set (0.00 sec)
SIG slack channel
Score
- 300
Mentor
- @qw4990
@waderly Thank you for your feedback!
@waderly We will fix the problem as soon as possible.
PTAL @XuHuaiyu
Confirming that this is still an issue:
tidb> set @j = 1000.31231231200432;
Query OK, 0 rows affected (0.00 sec)
tidb> set @k = 9381238.3123123120032;
Query OK, 0 rows affected (0.00 sec)
tidb> set @i = @j - @k;
Query OK, 0 rows affected (0.00 sec)
tidb> select @i;
+----------+
| @i |
+----------+
| -9380238 |
+----------+
1 row in set (0.00 sec)
tidb> select tidb_version()\G
*************************** 1. row ***************************
tidb_version(): Release Version: v4.0.0-beta.2-183-g57db6cec7
Git Commit Hash: 57db6cec7ffad78e74b6ac6c67a2bfe9a6718d17
Git Branch: master
UTC Build Time: 2020-04-04 08:06:18
GoVersion: go1.13
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
1 row in set (0.00 sec)
/pick-up
Pick up success.
mysql> set @j = 1000.31231231200432;
Query OK, 0 rows affected (0.00 sec)
mysql> set @k = 9381238.3123123120032;
Query OK, 0 rows affected (0.00 sec)
mysql> set @i = @j - @k;
Query OK, 0 rows affected (0.00 sec)
mysql> select @i;
+-------------------------+
| @i |
+-------------------------+
| -9380237.99999999999888 |
+-------------------------+
1 row in set (0.00 sec)
mysql> select tidb_version()\G
*************************** 1. row ***************************
tidb_version(): Release Version: None
Edition: Community
Git Commit Hash: None
Git Branch: None
UTC Build Time: None
GoVersion: go1.13.8
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
1 row in set (0.00 sec)
mysql> select @@version;
+------------------+
| @@version |
+------------------+
| 5.7.25-TiDB-None |
+------------------+
1 row in set (0.00 sec)
The master branch has been fixed.
@yufan022 You did not submit PR within 7 days, so give up automatically.
Confirm that this bug had been fixed in master and release 4.0.
mysql> set @j = 1000.31231231200432;
Query OK, 0 rows affected (0.00 sec)
mysql> set @k = 9381238.3123123120032;
Query OK, 0 rows affected (0.00 sec)
mysql> set @i = @j - @k;
Query OK, 0 rows affected (0.00 sec)
mysql> select @i;
+-------------------------+
| @i |
+-------------------------+
| -9380237.99999999999888 |
+-------------------------+
1 row in set (0.00 sec)
Fixed by https://github.com/pingcap/tidb/pull/18973
Please edit this comment or add a new comment to complete the following information
Not a bug
- Remove the 'type/bug' label
- Add notes to indicate why it is not a bug
Duplicate bug
- Add the 'type/duplicate' label
- Add the link to the original bug
Bug
Note: Make Sure that 'component', and 'severity' labels are added Example for how to fill out the template: https://github.com/pingcap/tidb/issues/20100
1. Root Cause Analysis (RCA) (optional)
2. Symptom (optional)
3. All Trigger Conditions (optional)
4. Workaround (optional)
5. Affected versions
[v3.0.0:v3.0.19], [v4.0.0, v4.0.8]
6. Fixed versions
v4.0.9