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

different behavior with mysql when cast json string to unsigned #47864

Closed
lcwangchao opened this issue Oct 20, 2023 · 0 comments · Fixed by #48010
Closed

different behavior with mysql when cast json string to unsigned #47864

lcwangchao opened this issue Oct 20, 2023 · 0 comments · Fixed by #48010

Comments

@lcwangchao
Copy link
Collaborator

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

> create table tj(a json);
> insert into tj values('"-1"');
> select cast(a as unsigned) from tj

2. What did you expect to see? (Required)

In MySQL 8.0:

mysql> select cast(a as unsigned) from tj;
+----------------------+
| cast(a as unsigned)  |
+----------------------+
| 18446744073709551615 |
+----------------------+
1 row in set (0.01 sec)

3. What did you see instead (Required)

In tidb:

mysql> select cast(a as unsigned) from tj;
+---------------------+
| cast(a as unsigned) |
+---------------------+
|                   0 |
+---------------------+
1 row in set, 1 warning (0.01 sec)

mysql> show warnings;
+---------+------+-----------------------------------------------+
| Level   | Code | Message                                       |
+---------+------+-----------------------------------------------+
| Warning | 1690 | BIGINT UNSIGNED value is out of range in '-1' |
+---------+------+-----------------------------------------------+
1 row in set (0.00 sec)

tidb returns 0 and an extra warning.

4. What is your TiDB version? (Required)

master, but I think it affects all versions with json

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

Successfully merging a pull request may close this issue.

2 participants