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

Fix handling of FLOAT(p), FLOAT(m,d) and DECIMAL(m,0) types esp. w.r.t. Restore() #311

Merged
merged 5 commits into from
Jun 4, 2019

Conversation

kennytm
Copy link
Contributor

@kennytm kennytm commented May 1, 2019

What problem does this PR solve?

  1. Fix The column type DECIMAL(20,0) is restored incorrectly as DECIMAL #310 regarding Restore() of FLOAT(m,0), DOUBLE(m,0) and DECIMAL(m,0).
  2. Ensure FLOAT(m,d) is always a FLOAT, never a DOUBLE.
  3. Ensure all of FLOAT(0) to FLOAT(24) map to the same FLOAT, and all of FLOAT(25) to FLOAT(53) map to the same DOUBLE.

What is changed and how it works?

  1. Refactored (*FieldType).Restore() such that all types share the same Tp(m,d) restore logic (except TIME(d) and friends).
  2. Changed the parser logic for FloatingPointType to distinguish between the FLOAT(m,d) and FLOAT(p) cases.
  3. Added a bunch of test cases about the behavior of Tp(m,d) for the rest of types.

Check List

Tests

  • Unit test

Code changes

Side effects

  • Breaking backward compatibility
    • FLOAT(24,1) produces a FLOAT instead of a DOUBLE, matching behavior of MySQL 8 (but note that FLOAT(m,d) is deprecated since MySQL 8.0.17).

Related changes

@kennytm kennytm force-pushed the kennytm/fix-310 branch 3 times, most recently from 6c37450 to 4895aa8 Compare May 1, 2019 10:22
* FLOAT(50,4) should not automatically become a DOUBLE, it is just a FLOAT
  shown with 50 digits.
* FLOAT(0) and FLOAT(24) are the alias of the same type FLOAT. There is no
  need to record the Flen.
@kennytm
Copy link
Contributor Author

kennytm commented May 5, 2019

PTAL @tiancaiamao

@codecov
Copy link

codecov bot commented May 29, 2019

Codecov Report

Merging #311 into master will not change coverage.
The diff coverage is 0%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #311   +/-   ##
=======================================
  Coverage   53.37%   53.37%           
=======================================
  Files          31       31           
  Lines        6540     6540           
=======================================
  Hits         3491     3491           
  Misses       2707     2707           
  Partials      342      342
Impacted Files Coverage Δ
parser.go 70.58% <ø> (ø) ⬆️
types/field_type.go 31.72% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1e93bd0...299c216. Read the comment docs.

@tiancaiamao
Copy link
Collaborator

LGTM
PTAL @lysu

Copy link
Collaborator

@lysu lysu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kennytm kennytm merged commit 7fdc36c into master Jun 4, 2019
@kennytm kennytm deleted the kennytm/fix-310 branch June 4, 2019 13:40
tiancaiamao pushed a commit to tiancaiamao/parser that referenced this pull request Apr 27, 2021
…t. Restore() (pingcap#311)

* parser: fix handling of FLOAT(p) and FLOAT(m,d) types

* FLOAT(50,4) should not automatically become a DOUBLE, it is just a FLOAT
  shown with 50 digits.
* FLOAT(0) and FLOAT(24) are the alias of the same type FLOAT. There is no
  need to record the Flen.

* types: fix Restore of DECIMAL(m,0) types

* tests: add test cases
lyonzhi pushed a commit to lyonzhi/parser that referenced this pull request Apr 25, 2024
…t. Restore() (pingcap#311)

* parser: fix handling of FLOAT(p) and FLOAT(m,d) types

* FLOAT(50,4) should not automatically become a DOUBLE, it is just a FLOAT
  shown with 50 digits.
* FLOAT(0) and FLOAT(24) are the alias of the same type FLOAT. There is no
  need to record the Flen.

* types: fix Restore of DECIMAL(m,0) types

* tests: add test cases
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The column type DECIMAL(20,0) is restored incorrectly as DECIMAL
3 participants