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: throw "too big precision" error for CAST(AS TIME) #8907

Merged
merged 11 commits into from
Jan 9, 2019

Conversation

zz-jason
Copy link
Member

@zz-jason zz-jason commented Jan 2, 2019

What problem does this PR solve?

For the following SQL:

SELECT CAST(1 AS TIME(31));

we should return a error as MySQL does:

MySQL(localhost:3306) > SELECT CAST(1 AS TIME(31));
ERROR 1426 (42000): Too-big precision 31 specified for 'CAST'. Maximum is 6.

Another tiny bugfix is, for cast decimal as time, when the input decimal is NULL, we should return NULL.

What is changed and how it works?

Check the target precision first, if the check result is positive, we then continue to recursively evaluate child expression.

Check List

Tests

  • Unit test

Code changes

  • Has exported function/method change

Related changes

  • Need to cherry-pick to the release branch
  • Need to be included in the release note

This change is Reviewable

@zz-jason zz-jason requested review from qw4990 and XuHuaiyu January 2, 2019 09:32
Copy link
Contributor

@XuHuaiyu XuHuaiyu left a comment

Choose a reason for hiding this comment

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

LGTM

expression/builtin_cast.go Outdated Show resolved Hide resolved
expression/builtin_cast.go Outdated Show resolved Hide resolved
@lysu
Copy link
Contributor

lysu commented Jan 7, 2019

/run-all-tests tidb-test=pr/711

@lysu
Copy link
Contributor

lysu commented Jan 7, 2019

/run-all-tests

@codecov-io
Copy link

codecov-io commented Jan 8, 2019

Codecov Report

Merging #8907 into master will increase coverage by 0.03%.
The diff coverage is 55.55%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #8907      +/-   ##
==========================================
+ Coverage   67.55%   67.58%   +0.03%     
==========================================
  Files         363      363              
  Lines       75301    75309       +8     
==========================================
+ Hits        50868    50901      +33     
+ Misses      19940    19917      -23     
+ Partials     4493     4491       -2
Impacted Files Coverage Δ
planner/core/errors.go 100% <100%> (ø) ⬆️
expression/builtin_cast.go 79.98% <100%> (+2.54%) ⬆️
planner/core/expression_rewriter.go 67.08% <42.85%> (-0.18%) ⬇️
executor/join.go 77.89% <0%> (-0.41%) ⬇️
expression/distsql_builtin.go 28.05% <0%> (+0.36%) ⬆️
store/tikv/lock_resolver.go 42.65% <0%> (+0.94%) ⬆️

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 bb2d56a...6e0cc97. Read the comment docs.

@zz-jason zz-jason requested review from eurekaka and XuHuaiyu January 8, 2019 07:44
@lonng
Copy link
Contributor

lonng commented Jan 8, 2019

/run-all-tests

Copy link
Contributor

@eurekaka eurekaka left a comment

Choose a reason for hiding this comment

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

LGTM

@eurekaka eurekaka added the status/LGT1 Indicates that a PR has LGTM 1. label Jan 8, 2019
@XuHuaiyu XuHuaiyu added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Jan 8, 2019
@zz-jason zz-jason requested a review from XuHuaiyu January 9, 2019 03:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/expression status/LGT2 Indicates that a PR has LGTM 2. type/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants