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

Cast function should not fail. #645

Closed
coocood opened this issue Nov 26, 2015 · 1 comment · Fixed by #3894
Closed

Cast function should not fail. #645

coocood opened this issue Nov 26, 2015 · 1 comment · Fixed by #3894
Labels
type/bug The issue is confirmed as a bug.

Comments

@coocood
Copy link
Member

coocood commented Nov 26, 2015

select cast("-1" as UNSIGNED) should return 18446744073709551615, but we get "constant -1 overflows bigint" error.

This is because we use Convert function for cast, but actually cast works differently than convert.
cast("xxx" as DATETIME) should returns NULL, but Convert such an invalid time string returns zero time.

@coocood coocood added the type/bug The issue is confirmed as a bug. label Nov 26, 2015
@qiuyesuifeng
Copy link
Member

select cast("-1" as UNSIGNED) there will get an warning.

mysql> select cast("-1" as UNSIGNED);
+------------------------+
| cast("-1" as UNSIGNED) |
+------------------------+
|   18446744073709551615 |
+------------------------+
1 row in set, 1 warning (0.00 sec)

mysql> show warnings;
+---------+------+-------------------------------------------------------------------------+
| Level   | Code | Message                                                                 |
+---------+------+-------------------------------------------------------------------------+
| Warning | 1105 | Cast to unsigned converted negative integer to it's positive complement |
+---------+------+-------------------------------------------------------------------------+
1 row in set (0.00 sec)

I think we should use error for type cast, like 18446744073709551615 is meaningless and it is difficult to do the same with MySQL.

YuJuncen pushed a commit to YuJuncen/tidb that referenced this issue Apr 23, 2021
* refactor ingester

* adapt ingester

* fmt & add some comments

* fix hound

* fix hound

* fix

* fix ci

* fix test

* fix test

* fix ci

* fix lint

* fix lint

* fix index panic

* sleep more time to wait ticdc synced

* address comment

* address comment

* fix test

* fix resolve lock

* fix hound

* fix nextkey

* fix hound

* fix lint

* fix ci

* refactor log

* fix deadlock

* change concurrency config

* fix hound

* fix remain range

* fix hound

* fix sort bug

* fix infinte loop

* fix test: resolve ts is 0

* update ingester coverage

* add seek for iterator & add some unit test

* address comment

* remove concurrency iter

* fix

* fix lost

* change range to [start, end)

* add iter producer

* fix build

* remove iter's lock

* fix build

* Update pkg/kv/kv.go

Co-authored-by: glorv <glorvs@163.com>

* address comment

* Update pkg/kv/kv.go

Co-authored-by: glorv <glorvs@163.com>

* address comment

* Update pkg/kv/kv.go

Co-authored-by: kennytm <kennytm@gmail.com>

* Update pkg/restore/split_client.go

Co-authored-by: kennytm <kennytm@gmail.com>

* adapt logutil

* address comment

* fix iter.Next()

* fix build

Co-authored-by: glorv <glorvs@163.com>
Co-authored-by: kennytm <kennytm@gmail.com>
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