Skip to content

[Compatibility]: UUID() native result type breaks MySQL string expression semantics #28382

Closed as not planned

Description

@Ariznawlll

MatrixOne version

Latest main at f72ca9efbeb3a7c673701e4a135cc6670c33cfde (VERSION() reports 8.0.30-MatrixOne-v1.3.0).

MySQL control: 8.3.0.

What is different

MySQL returns UUID() as a 36-character string. MatrixOne exposes UUID() as its native UUID SQL type. The native result does not participate in several ordinary string-expression contexts with MySQL semantics.

This is separate from the UUID version difference in #28380: changing the generated UUID from v7 to v1 would not change these result-type and coercion behaviors.

Reproduction and observed behavior

String predicates and scalar functions

SELECT UUID() IN ('fallback');
SELECT GREATEST(UUID(), 'fallback');
SELECT LEAST(UUID(), 'fallback');

MatrixOne returns:

invalid UUID length: 8
invalid argument function greatest, bad value [UUID VARCHAR]
invalid argument function least, bad value [UUID VARCHAR]

MySQL 8.3 treats UUID() as a string: the IN expression returns 0, and GREATEST/LEAST return the lexicographically selected string.

Set operation

SELECT 'fallback'
UNION ALL
SELECT UUID();

MatrixOne returns the UUID row truncated to the width of the first literal:

fallback
01a07f76

MySQL returns the complete 36-character UUID. Reversing the MatrixOne branches (SELECT UUID() UNION ALL SELECT 'fallback') also returns the full UUID, so the result depends on branch order.

CTAS metadata

CREATE TABLE ctas AS SELECT UUID() AS u;
SHOW CREATE TABLE ctas;

MatrixOne derives u UUID NOT NULL; MySQL derives u VARCHAR(36). This makes the return-type difference externally visible in persisted schema as well as scalar evaluation.

All behaviors above were reproduced in three independent runs on each engine.

Controls

Explicit conversion isolates the problem to UUID/string type resolution:

SELECT CAST(UUID() AS CHAR) IN ('fallback');
SELECT GREATEST(CAST(UUID() AS CHAR), 'fallback');

Both execute in MatrixOne with the same result shape as MySQL (0 and 'fallback'). CASE, IF, COALESCE, string length, concatenation, and the reverse-order UUID() UNION ALL SELECT 'fallback' also execute, so UUID generation and its textual formatting are not the cause.

Compatibility contract and implementation

Expected behavior

The MySQL-compatible UUID() function result should be usable as a 36-character string in comparison, scalar, set-operation, and CTAS contexts without explicit casts, and set-operation branch order must not truncate a generated UUID. MatrixOne-specific versioned generators or explicit casts to the native UUID type can retain native-type behavior separately.

Activity

  1. added this to the MO-202609 milestone on Sep 8, 2026
  2. added theissue type on Sep 8, 2026
  3. self-assigned this
    on Sep 8, 2026
  4. XuPeng-SH commented on Oct 9, 2026

    @XuPeng-SH
    Contributor

    PR #29800 已于 2026-10-09 合并,merge commit:8f48d6fac04bf612be65ed1b44477ef9b32cb88f。

    本次修复 UUID 与字符值表达式的类型归并和宽度问题:混合 UUID/CHAR/VARCHAR/TEXT 的 CASE、IF、COALESCE、UNION、LEAST/GREATEST 能保留完整 36 字符 UUID;UUID/NULL-only 仍使用 native UUID。

    本 issue 仍部分未解决:UUID() 继续返回 MatrixOne native UUIDv7,因此 CTAS 仍是 UUID 列;与任意非 UUID 文本做 native UUID predicate 仍按 UUID 解析,非法文本会报错。需要字符串语义时可显式 CAST(UUID() AS CHAR)。本次没有把 UUID() 改成 MySQL VARCHAR/v1,也没有承诺完整 MySQL collation 兼容,所以 issue 保持开放。

  5. XuPeng-SH commented on Oct 9, 2026

    @XuPeng-SH
    Contributor

    补充文档跟踪:matrixone-doc 的中英文 UUID 参考页需要按合并后的 native UUIDv7 契约修订,见 #29803。#29800 已修复混合 UUID/字符值表达式的完整宽度与分支顺序问题;本 issue 仍开放跟踪未采用 MySQL 字符返回语义的剩余行为,包括 native CTAS 类型和对任意文本的严格 UUID predicate。

  6. XuPeng-SH commented on Oct 9, 2026

    @XuPeng-SH
    Contributor

    收敛最终兼容性决定:#29800 已合并,修复 UUID/字符值表达式的宽度、分支顺序,以及 LEAST/GREATEST 支持。剩余的 native UUID 返回类型、native CTAS 类型和严格 UUID predicate,是保留原生类型/索引语义的明确产品契约,不再计划改成 MySQL 的 VARCHAR 返回语义。

    需要任意文本比较时使用 CAST(UUID() AS CHAR);需要 v1 字符结果时使用 CAST(UUID_V1() AS CHAR)。这不代表完整 MySQL collation 兼容。

    本 issue 按上述剩余兼容性诉求关闭为 not planned,并非声称所有行为都与 MySQL 相同。官方中英文文档纠正由 #29803 和matrixone-doc#374 跟踪;旧仓库 #723 已关闭且不计作文档交付。

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