Repository navigation
Closed
Copy link
Description
Problem
MatrixOne loses fractional-second precision when temporal values pass through common conditional expressions. The selected value is changed even when every temporal branch has an explicit fractional precision.
The affected paths include COALESCE, IFNULL, IF, searched/simple CASE, prepared parameters, views, and CTAS.
Reproduction
drop database if exists conditional_temporal_precision;
create database conditional_temporal_precision;
use conditional_temporal_precision;
create table src(
id int primary key,
d date,
dt6 datetime(6),
ts6 timestamp(6) null,
tm6 time(6)
);
insert into src values
(1, '2024-02-29', '2024-02-29 12:34:56.123456',
'2024-02-29 12:34:56.123456', '12:34:56.123456'),
(2, null, '2024-03-01 01:02:03.999999',
null, '23:59:59.999999');
create view v as
select id,
coalesce(tm6, cast('00:00:00.000001' as time(6))) as c_tm6,
ifnull(dt6, d) as i_dtd,
if(id = 1, ts6, dt6) as f_tsdt,
case when id = 1 then ts6 else dt6 end as k_tsdt,
case id when 1 then ts6 else dt6 end as simple_tsdt
from src;
select * from v order by id;
select column_name, column_type, datetime_precision
from information_schema.columns
where table_schema = database() and table_name = 'v'
order by ordinal_position;
create table ctas as select * from v;
select * from ctas order by id;Prepared execution is also affected:
prepare p from
'select coalesce(?,cast(''00:00:00.000001'' as time(6))),
ifnull(?,cast(''2000-01-01 00:00:00.000001'' as datetime(6))),
if(1,?,cast(''2000-01-01 00:00:00.000001'' as datetime(6))),
case when 1 then ? else cast(''2000-01-01 00:00:00.000001'' as datetime(6)) end';
set @tm = cast('12:34:56.123456' as time(6));
set @dt = cast('2024-02-29 12:34:56.123456' as datetime(6));
execute p using @tm, @dt, @dt, @dt;MatrixOne result
COALESCE(TIME(6), TIME(6))is exposed asTIME(0)and returns12:34:56.- For input
23:59:59.999999, the view returns23:59:59; CTAS materialization changes that value again to24:00:00. IFNULL(DATETIME(6), DATE),IF(TIMESTAMP(6), DATETIME(6)), and bothCASEforms are exposed asDATETIME(0).2024-03-01 01:02:03.999999becomes2024-03-01 01:02:04in those expressions.- Prepared parameters lose the same six fractional digits.
MySQL 8.0.45 result
The corresponding expressions are TIME(6) or DATETIME(6) and preserve the original values, including .123456 and .999999, in direct selection, views, CTAS, and prepared execution.
Additional metadata inconsistency
COALESCE(TIMESTAMP(6), TIMESTAMP(3)) preserves the value and reports datetime_precision=6 in MatrixOne, but column_type is rendered as TIMESTAMP(0) rather than TIMESTAMP(6).
Scope checked
TIME(6)withTIME(3)and constantTIME(6)fallbacks;DATE,DATETIME(3/6), andTIMESTAMP(3/6)combinations;COALESCE,IFNULL,IF, searchedCASE, and simpleCASE;- direct selection, view, CTAS, and prepared statements;
- ordinary fractions and carry boundary
.999999; - three independent runs with byte-identical output on each database.
Environment
- MatrixOne: official
maincommit0c3a04f390adaf6281fd592a49778ea5b1155e67 - MySQL control: 8.0.45
- Local single-node MatrixOne deployment
Activity
Ariznawlll commentedon Sep 15, 2026
补充
NULLIF路径(officialmain0c3a04f390adaf6281fd592a49778ea5b1155e67,MySQL 8.0.45 对照):MatrixOne 将返回类型降为
DATETIME(0)/TIME(0),选中的第一个参数丢失 6 位小数;.999999还会在 View/CTAS 路径触发秒进位。MySQL 保留第一个参数的微秒值。直接查询、View 和 CTAS 均已覆盖,3 次独立执行结果一致。因此受影响条件函数还包括
NULLIF,不仅是原报告中的COALESCE、IFNULL、IF和CASE。fix: preserve expression result metadata and coercion contracts (#28941)
Ariznawlll commentedon Sep 17, 2026
当前 main 复测未通过,转回 @XuPeng-SH 继续处理。
验证环境:本地单机 MatrixOne,由远端 main
0370bb4d6b118da29e164c54aa34ee010ed897bc全新构建;PR #28941 merge commitf6f8c0c885f999cbde3b0d394194b0a4a74176ae已包含。独立执行 3/3,结果一致。复现覆盖
COALESCE、IFNULL、IF、searched/simpleCASE、View、CTAS 和 prepared 参数。TIME(6)仍公开为TIME(0);混合时间条件表达式仍公开为DATETIME(0)。.123456被截断,2024-03-01 01:02:03.999999被舍入为2024-03-01 01:02:04,而 CTAS 中23:59:59.999999进一步变为24:00:00。prepared 执行同样丢失六位小数。期望是在 direct/View/CTAS/prepared 路径保留六位精度及原始值。当前验收未通过,issue 保持 Open。
fix: preserve expression result metadata and coercion contracts (matr…
fix: preserve expression result metadata and coercion contracts (matr…
fix: close expression result contract regressions (#29075)
fix(plan): narrow constant character slices across metadata consumers (…
slyunnn commentedon Sep 23, 2026
Regression and extended verification for #28896 (2026-09-23)
Verification Environment
origin/mainat66da3877e9e77f01083c4aac0cb9f94ab6e11fe6,feat(sql): support EXCEPT ALL multiset subtraction (#29228).Proxy,CN1,CN2,TN, andLog servicecontainers all used the same locally built imagesha256:2f11e09a1d306d186281dd444b465d69ed9ebc674a548c6fabac2c85c714f104, built from that exact clean source worktree.1 Log service / 1 TN / 2 CN / 1 Proxy. Connectivity and real DDL/DML execution succeeded through Proxy6001, CN116001, and CN216002.PREPARE/EXECUTE. The binary extension used Godatabase/sqlwithgo-sql-driver/mysql,interpolateParams=false, and actualCOM_STMT_PREPARE/COM_STMT_EXECUTE.f6f8c0c885f999cbde3b0d394194b0a4a74176ae) did not fully close the temporal path; the issue's follow-up verification recorded the remaining failure. The effective follow-up is PR #29075, merge commitaeee7db5099b4347a5c2e5f8d3e4785d76884100,fix: close expression result contract regressions, includingacaed0abd4c49ad38339f21437d7df5e3e8839d0,fix: isolate temporal prepared parameter domains,f6bf1ba3c25570787b6632b09c0aaa20a3263f61,fix(frontend): scope temporal execute domains by consumer, andd987cf6354b56aa1eab0e6c016eaf2860f81eb69,fix: fence mixed temporal conditional plans.What Was Covered
COALESCE,IFNULL,IF, searchedCASE, and simpleCASEreproduction passed on Proxy6001, CN116001, and CN216002.TIME(6)andDATETIME(6)values retained.123456and.999999rather than truncating or rounding.CTASvalues andinformation_schema.columnsmetadata retainedTIME(6)/DATETIME(6)for the affected conditional expressions on all three endpoints;23:59:59.999999did not become24:00:00.COALESCEpreserved aTIME(6)fallback of00:00:00.000001;IFNULL(DATETIME(6), DATE)retainedDATETIME(6)and rendered a date fallback as00:00:00.000000.PREPARE/EXECUTEparameters retained six fractional digits forCOALESCE,IFNULL,IF, andCASEon all three endpoints.database/sql+go-sql-driver/mysqlwithinterpolateParams=false; realCOM_STMT_PREPARE/COM_STMT_EXECUTEretainedTIME(6)andDATETIME(6)fractions on all three endpoints.NULLIFretained the first argument'sTIME(6)/DATETIME(6)precision, including.999999; the nearestTIME(0)-first-argument control correctly remainedTIME(0).COALESCE(TIMESTAMP(6), TIMESTAMP(3))returned the six-digit selected value and exposedTIMESTAMP(6)withdatetime_precision = 6in both View andCTASmetadata on all three endpoints.test/distributed/cases/function/func_expression_result_contracts.testwas replayed twice through mo-tester via Proxy6001; each run passed68/68statements with0failed, ignored, or abnormal results.8.0.45differential run was not repeated locally. The MatrixOne assertions use the exact expected values and metadata stated in the issue.maincontaining the incomplete PR#28941.Findings
The reported loss of fractional-second precision is no longer reproducible on current
main. Conditional temporal expressions preserve both their runtime value and result-domain metadata through direct selection, View,CTAS, SQL prepared execution, and binary prepared execution.The three endpoint protocol cases ran in parallel with separate databases (
issue28896_ts_proxy,issue28896_ts_cn1, andissue28896_ts_cn2), so they had no shared catalog objects. The two mo-tester replays were intentionally serial because they use one self-cleaning BVT fixture and result comparison on the same instance.Large-data regression is not needed. This is a scalar planner/frontend type-and-scale propagation defect that is fully observable with one-row expressions plus the small
3-row NULL/fallback fixture. It does not depend on row-count thresholds, block/batch boundaries, memory, spill, concurrency, skew, network transfer, or resource scale.MOTR / BVT Coverage
No MOTR branch, commit, or new test was needed. Current
mainalready contains the dedicated expression-contract BVT from PR#29075, including conditional temporal View/CTASmetadata and values, plusNULLIFprecision controls. It was replayed twice successfully; no test source was modified during this verification.Final Conclusion
Fixed. The original conditional temporal precision failure and the covered SQL/binary prepared, View,CTAS,NULLIF, NULL-fallback, and mixed-TIMESTAMP metadata variants pass on Proxy6001, CN116001, and CN216002using the currentmainruntime. Large-data regression is not required for the reasons above.Ariznawlll commentedon Sep 23, 2026
最新 main 验证通过,关闭。
验证版本:
16d8e5106caaedfe0a7296e4f628683e1b6a92b4,包含 PR #29075。覆盖:
COALESCE、IFNULL、CASE、NULLIF的TIME(6)/DATETIME(6)值与列元数据在 View、CTAS 和 SQLPREPARE/EXECUTE路径保留六位小数;.999999边界保持原值,不发生截断、四舍五入或变为24:00:00;现有产品 BVT
func_expression_result_contracts.test继续覆盖更完整的条件表达式结果契约。