Repository navigation
Description
Environment
- MatrixOne:
mainatfc621e3616d229c7a29d0c80e73ed8eb1997459c - MySQL reference: 8.0.46
- Session time zone:
+00:00
Problem
MatrixOne accepts ALLOW_INVALID_DATES in sql_mode, but still rejects calendar-invalid DATE and DATETIME values such as 2024-02-30. The mode does not change direct writes, updates, prepared parameters, or column defaults.
MySQL documents that ALLOW_INVALID_DATES permits month values 1-12 and day values 1-31 without checking the day against the actual number of days in the month. It applies to DATE and DATETIME, not TIMESTAMP.
Minimal reproduction
SET SESSION sql_mode = 'STRICT_TRANS_TABLES,ALLOW_INVALID_DATES';
CREATE TABLE t(
id INT PRIMARY KEY,
d DATE,
dt DATETIME(6)
);
INSERT INTO t VALUES(
1,
'2024-02-30',
'2024-02-30 12:34:56.123456'
);
SELECT id, CAST(d AS CHAR), CAST(dt AS CHAR) FROM t;MatrixOne returns:
ERROR 20203: invalid argument parsedate, bad value 2024-02-30
MySQL 8.0.46 stores and returns:
1 | 2024-02-30 | 2024-02-30 12:34:56.123456
Without ALLOW_INVALID_DATES, both systems reject the same row.
Covered boundaries and paths
The behavior was checked with 2024-02-30, non-leap 2023-02-29, and 2024-04-31.
- Direct
INSERT,UPDATE, and SQLPREPARE ... EXECUTE ... USINGparameters are accepted by MySQL under the mode and rejected by MatrixOne. - MySQL accepts
DATE DEFAULT '2024-02-30'andDATETIME DEFAULT '2024-02-30 12:34:56'under the mode; MatrixOne rejects the table definition. - MySQL can subsequently evaluate
YEAR,MONTH,DAY,DAYOFMONTH,LAST_DAY,DATE_ADD, andDATEDIFFover the stored value. MatrixOne has no equivalent stored-value path because every entry point rejects it. 2024-13-01and2024-01-32are rejected by both systems even with the mode, confirming that the expected range is not arbitrary invalid input.- A row containing an invalid
TIMESTAMPis rejected by both systems, confirming MySQL's documented exclusion ofTIMESTAMPfrom this mode.
Code analysis
pkg/frontend/variables.go lists ALLOW_INVALID_DATES as a valid sql_mode token, but there are no consumers of this token outside that registration. types.ParseDate and types.ParseDatetime always validate the calendar date and do not receive session SQL mode information. DML binding, prepared execution, and default-value validation therefore cannot select the relaxed rule.
The behavior above was reproduced three times with fresh databases and connections. Each relaxed-mode case has a strict-mode control, and the out-of-range month/day plus TIMESTAMP controls prevent widening the expected behavior beyond MySQL's documented scope.
Activity
XuPeng-SH commentedon Sep 10, 2026
Triage routing: assigned to @jiangxinmeng1. Labels normalized to
kind/bug+needs-triage(existing compatibility labels, when present, are retained).Recommended PR decomposition:
#28602only): defineALLOW_INVALID_DATESbehavior for DATE/DATETIME parsing and validation. Keep it separate from DST gap handling (#28570) because invalid calendar dates and nonexistent local times are different contracts.Suggested priority: P2; cover zero dates, invalid month/day values, strict/non-strict modes, and round-trip behavior.
XuPeng-SH commentedon Sep 27, 2026
Decision for #29076 (2026-09-27): defer full
ALLOW_INVALID_DATESsupport from this PR. The mode token remains accepted for connection compatibility, but DATE/DATETIME still reject impossible calendar dates; this issue remains open and must not be marked fixed by #29076.Reason: correct support requires preserving the civil fields through scalar storage, tuple/index ordering, WAL/logtail, backup/restore, and calendar functions. The earlier #29076 draft changed valid persisted tuple keys and had unresolved recovery/upgrade safety gaps; that implementation has now been removed from the PR. The compatibility requirement for a future design is that all previously stored valid DATE/DATETIME values and index keys remain readable without a rewrite after an offline upgrade. Once new invalid-date values have been written, direct downgrade to an old reader need not be supported.
Revisit when there is a concrete workload that must store such dates, with an approved storage/restore design and old-data upgrade plus index/SQL regression evidence. Existing applications that merely set the MySQL mode are not forced to change their initialization now.
fengttt commentedon Sep 29, 2026
What are we doing? Why we would accept this flag and put in bad values? What is the point of introduce bugs to the database?
fix(frontend): retain DATETIME fractional width in text rows (#29076)