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

regression issue: sql_mode=STRICT_TRANS_TABLES insert invalid date Successfully #26762

Closed
ChenPeng2013 opened this issue Jul 31, 2021 · 4 comments · Fixed by #26784
Closed

regression issue: sql_mode=STRICT_TRANS_TABLES insert invalid date Successfully #26762

ChenPeng2013 opened this issue Jul 31, 2021 · 4 comments · Fixed by #26784
Assignees
Labels
severity/critical sig/execution SIG execution type/bug The issue is confirmed as a bug.

Comments

@ChenPeng2013
Copy link
Contributor

ChenPeng2013 commented Jul 31, 2021

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

drop table if exists t1, t2, t3;
set @@sql_mode='ALLOW_INVALID_DATES';
create table t1 (a date default '0000-00-00') partition by range (DAY(a)) (
partition p0 values less than (10),
partition p1 values less than (20),
partition p2 values less than (32)
);
create table t2 (a date default '0000-00-00') partition by hash (DAY(a)) partitions 4;
insert into t1 values('0000-00-00'), (NULL), ('2020-01-30'), ('2010-00-01'), ('2010-01-00');
insert into t1 values('2020-02-31');
insert into t2 values('0000-00-00'), (NULL), ('2020-01-30'), ('2010-00-01'), ('2010-01-00');
insert into t2 values('2020-02-31');
set @@sql_mode='STRICT_TRANS_TABLES';
insert into t1 values('2020-02-31');

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

v4.0.10

mysql> set @@sql_mode='STRICT_TRANS_TABLES';
Query OK, 0 rows affected (0.00 sec)

mysql> insert into t1 values('2020-02-31');
ERROR 1366 (HY000): Incorrect date value: '2020-02-31' for column 'a' at row 1

3. What did you see instead (Required)

release-4.0 & release-5.0 & release-5.1 & master

mysql> set @@sql_mode='STRICT_TRANS_TABLES';
Query OK, 0 rows affected (0.00 sec)

mysql> insert into t1 values('2020-02-31');
Query OK, 1 row affected (0.00 sec)

4. What is your TiDB version? (Required)

Release Version: v5.1.1
Edition: Community
Git Commit Hash: 797bddd25310ed42f0791c8eccb78be8cce2f502
Git Branch: release-5.1
UTC Build Time: 2021-07-31 02:01:43
GoVersion: go1.16.5
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
@ChenPeng2013 ChenPeng2013 added type/bug The issue is confirmed as a bug. sig/execution SIG execution severity/critical labels Jul 31, 2021
@guo-shaoge guo-shaoge self-assigned this Aug 2, 2021
@guo-shaoge
Copy link
Collaborator

guo-shaoge commented Aug 2, 2021

2020-02-31 is an invalid date, so the parsed result is a ZeroTime.

In master/5.1/5.0, CastVlue() will return ZeroTime instead of an error because NO_ZERO_DATE is not set.

@ti-srebot
Copy link
Contributor

Please edit this comment or add a new comment to complete the following information

Not a bug

  1. Remove the 'type/bug' label
  2. Add notes to indicate why it is not a bug

Duplicate bug

  1. Add the 'type/duplicate' label
  2. Add the link to the original bug

Bug

Note: Make Sure that 'component', and 'severity' labels are added
Example for how to fill out the template: #20100

1. Root Cause Analysis (RCA) (optional)

2. Symptom (optional)

3. All Trigger Conditions (optional)

4. Workaround (optional)

5. Affected versions

6. Fixed versions

@guo-shaoge
Copy link
Collaborator

/label needs-cherry-pick-4.0

@guo-shaoge
Copy link
Collaborator

/run-cherry-picker

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity/critical 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