Skip to content

[Compatibility]: ASCII exposes TINYINT UNSIGNED result metadata instead of MySQL INT #28455

Closed

Description

@Ariznawlll

Is there an existing issue for the same bug?

  • I have checked the existing issues.

The closed implementation request #2106 does not cover result metadata. No issue was found for ASCII() CTAS or view result types.

Branch Name

main

Commit ID

a9d3b8b857c44f1249e682c91d4d62a914eb7d20

Other Environment Information

  • Local standalone MatrixOne built from the commit above
  • Reference: MySQL 8.3.0

Actual Behavior

ASCII() returns the same scalar values in MatrixOne and MySQL, but MatrixOne exposes a different result type:

CREATE TABLE src(id INT PRIMARY KEY, s VARCHAR(20));
INSERT INTO src VALUES (1,'A'),(2,'中'),(3,''),(4,NULL);

CREATE TABLE dst AS SELECT ASCII(s) AS a FROM src;

SELECT DATA_TYPE, COLUMN_TYPE, NUMERIC_PRECISION, NUMERIC_SCALE
FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='dst' AND COLUMN_NAME='a';
Engine CTAS/view column type
MatrixOne TINYINT UNSIGNED, precision 3
MySQL 8.3 INT, precision 10

The same metadata difference is visible through a view. It also changes type propagation: a CTAS over ASCII(s) UNION ALL SELECT 300 becomes DOUBLE in MatrixOne but BIGINT in MySQL.

The source values and metadata checks were repeated three times. ASCII('A'), ASCII('中'), ASCII(''), and ASCII(NULL) return the same values in both engines, so this is specifically a result-domain problem.

The built-in registration currently hard-codes the return type to T_uint8, which explains the TINYINT UNSIGNED metadata.

Expected Behavior

ASCII() should expose MySQL-compatible integer result metadata so CTAS, views, set operations, and clients do not observe a narrower unsigned type.

Steps to Reproduce

CREATE DATABASE codex_ascii_metadata;
USE codex_ascii_metadata;
CREATE TABLE src(id INT PRIMARY KEY, s VARCHAR(20));
INSERT INTO src VALUES (1,'A'),(2,'中'),(3,''),(4,NULL);

CREATE TABLE dst AS SELECT ASCII(s) AS a FROM src;
SHOW CREATE TABLE dst;

CREATE VIEW v AS SELECT ASCII(s) AS a FROM src;
SELECT DATA_TYPE, COLUMN_TYPE, NUMERIC_PRECISION, NUMERIC_SCALE
FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA='codex_ascii_metadata' AND TABLE_NAME IN ('dst','v');

Controls

  • Scalar and column values agree with MySQL for ASCII, multibyte text, empty strings, integers, and NULL.
  • ORD() metadata is BIGINT in both engines and does not show the same issue.

Activity

  1. added this to the MO-202609 milestone on Sep 9, 2026
  2. added theissue type on Sep 9, 2026
  3. self-assigned this
    on Sep 9, 2026
  4. added a commit that references this issue on Sep 12, 2026
    8074b4c
  5. Ariznawlll commented on Sep 14, 2026

    @Ariznawlll
    CollaboratorAuthor

    测试版本

    原问题验证

    • ASCII 的结果元数据为 MySQL 兼容的 signed INT。

    Happy Path 覆盖

    • ASCII(A)/ASCII(中)/ASCII(空串)/NULL 为 65/228/0/NULL;CTAS 元数据为 INT、precision 10。

    Unhappy Path 覆盖

    • 覆盖空串与 NULL,不把结果域退化为 TINYINT UNSIGNED。

    白盒验证

    回归测试

    测试证据

    • 独立环境三轮输出字节一致;服务日志未见 panic/hang,测试后已清理服务。

    测试结论

    测试通过。

  6. Ariznawlll commented on Sep 14, 2026

    @Ariznawlll
    CollaboratorAuthor

    测试版本

    • 分支:main
    • commit:bb358ea76aeb44a6eed5079616e7e75ba35e75b9
    • 部署:独立本地 1 CN / 1 TN / 1 LogService;连续执行 3 轮。

    原问题验证

    • ASCII 的结果元数据已为 MySQL 兼容的 signed INT。

    Happy Path 覆盖

    • ASCII(A)/ASCII(中)/ASCII(空串)/NULL 为 65/228/0/NULL;CTAS 元数据为 INT、precision 10。

    Unhappy Path 覆盖

    • 覆盖空串与 NULL,不把结果域退化为 TINYINT UNSIGNED。

    白盒验证

    回归测试

    测试证据

    • 独立环境三轮输出字节一致;服务日志未见 panic/hang,测试后已清理服务。

    测试结论

    测试通过。

  7. added 3 commits that reference this issue on Sep 17, 2026
    6b75380
    54f04b2
    5851e92
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