Skip to content

[Compatibility]: OCT misparses numeric strings and makes TIME results depend on the current year #28465

Closed

Description

@Ariznawlll

MatrixOne version

Latest main at a9d3b8b857c44f1249e682c91d4d62a914eb7d20. MySQL control: 8.3.0.

What is wrong

OCT() applies date-first parsing and strict whole-string integer parsing to string arguments. This changes valid numeric strings, rejects MySQL-compatible numeric prefixes, and makes a TIME value depend on the current calendar year.

Representative results:

expression                 MatrixOne                         MySQL 8.3
OCT('12tail')              error 20203                       14
OCT('12.5')                error 20203                       14
OCT('abc')                 error 20203                       0
OCT('')                    error 20203                       NULL
OCT('20240506')            3750                              115154172
OCT('20240101123456')      3750                              446420402322600
OCT(TIME '12:34:56')       3752 (octal for year 2026)        14

The compact numeric strings are interpreted as dates by MatrixOne and reduced to their year (2024, whose octal representation is 3750). MySQL instead applies numeric conversion to string arguments. For a typed TIME, MatrixOne currently returns the octal representation of the current year, so the result is also time-dependent.

Reproduction

SELECT OCT('12tail'), OCT('12.5'), OCT('abc'), OCT('');
SELECT OCT('20240506'), OCT('20240101123456');

CREATE TABLE t(s VARCHAR(32), tm TIME);
INSERT INTO t VALUES ('12tail', '12:34:56');
SELECT OCT(s), OCT(tm) FROM t;

PREPARE p FROM 'SELECT OCT(?)';
SET @v = '20240506';
EXECUTE p USING @v;

The scalar, column, and prepared-statement forms were reproduced in three independent databases per engine. A mixed VARCHAR scan in MatrixOne aborts at the first non-strict value, while MySQL produces a result for each row.

Controls

  • Integer, DECIMAL, and DOUBLE columns produce the same octal values in both engines for ordinary inputs.
  • Typed DATE and DATETIME values currently produce the same year-based values in both engines.
  • A pure integer string such as '12' returns 14 in both engines.
  • The connection remains usable after MatrixOne returns error 20203.

Root cause

OctString attempts ParseDatetime and ParseDateCast before numeric conversion, and the fallback uses strict strconv.ParseInt on the entire string. The same string executor is selected for TIME, allowing 12:34:56 to be parsed as a datetime with the current year.

Expected behavior

String and TIME arguments should follow MySQL-compatible numeric conversion semantics. Numeric prefixes should be converted without aborting the query, compact numeric strings should remain numeric, empty/invalid inputs should follow MySQL's NULL/zero behavior, and the result must not depend on the current year.

Activity

  1. added this to the MO-202609 milestone on Sep 9, 2026
  2. added theissue type on Sep 9, 2026
  3. Ariznawlll commented on Sep 9, 2026

    @Ariznawlll
    CollaboratorAuthor

    在同步后的最新 main(f0c31cd4b830be32442cf329e0a3fb08aa9c16c3)重新执行原矩阵,问题仍存在且连续 3 轮结果一致:字符串数值前缀仍报 20203,紧凑日期形数字仍被截取为年份,TIME '12:34:56' 仍返回当前年份 2026 的八进制值 3752。整数、DECIMAL、DOUBLE、DATE、DATETIME 控制未变化。

  4. self-assigned this
    on Sep 9, 2026
  5. added a commit that references this issue on Sep 10, 2026
    44b7f90
  6. Ariznawlll commented on Sep 11, 2026

    @Ariznawlll
    CollaboratorAuthor

    测试版本

    • 分支:main
    • commit:e7d46d6dfb27696211ca828c55e245d3bd1b634d
    • 部署方式:本地单 CN MatrixOne,MOTR 连接到本机 6001
    • 测试日期:2026-09-11

    原问题验证

    在隔离数据库中连续执行 3 轮原始触发路径:OCT('12tail')、OCT('12.5')、OCT('abc')、OCT('')、OCT('20240506')、OCT('20240101123456')、OCT(TIME '12:34:56'),以及列值和 SQL PREPARE/EXECUTE 参数路径。3/3 均无报错;字符串前缀/小数返回 14,非数字返回 0,空串返回 NULL,紧凑数字字符串按数值转换,TIME 12:34:56 稳定返回 14,未再依赖当前年份。

    Happy Path 覆盖

    1. OCT(12)、DECIMAL 12.5 与 DOUBLE 12.5 均返回 14。
    2. DATE 与 TIMESTAMP 2024-05-06 均返回 3750;正、负 TIME 分别返回 14 和 1777777777777777777764。
    3. VARCHAR 列混合保存数字前缀、非数字、空串和紧凑数字;按固定顺序查询结果正确。
    4. SQL prepared statement 分别绑定 20240506 与 12tail,结果为 115154172 与 14。

    Unhappy Path 覆盖

    1. 旧问题中的非数字字符串 abc 与空串不再中止混合查询,分别受控返回 0 与 NULL。
    2. 负 TIME 路径返回有符号八进制结果,未出现日期/当前年份回退。

    白盒验证

    不适用:本次为真实 MatrixOne 服务上的 SQL 黑盒验收;修复实现已随 MatrixOne PR #28533 合入当前 main。

    回归测试

    测试证据

    • 回归用例与结果文件:MOTR PR Add error code #159
    • 本地每轮测试后检查 information_schema.schemata,隔离测试库残留数为 0。

    测试结论

    测试通过。

  7. added 3 commits that reference this issue on Sep 17, 2026
    3add3a7
    2264bed
    e09df22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/compatibilitykind/bug

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions