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

consider unsigned int for built-in function truncate #7591

Closed
XuHuaiyu opened this issue Sep 3, 2018 · 5 comments · Fixed by #8000
Closed

consider unsigned int for built-in function truncate #7591

XuHuaiyu opened this issue Sep 3, 2018 · 5 comments · Fixed by #8000
Labels
component/expression good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. type/compatibility

Comments

@XuHuaiyu
Copy link
Contributor

XuHuaiyu commented Sep 3, 2018

Please answer these questions before submitting your issue. Thanks!

  1. What did you do?
CREATE TABLE `t` (
  `a` bigint(20) UNSIGNED DEFAULT NULL
);
insert into t value(cast(a as unsigned));;
  1. What did you expect to see?
mysql> select truncate(a, 1) from t;
+----------------------+
| truncate(a, 1)       |
+----------------------+
| 18446744073709551615 |
+----------------------+
1 row in set (0.01 sec)
  1. What did you see instead?
tidb> select truncate(a, 1) from t;
+----------------+
| truncate(a, 1) |
+----------------+
|           NULL |
+----------------+
1 row in set (0.00 sec)
  1. What version of TiDB are you using (tidb-server -V or run select tidb_version(); on TiDB)?
tidb> select tidb_Version();
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_Version()                                                                                                                                                                                                                                                                                                                      |
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v2.1.0-rc.1-41-g3d891d9c2
Git Commit Hash: 3d891d9c2666a4812f77fc286d696f279a9e8e4c
Git Branch: master
UTC Build Time: 2018-09-03 08:14:20
GoVersion: go version go1.10.3 darwin/amd64
Race Enabled: false
TiKV Min Version: 2.1.0-alpha.1-ff3dd160846b7d1aed9079c389fc188f7f5ea13e
Check Table Before Drop: false |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
@XuHuaiyu XuHuaiyu added help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. type/compatibility good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. labels Sep 3, 2018
@mz1999
Copy link
Contributor

mz1999 commented Sep 6, 2018

I executed the above SQL statements on MySQL, Why didn't I get the expected results?

CREATE TABLE `t` (
  `a` bigint(20) UNSIGNED DEFAULT NULL
);
insert into t value(cast(a as unsigned));

mysql> select truncate(a, 1) from t;
+----------------+
| truncate(a, 1) |
+----------------+
|           NULL |
+----------------+
1 row in set (0.01 sec)

MySQL version is 5.7

mysql> select version();
+-----------+
| version() |
+-----------+
| 5.7.22    |
+-----------+
1 row in set (0.00 sec)

@winoros
Copy link
Member

winoros commented Sep 6, 2018

@mz1999
The insert sql should be same with insert into t value(cast(DEFAULT as unsigned));
cast(default as unsigned) => cast(null as unsigned) => null
truncate(NULL, 1) = NULL

@zz-jason
Copy link
Member

discovered in tikv/tikv#3532

@XuHuaiyu
Copy link
Contributor Author

Sorry for the wrong reproducible steps I mentioned in the description,
which I wanted to report is the same as #7615 .

So I will close this issue, and reopen that one.

@XuHuaiyu
Copy link
Contributor Author

Sorry for the wrong reproducible steps I mentioned in the description,
which I wanted to report is the same as #7615 .

So I will close this issue, and reopen that one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/expression good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. type/compatibility
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants