Skip to content

[Bug]: SEC_TO_TIME and MAKETIME boundary/fractional behavior differs from MySQL #25304

Closed

Description

@Ariznawlll

Bug Report

MatrixOne Version

Latest origin/main verified locally at 200bfa7e0efb.

Reproduce Steps

set session sql_mode = '';

select sec_to_time(3020399) as max_in_range,
       sec_to_time(3020400) as over_range,
       sec_to_time(-3020400) as under_range,
       sec_to_time(2378.7) as fractional_seconds;

select maketime(12,15,30.9) as fractional_second,
       maketime(840,0,0) as over_hour,
       maketime(12,60,0) as bad_minute,
       maketime(null,1,1) as null_hour;

Expected Behavior

MySQL returns:

max_in_range  over_range  under_range  fractional_seconds
838:59:59     838:59:59   -838:59:59   00:39:38.7

fractional_second  over_hour  bad_minute  null_hour
12:15:30.9         838:59:59  NULL        NULL

Actual Behavior

MatrixOne returns:

max_in_range  over_range  under_range  fractional_seconds
838:59:59     NULL        NULL         00:39:38

fractional_second  over_hour  bad_minute  null_hour
12:15:30           NULL       NULL        NULL

Notes

Found during MySQL compatibility Module 5 exploration for date/time functions. MySQL documents SEC_TO_TIME() and MAKETIME() as time construction/conversion functions, and MAKETIME() allows fractional seconds in the second argument.

Existing main coverage has func_datetime_sec_to_time / func_datetime_maketime, but some boundary comments/expectations are not aligned with MySQL oracle, so this should be fixed as a bug/regression rather than added as a passing BVT row now.

Activity

  1. added
    kind/bug
    severity/s1
    on Jul 1, 2026
  2. added
    severity/s0
    and removed
    severity/s1
    on Jul 2, 2026
  3. added this to the MO-202607 milestone on Jul 2, 2026
  4. added theissue type on Jul 2, 2026
  5. added and removed
    severity/s0
    on Jul 2, 2026
  6. added
    severity/s0
    ai-easy
    and removed
    severity/s0
    on Jul 2, 2026
  7. iamlinjunhong commented on Aug 20, 2026

    @iamlinjunhong
    Contributor

    Additional latest-main evidence from ODBC compatibility testing: direct TIME(6) column insertion accepts a value beyond MySQL's documented maximum even with STRICT_TRANS_TABLES enabled.

    • MatrixOne: 592ad2190a90e063e3877059f4018427a10a4998
    • MatrixOne ODBC source: 8f1ca365289a0f8ea0d22e6581cce1ea4ae67454
    • Direct client confirmation: MySQL 9.7.1 CLI over the MatrixOne MySQL protocol
    • @@sql_mode: ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES
    create table repro_time_range(id int primary key, t time(6));
    insert into repro_time_range values (1,'838:59:59.999999');
    insert into repro_time_range values (2,'839:00:00');
    select id, cast(t as varchar), time_to_sec(t) from repro_time_range order by id;

    Actual:

    1  838:59:59.999999  3020399
    2  839:00:00.000000  3020400
    

    Expected under strict MySQL behavior: the second insert is rejected as out of range (maximum 838:59:59.999999). This complements the SEC_TO_TIME/MAKETIME boundary evidence already in this issue: MatrixOne's constructor functions and TIME column cast path disagree at the same boundary.

    Evidence: server-scenarios-round3.json R304, server-candidate-repros-round3.sql, and direct-mysql-candidate-repros-round3.log.

  8. iamlinjunhong commented on Aug 26, 2026

    @iamlinjunhong
    Contributor

    Retested the direct TIME(6) column boundary on latest main; the existing discrepancy remains reproducible.

    • MatrixOne: 1891117aedce0419a81630b3011906b560b93d0a
    • MatrixOne ODBC candidate: 390f3cc58ebc06d5e830a7839cccbca2962ffcc4
    • Control client: MySQL 8.0.46 CLI directly over the MatrixOne MySQL protocol
    • @@sql_mode includes STRICT_TRANS_TABLES
    create table time_839_repro.t(id int primary key,v time(6));
    insert into time_839_repro.t values (1,'839:00:00');
    show warnings;
    select id,cast(v as varchar),time_to_sec(v) from time_839_repro.t;

    Actual: the insert succeeds without warning and stores 839:00:00.000000 / 3020400 seconds. This is the same column-cast boundary evidence previously attached, now reconfirmed on the newest commit.

    Evidence: artifacts/production-release-20260826/logs/repro-time-839-native-1891117.log.

  9. iamlinjunhong commented on Aug 26, 2026

    @iamlinjunhong
    Contributor

    Retested through MatrixOne ODBC on current main:

    • MatrixOne: a53f5a3b757c5b21a36e539e4471533fe1d091a8
    • MatrixOne ODBC candidate: 390f3cc58ebc06d5e830a7839cccbca2962ffcc4
    • STRICT_TRANS_TABLES enabled

    The server still accepts TIME(6) '839:00:00' without an error or warning, while 838:59:59.999999 succeeds as expected. The no-pooling ODBC boundary round reports 10 PASS / 2 FAIL; this is one of the two failures (the other is MatrixOne's intentional transactional-DDL semantic difference).

  10. Ariznawlll commented on Aug 31, 2026

    @Ariznawlll
    CollaboratorAuthor

    测试通过。

    验证版本:main@09c9a0b。SEC_TO_TIME 正负 clamp、边界 3020399/400/401、fraction/microsecond,以及 MAKETIME fraction/clamp/非法 minute/second/NULL/strict mode 均连续 3 轮得到预期结果。

    已加入 MOTR 回归:https://github.com/matrixorigin/motr/pull/131。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

ai-easykind/bug

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions