tidb icon indicating copy to clipboard operation
tidb copied to clipboard

float type ?

Open martin-ly opened this issue 8 years ago • 11 comments

Description

Please answer these questions before submitting your issue. Thanks!

  1. 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)
  1. 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)
  1. What version of TiDB are you using (tidb-server -V or run select 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

#sig-exec

Score

  • 300

Mentor

  • @qw4990

martin-ly avatar Jun 22 '18 07:06 martin-ly

@waderly Thank you for your feedback!

ciscoxll avatar Jun 22 '18 13:06 ciscoxll

@waderly We will fix the problem as soon as possible.

ciscoxll avatar Jun 22 '18 13:06 ciscoxll

PTAL @XuHuaiyu

tiancaiamao avatar Jun 22 '18 15:06 tiancaiamao

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)

wwar avatar Apr 10 '20 23:04 wwar

/pick-up

yufan022 avatar Nov 17 '20 02:11 yufan022

Pick up success.

ghost avatar Nov 17 '20 02:11 ghost

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 avatar Nov 20 '20 07:11 yufan022

@yufan022 You did not submit PR within 7 days, so give up automatically.

ghost avatar Nov 24 '20 02:11 ghost

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)

wjhuang2016 avatar Dec 11 '20 10:12 wjhuang2016

Fixed by https://github.com/pingcap/tidb/pull/18973

wjhuang2016 avatar Dec 11 '20 10:12 wjhuang2016

Please edit this comment or add a new comment to complete the following information

Not a bug

  1. Remove the 'type/bug' label
  2. Add notes to indicate why it is not a bug

Duplicate bug

  1. Add the 'type/duplicate' label
  2. 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

ti-srebot avatar Dec 11 '20 10:12 ti-srebot