pingcap/tidb

invalid year value cast incorrect

Open

#25,993 opened on Jul 6, 2021

View on GitHub
 (1 comment) (0 reactions) (1 assignee)Go (6,186 forks)batch import
help wantedseverity/moderatesig/executiontype/bug

Repository metrics

Stars
 (40,090 stars)
PR merge metrics
 (Avg merge 14d 4h) (346 merged PRs in 30d)

Description

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

set sql_mode = '';
CREATE TABLE t1 (a int, y YEAR);
insert ignore t1 values (1, 1900), (2, 2156), (3, '1900'), (4, '2156');

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

As described in doc

Invalid YEAR value is automatically converted to 0000

mysql> select * from t1;
+------+------+
| a    | y    |
+------+------+
|    1 | 0000 |
|    2 | 0000 |
|    3 | 0000 |
|    4 | 0000 |
+------+------+

3. What did you see instead (Required)

mysql> select * from t1;
+------+------+
| a    | y    |
+------+------+
|    1 | 1901 |
|    2 | 2155 |
|    3 | 1901 |
|    4 | 2155 |
+------+------+

4. What is your TiDB version? (Required)

 Release Version: v5.2.0-alpha-206-gcb06e116c
Edition: Community
Git Commit Hash: cb06e116c1bfb1089c2e1df5072e889a3b7decd3
Git Branch: master
UTC Build Time: 2021-07-05 10:33:48
GoVersion: go1.16.2
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false |

Contributor guide