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

types: fix FLOAT data overflow check (#20067) (#20158) #20252

Merged
merged 3 commits into from
Oct 3, 2020

Conversation

ti-srebot
Copy link
Contributor

cherry-pick #20158 to release-4.0


What problem does this PR solve?

Issue Number: close #20067

Problem Summary:

Execute

DROP TABLE IF EXISTS t_5_1_1_1_float;
CREATE TABLE t_5_1_1_1_float ( col1 FLOAT, col2 FLOAT(10,2), col3 DOUBLE, col4 DOUBLE(10,2), col5 DECIMAL, col6  DECIMAL(10,2) ) ;
INSERT INTO t_5_1_1_1_float VALUES (-3.402823466E+68, -34028234.6611, -1.7976931348623157E+308, -17976921.34, -9999999999, -99999999.99);

TiDB 4.0.5

mysql> INSERT INTO t_5_1_1_1_float VALUES (-3.402823466E+68, -34028234.6611, -1.7976931348623157E+308, -17976921.34, -9999999999, -99999999.99);
Query OK, 1 row affected (0.01 sec)
mysql> SELECT * FROM t_5_1_1_1_float;
+------+--------------+-------------------------+--------------+-------------+--------------+
| col1 | col2         | col3                    | col4         | col5        | col6         |
+------+--------------+-------------------------+--------------+-------------+--------------+
| -Inf | -34028236.00 | -1.7976931348623157e308 | -17976921.34 | -9999999999 | -99999999.99 |
+------+--------------+-------------------------+--------------+-------------+--------------+
1 row in set (0.00 sec)

MySQL 5.7.29

mysql> INSERT INTO t_5_1_1_1_float VALUES (-3.402823466E+68, -34028234.6611, -1.7976931348623157E+308, -17976921.34, -9999999999, -99999999.99);
ERROR 1264 (22003): Out of range value for column 'col1' at row 1

What is changed and how it works?

What's Changed:

How it Works:

​ when the target column is TypeFloat, and the inserted value overflow (greater then math.MaxFloat32 or less than -math.MaxFloat32) return error

Related changes

  • Need to cherry-pick to the release branch

Check List

Tests

  • Integration test

Release note

  • fix FLOAT data type: out of range data should not be inserted

Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor Author

/run-all-tests

Copy link
Contributor

@SunRunAway SunRunAway left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-srebot ti-srebot added the status/LGT1 Indicates that a PR has LGTM 1. label Sep 27, 2020
Copy link
Contributor

@lzmhhh123 lzmhhh123 left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-srebot
Copy link
Contributor Author

@lzmhhh123, Thanks for your review, however we are sorry that your vote won't be count.

Copy link
Member

@zz-jason zz-jason left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-srebot ti-srebot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Oct 3, 2020
@zz-jason
Copy link
Member

zz-jason commented Oct 3, 2020

/merge

@ti-srebot ti-srebot added the status/can-merge Indicates a PR has been approved by a committer. label Oct 3, 2020
@ti-srebot
Copy link
Contributor Author

Your auto merge job has been accepted, waiting for:

  • 20077
  • 20297
  • 20293
  • 20155
  • 20074

@ti-srebot
Copy link
Contributor Author

/run-all-tests

@ti-srebot
Copy link
Contributor Author

@ti-srebot merge failed.

@zz-jason zz-jason merged commit 9518e90 into pingcap:release-4.0 Oct 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/expression contribution This PR is from a community contributor. sig/execution SIG execution status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. type/4.0-cherry-pick
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants