Repository navigation
Description
Is there an existing issue for the same bug?
- I have checked the existing issues, including open and closed issues.
Branch Name
main
Commit ID
Other Environment Information
- MatrixOne: locally built from the commit above (
8.0.30-MatrixOne-v1.3.0) - MySQL baseline: 8.0.46
- Verification date: 2026-09-10
Actual Behavior
MatrixOne exposes explicit_defaults_for_timestamp as a writable dynamic session/global variable, but setting it to OFF has no effect on TIMESTAMP column definition or write behavior.
With the setting ON, MatrixOne and MySQL both create an unconstrained TIMESTAMP column as nullable with a NULL default:
SET SESSION explicit_defaults_for_timestamp=ON;
CREATE TABLE t(id INT PRIMARY KEY, ts TIMESTAMP);ts TIMESTAMP NULL DEFAULT NULL
With the setting OFF, MySQL 8.0.46 applies its documented legacy implicit-first-TIMESTAMP behavior:
ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
MatrixOne still creates:
ts TIMESTAMP NULL DEFAULT NULL
The schema difference changes stored values:
- Omitting
tsinserts the current timestamp in MySQL but NULL in MatrixOne. - Explicitly inserting NULL into the implicit first TIMESTAMP stores the current timestamp in MySQL but NULL in MatrixOne.
TIMESTAMP NOT NULLwith no explicit default gainsDEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMPunder MySQLOFF, so an omitted value succeeds; MatrixOne keeps no default and rejects the same insert withinvalid default value for column 'ts'.- An explicitly nullable
TIMESTAMP NULLremains nullable in both engines, which is the expected control.
SELECT @@session.explicit_defaults_for_timestamp correctly reports 0 after the MatrixOne assignment, so the variable is stored but ignored by DDL binding.
Expected Behavior
When MatrixOne accepts explicit_defaults_for_timestamp=OFF, TIMESTAMP DDL and implicit write behavior should follow MySQL's corresponding compatibility rules. If the legacy mode is intentionally unsupported, the setting should not be exposed as a writable dynamic variable that silently has no effect.
Steps to Reproduce
DROP DATABASE IF EXISTS explicit_timestamp_defaults;
CREATE DATABASE explicit_timestamp_defaults;
USE explicit_timestamp_defaults;
SET SESSION explicit_defaults_for_timestamp=OFF;
SELECT @@session.explicit_defaults_for_timestamp;
CREATE TABLE plain_t(
id INT PRIMARY KEY,
ts TIMESTAMP
);
SHOW CREATE TABLE plain_t;
INSERT INTO plain_t(id) VALUES(1);
INSERT INTO plain_t VALUES(2,NULL);
SELECT id,ts,ts IS NULL FROM plain_t ORDER BY id;
CREATE TABLE nullable_t(
id INT PRIMARY KEY,
ts TIMESTAMP NULL
);
SHOW CREATE TABLE nullable_t;
CREATE TABLE notnull_t(
id INT PRIMARY KEY,
ts TIMESTAMP NOT NULL
);
SHOW CREATE TABLE notnull_t;
INSERT INTO notnull_t(id) VALUES(1);Additional information
pkg/frontend/variables.go registers explicit_defaults_for_timestamp as a dynamic ScopeBoth Boolean with default 1. No production parser, binder, default-expression, or timestamp-column path reads the setting; the only other source occurrence is an error-message definition describing the MySQL option.
ON/OFF, unconstrained/explicit NULL/explicit NOT NULL column definitions, SHOW CREATE, omitted values, explicit NULL values, and post-create updates were reproduced three times on the same latest-main build and compared with MySQL 8.0.46. No existing issue for this variable was found.
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:
#28598 + #28599): alignexplicit_defaults_for_timestamp, automatic TIMESTAMP columns, and session timestamp override. They share TIMESTAMP default-value generation and need DDL plus INSERT/UPDATE coverage.#28570separate because DST gap mapping is a time-zone conversion contract, not default generation.Suggested priority: P2; confirm exact MySQL mode/version compatibility before changing DDL behavior.
jiangxinmeng1 commentedon Oct 22, 2026
已在
main提交c232b6d2a1b5a94ac624c4954586569841c1e153复核。合并的 #28932 已让explicit_defaults_for_timestamp=OFF参与 TIMESTAMP DDL、默认值及显式 NULL 写入处理;相关远程回归测试TestTableDumpTimestampDefaults、TestLegacyTimestampRuntimeNullAssignment通过。请 @Ariznawlll 按本 issue 的 SQL 步骤复核,若仍有差异请补充具体结果。
Ariznawlll commentedon Oct 22, 2026
测试版本
cca94b810ce87a38d1af16d7b418ea727eeda81c(包含已合入修复 fix remaining date/time compatibility issues #28932 的 merge commit)原问题验证
explicit_defaults_for_timestamp=OFF后首个隐式 TIMESTAMP 的 SHOW CREATE 为NOT NULL DEFAULT CURRENT_TIMESTAMP() ON UPDATE CURRENT_TIMESTAMP();省略值和显式 NULL 插入后 2 行均非 NULL。 独立启动环境重复 3/3 轮通过,未用开发者自测代替 QA。Happy Path 覆盖
TIMESTAMP NULL可保留 NULL,显式 NOT NULL 省略值成功;更新普通列并等待 1 秒后ts>旧值为 1;恢复 ON 时普通 TIMESTAMP 为可空。Unhappy Path 覆盖
白盒验证
本轮未单独跑 Go UT / race;本问题为确定性 SQL 值或类型路径,以真实协议黑盒及 SQL 回归验收。完整 MatrixOne suite 未执行。
回归测试
--repeat 3通过。PR 当前仍 Open,尚未声称已合并或 CI 全绿。测试证据
上述 PR 的成对 t/r、实际 main SHA,以及本地
go test ./pkg/tests/issues -run '^TestQATemporalScreenshot20261022$' -count=3与 MOTR 定向--repeat 3均通过;黑盒临时测试仅用于本次独立验收,未作为持久产品代码提交。测试结论
测试通过。