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

Autoid value is incorrect when field type is float or double #11109

Closed
nange opened this issue Jul 6, 2019 · 2 comments · Fixed by #11110
Closed

Autoid value is incorrect when field type is float or double #11109

nange opened this issue Jul 6, 2019 · 2 comments · Fixed by #11110
Labels
type/bug The issue is confirmed as a bug.

Comments

@nange
Copy link
Contributor

nange commented Jul 6, 2019

Bug Report

Please answer these questions before submitting your issue. Thanks!

  1. What did you do?
    If possible, provide a recipe for reproducing the error.
use test;
create table t1(id int primary key, n float auto_increment, key I_n(n));
create table t2(id int primary key, n double auto_increment, key I_n(n));
insert into t1 values(1, 1);
insert into t2 values(1, 1);
insert into t2(id) values(2);
  1. What did you expect to see?
mysql> select * from t1;
+----+---+
| id | n |
+----+---+
|  1 | 1 |
+----+---+
1 row in set (0.00 sec)
mysql> select * from t2;
+----+---+
| id | n |
+----+---+
|  1 | 1 |
|  2 | 2 |
+----+---+
2 rows in set (0.00 sec)
  1. What did you see instead?
mysql> select * from t1;
+----+------+
| id | n    |
+----+------+
|  1 |    0 |
+----+------+
1 row in set (0.00 sec)
mysql> select * from t2;
+----+-----------------------+
| id | n                     |
+----+-----------------------+
|  1 |                     1 |
|  2 | 4.6071824188000174e18 |
+----+-----------------------+
2 rows in set (0.00 sec)
  1. What version of TiDB are you using (tidb-server -V or run select tidb_version(); on TiDB)?
./tidb-server -V

Release Version: v3.0.0-rc.1-290-g21d2590ac
Git Commit Hash: 21d2590ac37bf53e5e687b8a341d50105ddbffe8
Git Branch: master
UTC Build Time: 2019-07-06 12:56:31
GoVersion: go version go1.12.6 darwin/amd64
Race Enabled: false
TiKV Min Version: 2.1.0-alpha.1-ff3dd160846b7d1aed9079c389fc188f7f5ea13e
Check Table Before Drop: false
@crazycs520
Copy link
Contributor

Thanks for report and contribution.

BTW, the other case may have the same problem, I just test update:

use test;
create table t1(id int primary key, n float auto_increment, key I_n(n));
insert into t1 set id=1;
update t1 set n=n+1;
insert into t1 set id=2;

select * from t1;
+----+--------------+
| id | n            |
+----+--------------+
| 1  | 2.0          |
| 2  | 4.611686e+18 |
+----+--------------+

@nange
Copy link
Contributor Author

nange commented Jul 6, 2019

I will take a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants