Repository navigation
Description
Description
FROM_UNIXTIME(?) keeps fractional-seconds precision 6 for a prepared integer epoch parameter. MySQL 8.0.46 returns precision 0 for the same integer parameter. The epoch value is correct on both engines; the difference is the prepared result/CTAS column type and its metadata.
Environment
- MatrixOne main ancestor commit:
2ce4e58af6f03b943ee288ffad81012766cf830a(local two-CN cluster behind Proxy) - Current
origin/mainat investigation:944b721d1b3705cdb51d1e26f1a04611a08c8401; the relevantFROM_UNIXTIMEreturn-type and prepared-plan source files are unchanged from the tested commit - MySQL: 8.0.46
- Session time zone:
+00:00 - Date: 2026-10-14
Steps to reproduce
CREATE DATABASE probe_db;
USE probe_db;
SET SESSION time_zone = '+00:00';
SET @epoch = 1704067200;
PREPARE p FROM
'CREATE TABLE ctas_int AS SELECT FROM_UNIXTIME(?) AS ts';
EXECUTE p USING @epoch;
SELECT COLUMN_TYPE, DATETIME_PRECISION
FROM information_schema.columns
WHERE table_schema = 'probe_db'
AND table_name = 'ctas_int'
AND column_name = 'ts';Actual behavior
MatrixOne reports datetime(6), precision 6; the same prepared CTAS reports datetime, precision 0 on MySQL. A prepared SELECT FROM_UNIXTIME(?) also prints .000000 in MatrixOne for the integer parameter, while MySQL prints no fractional part.
The prepared CTAS schema mismatch reproduced in 3/3 fresh tables on each engine.
Expected behavior
For an integer epoch input, the result type should have fractional-seconds precision 0, as in MySQL 8.0.46.
Stability and controls
- Prepared integer epoch: MatrixOne
DATETIME(6)vs MySQLDATETIME, 3/3. - Literal
FROM_UNIXTIME(1704067200)CTAS: both reportDATETIME, precision 0. - User-variable
FROM_UNIXTIME(@epoch)CTAS with@epoch = 1704067200: both reportDATETIME, precision 0. - Prepared decimal parameter
1704067200.123456: both reportDATETIME(6), precision 6, and retain.123456. - The materialized epoch value is otherwise correct; this is a precision/type metadata mismatch, not loss of the integer timestamp value.
Code analysis
The result type is selected by fromUnixTimeReturnType in pkg/sql/plan/function/list_builtIn.go from the statically resolved argument type. A prepared marker is resolved with fractional precision 6, so the return type remains DATETIME(6) when execution binds an integer. The prepared-plan coverage in pkg/sql/plan/prepared_interval_test.go also preserves the marker under FROM_UNIXTIME(?); execution does not narrow the return precision to the bound integer type.
Regression coverage
After a fix, cover prepared integer and decimal epoch parameters through both SELECT metadata and CTAS information_schema.columns, with literal and user-variable controls.
Related
- [Bug]: CTAS truncates fractional seconds from FROM_UNIXTIME #28124 fixed fractional seconds being truncated by CTAS for
FROM_UNIXTIME; this report covers the opposite prepared-integer precision mismatch and does not reopen that closed issue.
Activity
slyunnn commentedon Oct 21, 2026
Verification update (2026-10-21)
Verified on latest
origin/maine47f45ca6548e198e73ecb242521047bfd449850(fix(python-sdk): redact create_table diagnostics and gate the success log (#30678)). The fresh runtime topology was2 CN / 1 TN / 1 LogService / Proxy; Proxy6001, CN116001, and CN216002each accepted MySQL connections. Session time zone was+00:00.PREPARE/EXECUTECTAS reproduction returnedDATETIME, precision0for the integer parameter through Proxy, CN1, and CN2 (three fresh tables per direct CN). Decimal1704067200.123456returnedDATETIME(6), precision6; literal and user-variable controls returnedDATETIME, precision0.COM_STMT_PREPARE/EXECUTE: MatrixOne returned precision0for the integer parameter and6for the decimal parameter.8.0.46, the exact SQLPREPARE/EXECUTEinteger CTAS returnedDATETIME(6), precision6in3/3fresh tables; binaryCOM_STMTalso returnedDATETIME(6). Literal and user-variable controls returned precision0.The current MatrixOne result matches the expected behavior explicitly stated in this issue (integer prepared input should produce precision
0), so the reported MatrixOne mismatch is not reproducible on latestmain. Related PR #30224, merged asd82e828b0a4df9ce635fe573c1e90c5cde978bf9, states that theFROM_UNIXTIMEreproduction already passed on its base and made noFROM_UNIXTIMEkernel change.@Ariznawlll, could you please confirm whether the MySQL
8.0.46result in the issue was obtained with the exact SQLPREPARE/EXECUTEsteps above? My local run of those steps returned precision6, opposite to the issue report's precision0. If possible, please share the exact command/output (and any relevant client/session details) so we can reconcile the MySQL baseline. This is a request to verify the reported comparison, not to clarify the expected behavior, which is already explicit in the issue.The related existing BVT is
test/distributed/cases/function/func_temporal_consistency_28851.test; the full BVT harness was not rerun. No large-data regression is relevant to this result-type metadata case.slyunnn commentedon Oct 21, 2026
Compatibility baseline correction and engineering follow-up (2026-10-21)
The issue creator has confirmed that the MySQL
8.0.46result for the exact SQLPREPARE/EXECUTEinteger-parameter case matches the independent verification: CTAS metadata isDATETIME(6), precision6. The original issue's MySQL expectation of precision0appears to have used the ordinary integer-literal/user-variable result as the prepared-statement baseline; those are different cases.On latest MatrixOne
origin/maine47f45ca6548e198e73ecb242521047bfd449850, the same SQLPREPARE/EXECUTECTAS returnedDATETIME, precision0through Proxy, CN1, and CN2. Thus the original reported direction (MatrixOne 6vsMySQL 0) is not accurate, but the corrected comparison currently points to the opposite result (MatrixOne 0vsMySQL 6).Reopening this issue for engineering review of the intended prepared-result compatibility contract and whether the latest MatrixOne precision-
0result is intentional. Related merged PR #30224 (d82e828b0a4df9ce635fe573c1e90c5cde978bf9) includes this issue and says the originalFROM_UNIXTIMEreproduction already passed on its base without a kernel change.The issue is assigned to
iamlinjunhong, author of PR #30224, for review. No new issue is being created pending this assessment.XuPeng-SH commentedon Nov 1, 2026
转 QA 验证。修复 #31141 已合入 main,merge SHA:
950ef51d97422022e84386cfb85006288b791e62。本轮核对了合并状态、修复范围及本 issue 全部评论:按已纠正的 MySQL 8.0.46 基线,直接 prepared FROM_UNIXTIME 参数应暴露 DATETIME(6),包括整数和 decimal3;普通字面量、用户变量和显式 CAST 保持各自精度契约。旧 main 精度 0 的反例由本次新修复覆盖,未见适用于合并后版本的已验证反例或尚未完成的开发 follow-up。
证据及限制:PR 作者报告在 ef81e86 上 plan/function 全量及 focused frontend/parser 测试通过,真实服务 prepared_temporal_results.sql 208/208 和 interval_operator_string_operand.sql 31/31 均通过两次;PR 合并队列记录 CI Required 成功。以上为远端记录/作者报告,本轮未运行本地测试,也未独立重建原始测试证据;不表示本轮验收通过。作者明确未新增 MySQL differential、race 或 multi-CN 验证。
请 QA 在包含上述 merge SHA 的版本上,按纠正后的基线对比 SQL PREPARE/EXECUTE 与 binary COM_STMT 的 SELECT 元数据、CTAS information_schema 和实际值:整数、decimal3/6、NULL、负值及普通/显式 CAST 控制;关注重复执行时参数切换、CTAS 写入精度与 SELECT 句柄历史隔离。按原报告匹配时区及 sql_mode,补充 Proxy/直连 CN 路径。issue 保持 open,待报告者复核。
Ariznawlll commentedon Nov 3, 2026
结论
测试通过。按 issue 后续修正的比较基线,prepared 整数参数的 FROM_UNIXTIME 结果元数据为 DATETIME(6)。
关键证据
main@d61a7206c16b30baa4efc525eb6067c4364035aa;隔离 MO、MySQL 8.0.45,UTC。datetime(6)、精度 6 和正确值,两端三轮一致。二进制 COM_STMT 对整数及同一预编译句柄重用的类型、精度和结果在两 CN 各三轮通过。待解决点
MOTR PR 尚待评审合入;原 issue 的 MySQL 预期已由后续评论纠正,本轮对照为 8.0.45 而非原记录的 8.0.46。