Skip to content

[Compatibility]: OCT exposes DECIMAL instead of a bounded character result #28466

Closed

Description

@Ariznawlll

MatrixOne version

Latest main at a9d3b8b857c44f1249e682c91d4d62a914eb7d20. MySQL control: 8.3.0.

What is different

MatrixOne exposes OCT() as DECIMAL(38,0), while MySQL exposes its octal representation as VARCHAR(65). The difference becomes persistent schema through CTAS and is also visible through views/client result metadata.

Reproduction

CREATE TABLE src(i BIGINT, d DOUBLE);
INSERT INTO src VALUES (12, 12.5);

CREATE TABLE derived AS
SELECT OCT(i) AS oi, OCT(d) AS od FROM src;

SHOW CREATE TABLE derived;
SELECT COLUMN_NAME, DATA_TYPE, COLUMN_TYPE,
       CHARACTER_MAXIMUM_LENGTH, NUMERIC_PRECISION, NUMERIC_SCALE
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'derived'
ORDER BY ORDINAL_POSITION;

CREATE VIEW v AS SELECT OCT(i) AS oi FROM src;
SELECT DATA_TYPE, COLUMN_TYPE, CHARACTER_MAXIMUM_LENGTH,
       NUMERIC_PRECISION, NUMERIC_SCALE
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'v';

Observed metadata:

                         MatrixOne              MySQL 8.3
CTAS OCT(i)              DECIMAL(38,0)          VARCHAR(65)
CTAS OCT(d)              DECIMAL(38,0)          VARCHAR(65)
view OCT(i)              DECIMAL(38,0)          VARCHAR(65)

This was reproduced in three independent databases per engine.

Controls

  • Ordinary values such as OCT(12) are textually 14 in both engines.
  • The mismatch is present for both integral and approximate numeric inputs, so it is not caused by one argument overload.
  • BIN() and CONV() on this same MatrixOne commit now expose bounded VARCHAR(65) after fix(function): preserve bounded conversion result metadata #28420, confirming that bounded base-conversion result metadata can be represented correctly.

Root cause

Every OCT overload in the function registry returns types.T_decimal128.ToType(), and each executor writes a Decimal128. CTAS and view derivation therefore persist a numeric type instead of the function's character result domain.

Expected behavior

OCT() should expose a bounded character result compatible with MySQL so that CTAS, views, UNION/type propagation, client metadata, and downstream string operations see the correct domain.

Activity

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

    @Ariznawlll
    CollaboratorAuthor

    在同步后的最新 main(f0c31cd4b830be32442cf329e0a3fb08aa9c16c3)重新执行 3 轮 CTAS 与 view 元数据检查:MatrixOne 的 OCT(INT)/OCT(DOUBLE) 仍派生为 DECIMAL(38,0),MySQL 8.3 为 VARCHAR(65);值输出与原报告一致。

  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 轮 BIGINT、DOUBLE 输入的 OCT,并创建 CTAS 表和 View。查询 information_schema.columns:CTAS 与 View 的 oi、od 四个输出列均为 VARCHAR(65),未再出现 DECIMAL(38,0) 元数据。

    Happy Path 覆盖

    1. 12/12.5 的 OCT 值均为 14,并可在 CONCAT(OCT(i), ':x') 和 LENGTH(OCT(d)) 中作为字符结果使用。
    2. CTAS oct_derived 与 View oct_view 的 BIGINT、DOUBLE OCT 输出均为 varchar、VARCHAR(65)、长度 65。
    3. 直接查询、CTAS、View 和字符串上下文覆盖同一结果域,元数据一致。

    Unhappy Path 覆盖

    1. 负值 -12/-12.5、零以及 BIGINT 最大值均完成 OCT 转换并返回稳定字符结果。
    2. 本 issue 没有要求服务端拒绝某类输入;上述边界值均为有效输入,验证其不会退化为 DECIMAL 元数据或中止查询。

    白盒验证

    不适用:本次为真实 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