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 year as datetime should return null #23869

Open
ichn-hu opened this issue Apr 6, 2021 · 4 comments
Open

Cast year as datetime should return null #23869

ichn-hu opened this issue Apr 6, 2021 · 4 comments
Assignees
Labels
severity/moderate sig/execution SIG execution type/bug The issue is confirmed as a bug.

Comments

@ichn-hu
Copy link
Contributor

ichn-hu commented Apr 6, 2021

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

drop table if exists t;
create table t (a year);
insert into t values (2021);
select cast(a as datetime) from t;

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

MySQL [test]> select cast(a as datetime) from t;
+---------------------+
| cast(a as datetime) |
+---------------------+
| NULL                |
+---------------------+
1 row in set, 1 warning (0.000 sec)
MySQL [test]> show warnings;
+---------+------+----------------------------------+
| Level   | Code | Message                          |
+---------+------+----------------------------------+
| Warning | 1292 | Incorrect datetime value: '2021' |
+---------+------+----------------------------------+
1 row in set (0.000 sec)

3. What did you see instead (Required)

MySQL [test]> select cast(a as datetime) from t;
+---------------------+
| cast(a as datetime) |
+---------------------+
| 2021-00-00 00:00:00 |
+---------------------+
1 row in set (0.001 sec)

4. What is your TiDB version? (Required)

master

this bug is caused by #20233 , TiDB acts correctly before this PR, namely in e9b11b7

@ichn-hu ichn-hu added the type/bug The issue is confirmed as a bug. label Apr 6, 2021
@Howie59
Copy link
Contributor

Howie59 commented Apr 6, 2021

/assign

@ichn-hu
Copy link
Contributor Author

ichn-hu commented Apr 8, 2021

@Howie59 Thanks for your interest, but I've already proposed a PR, feel free to look at other issues on #20804

@ichn-hu
Copy link
Contributor Author

ichn-hu commented Apr 8, 2021

/unassign @Howie59

@ichn-hu
Copy link
Contributor Author

ichn-hu commented Apr 8, 2021

/assign @ichn-hu

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

Successfully merging a pull request may close this issue.

4 participants