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: let round take effect in converting float string to int string. #8279

Merged
merged 20 commits into from Nov 26, 2018

Conversation

Projects
None yet
6 participants
@lzmhhh123
Member

lzmhhh123 commented Nov 12, 2018

What problem does this PR solve?

When float string converts to int string. It always rounds down in TiDB. But in MySQL, it rounds.
Pls look this example:

In MySQL

mysql > create table t(a int unsigned);
Query OK, 0 rows affected (0.05 sec)

mysql > insert into t values("0.1"), ("0.8");
Query OK, 2 rows affected (0.11 sec)
Records: 2  Duplicates: 0  Warnings: 0

mysql > insert into t values("-0.1");
Query OK, 1 row affected (0.04 sec)

mysql > select * from t;
+------+
| a    |
+------+
|    0 |
|    1 |
|    0 |
+------+
3 rows in set (0.00 sec)

In TiDB

tidb(localhost:4000) > create table t(a int unsigned);
Query OK, 0 rows affected (0.02 sec)

tidb(localhost:4000) > insert into t values("0.1"), ("0.8");
Query OK, 2 rows affected (0.00 sec)

tidb(localhost:4000) > insert into t values("-0.1");
ERROR 1264 (22003): Out of range value for column 'a' at row 1

tidb(localhost:4000) > select * from t;
+------+
| a    |
+------+
|    0 |
|    0 |
+------+
2 rows in set (0.00 sec)

What is changed and how it works?

Change the function floatStrToIntStr in types/convert.go.

Check List

Tests

  • Unit test
  • Integration test

Related changes

  • Need to cherry-pick to the release branch

This change is Reviewable

fix
@XuHuaiyu

This comment has been minimized.

Contributor

XuHuaiyu commented Nov 13, 2018

/run-all-tests

Show resolved Hide resolved expression/builtin_time_test.go Outdated
Show resolved Hide resolved types/convert.go Outdated

lzmhhh123 added some commits Nov 13, 2018

fix
fix
fix
@winoros

main changes lgtm

Show resolved Hide resolved types/convert.go Outdated
Show resolved Hide resolved expression/builtin_time.go
Show resolved Hide resolved expression/builtin_time.go Outdated

lzmhhh123 added some commits Nov 18, 2018

Show resolved Hide resolved expression/builtin_time.go Outdated
Show resolved Hide resolved expression/builtin_time.go Outdated
Show resolved Hide resolved expression/builtin_time.go Outdated
Show resolved Hide resolved types/convert.go Outdated
Show resolved Hide resolved types/convert.go Outdated
Show resolved Hide resolved types/convert.go

lzmhhh123 and others added some commits Nov 21, 2018

@@ -4556,18 +4569,28 @@ func (b *builtinMakeTimeSig) Clone() builtinFunc {
return newSig
}
// calculate for hour and minute

This comment has been minimized.

@winoros

winoros Nov 22, 2018

Member

Comment should follow the format FuncName ....

@zz-jason

LGTM

@zz-jason zz-jason merged commit 8783877 into pingcap:master Nov 26, 2018

4 checks passed

ci/circleci Your tests passed on CircleCI!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
jenkins-ci-tidb/build Jenkins job succeeded.
Details
license/cla Contributor License Agreement is signed.
Details

zz-jason added a commit to zz-jason/tidb that referenced this pull request Nov 27, 2018

zz-jason added a commit that referenced this pull request Nov 28, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment