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

expression: fix type infer of unaryMinus which should return ETDecimal if ETInt overflow int #11989

Merged
merged 3 commits into from
Sep 2, 2019
Merged

expression: fix type infer of unaryMinus which should return ETDecimal if ETInt overflow int #11989

merged 3 commits into from
Sep 2, 2019

Conversation

lonng
Copy link
Contributor

@lonng lonng commented Sep 2, 2019

Signed-off-by: Lonng heng@lonng.org

What problem does this PR solve?

Fix #11983

The typeInfer of unaryMinus function should return types.ETDecimal if the inferred type is types.ETInt and the value will overflow the int bound.

mysql> create table f (a decimal(65, 0));
Query OK, 0 rows affected (0.02 sec)

mysql> insert into f value (-17000000000000000000);
ERROR 1264 (22003): Out of range value for column 'a' at row 1

What is changed and how it works?

Relax restrictions of the unaryMinus.typeInfer which should alway handle int overflow instead of just in SELECT statement.

Check List

Tests

  • Unit test
  • Integration test

Related changes

  • Need to update the tidb-ansible repository

Release note

  • Fix type infers of unaryMinus which should return ETDecimal if the ETInt overflow int bound.

…l if overflow int

Signed-off-by: Lonng <heng@lonng.org>
Signed-off-by: Lonng <heng@lonng.org>
@codecov
Copy link

codecov bot commented Sep 2, 2019

Codecov Report

Merging #11989 into master will decrease coverage by 0.0534%.
The diff coverage is 100%.

@@               Coverage Diff                @@
##             master     #11989        +/-   ##
================================================
- Coverage   81.2782%   81.2248%   -0.0535%     
================================================
  Files           444        443         -1     
  Lines         95130      95019       -111     
================================================
- Hits          77320      77179       -141     
- Misses        12322      12347        +25     
- Partials       5488       5493         +5

@lonng
Copy link
Contributor Author

lonng commented Sep 2, 2019

/run-all-tests

Copy link
Contributor

@winkyao winkyao left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@crazycs520 crazycs520 left a comment

Choose a reason for hiding this comment

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

LGTM

@lonng lonng added the status/can-merge Indicates a PR has been approved by a committer. label Sep 2, 2019
@lonng lonng changed the title expression: fix type infer of unaryMinus which should return ETDecimal if overflow int expression: fix type infer of unaryMinus which should return ETDecimal if ETInt overflow int Sep 2, 2019
@sre-bot
Copy link
Contributor

sre-bot commented Sep 2, 2019

/run-all-tests

@lonng lonng merged commit 67d4f91 into pingcap:master Sep 2, 2019
@lonng lonng deleted the fix-unary-minus-type-infer branch September 2, 2019 13:30
@lonng
Copy link
Contributor Author

lonng commented Sep 2, 2019

/run-cherry-picker

@sre-bot
Copy link
Contributor

sre-bot commented Sep 2, 2019

cherry pick to release-2.1 in PR #11990

@sre-bot
Copy link
Contributor

sre-bot commented Sep 2, 2019

cherry pick to release-3.0 in PR #11991

winkyao pushed a commit that referenced this pull request Sep 2, 2019
sre-bot added a commit that referenced this pull request Sep 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/expression status/can-merge Indicates a PR has been approved by a committer.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can 't insert data to decimal(65, 0)
4 participants