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 int as time may produce wront result #1764

Closed
leiysky opened this issue Apr 13, 2021 · 1 comment · Fixed by #1788
Closed

Cast int as time may produce wront result #1764

leiysky opened this issue Apr 13, 2021 · 1 comment · Fixed by #1788
Assignees
Labels

Comments

@leiysky
Copy link
Contributor

leiysky commented Apr 13, 2021

Minimal reproduce:

create table t (a int);
insert into t values(65535);
alter table t set tiflash replica 1;
set session tidb_isolation_read_engines='tiflash';
select * from t where cast(a as datetime);
# expect empty but get 65535
@leiysky leiysky added the type/bug The issue is confirmed as a bug. label Apr 13, 2021
@leiysky
Copy link
Contributor Author

leiysky commented Apr 18, 2021

The root cause of this bug is that TiFlash doesn't validate the result of cast integer as datetime as strict as TiDB.

This inconsistent behavior only occurs when the original integer value has valid format but doesn't represent a valid datetime value. For example a integer 20210499 can be casted to datetime '2021-04-99', in TiDB it will return NULL while in TiFlash it will return '2021-04-99'.

We can change the severity to major since this is a corner case.

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

Successfully merging a pull request may close this issue.

4 participants