Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOUBLE type can't keep precise #21692

Closed
lance6716 opened this issue Dec 14, 2020 · 5 comments · Fixed by #21788
Closed

DOUBLE type can't keep precise #21692

lance6716 opened this issue Dec 14, 2020 · 5 comments · Fixed by #21788
Assignees
Labels
severity/moderate sig/execution SIG execution type/bug The issue is confirmed as a bug.

Comments

@lance6716
Copy link
Contributor

lance6716 commented Dec 14, 2020

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

lightning's CI

create table precise_types (
    a BIGINT UNSIGNED NOT NULL,
    b BIGINT NOT NULL,
    c DECIMAL(21,1) NOT NULL,
    d DOUBLE(21,1) NOT NULL
);
insert into precise_types values (
    18446744073709551614,
    -9223372036854775806,
    99999999999999999999,
    18446744073709551614
);
SELECT a, b, c, d FROM precise_types\G

2. What did you expect to see? (Required)

MySQL 8.0.19

mysql> SELECT a, b, c, d FROM precise_types\G
*************************** 1. row ***************************
a: 18446744073709551614
b: -9223372036854775806
c: 99999999999999999999.0
d: 18446744073709552000.0
1 row in set (0.00 sec)

3. What did you see instead (Required)

mysql> SELECT a, b, c, d FROM precise_types\G
*************************** 1. row ***************************
a: 18446744073709551614
b: -9223372036854775806
c: 99999999999999999999.0
d: 1.8e19
1 row in set (0.01 sec)

4. What is your TiDB version? (Required)

Release Version: v4.0.0-beta.2-1804-g06cd92e05
Edition: Community
Git Commit Hash: 06cd92e
Git Branch: HEAD
UTC Build Time: 2020-12-12 21:09:27
GoVersion: go1.13.4
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false

@lance6716 lance6716 added the type/bug The issue is confirmed as a bug. label Dec 14, 2020
@ti-srebot
Copy link
Contributor

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: #20100

1. Root Cause Analysis (RCA) (optional)

2. Symptom (optional)

3. All Trigger Conditions (optional)

4. Workaround (optional)

5. Affected versions

6. Fixed versions

@lance6716
Copy link
Contributor Author

/unlabel type/bug

we didn't support DOUBLE(M,D) since https://dev.mysql.com/doc/refman/8.0/en/floating-point-types.html

@ti-srebot ti-srebot removed the type/bug The issue is confirmed as a bug. label Dec 14, 2020
@lance6716 lance6716 reopened this Dec 14, 2020
@lance6716
Copy link
Contributor Author

/label type/bug

since behaviour is not same with MySQL 8.0 (thought a deprecated feature), I still let this issue open

@tangenta
Copy link
Contributor

tangenta commented Jan 8, 2021

I don't think this bug is fixed, here is the result in master(gcec1a9265):

mysql> SELECT a, b, c, d FROM precise_types\G;
*************************** 1. row ***************************
a: 18446744073709551614
b: -9223372036854775806
c: 99999999999999999999.0
d: 1.8446744073709552e19
1 row in set (0.00 sec)

got: 1.8446744073709552e19
expected: 18446744073709552000.0

@tangenta tangenta reopened this Jan 8, 2021
@lzmhhh123
Copy link
Contributor

I don't think this bug is fixed, here is the result in master(gcec1a9265):

mysql> SELECT a, b, c, d FROM precise_types\G;
*************************** 1. row ***************************
a: 18446744073709551614
b: -9223372036854775806
c: 99999999999999999999.0
d: 1.8446744073709552e19
1 row in set (0.00 sec)

got: 1.8446744073709552e19
expected: 18446744073709552000.0

1.8446744073709552e19 is equal to 18446744073709552000.0. For MySQL protocol, they are the same when received from the user.

johan-j added a commit to johan-j/tidb that referenced this issue Feb 28, 2021
This resolve issue pingcap#22791: query result for float type is incompatible with previous version

It seems like this broke in the fix for issue pingcap#21692. In mysql, e-format
is only returned when used in the query, for example:
select 1e15, will print 1e15 back.
However, when stored in a table mysel will print it in decimal form.
issue pingcap#21692 resolved this by checking for empty table. However, that
fix applies for everything rather than only for e-format. And that
caused the new issue pingcap#22791.

This resolves both pingcap#22791 and pingcap#21692.

It also resolve an issue where for a default width float column we do
not round to the mysql default precision.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity/moderate sig/execution SIG execution type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants