Skip to content

[Bug]: grouped ENUM/SET numeric conversion fails on 4.2-dev #32819

Closed

Description

@XuPeng-SH

Existing issue check

  • This is the same behavior as the closed main-branch issue [Bug]: grouped ENUM and SET values lose numeric ordinal semantics #28687, fixed by PR fix(plan): preserve grouped ENUM/SET numeric semantics #28751 (afe0f1a755965f529745b93608ee766c78b2e6b5).
  • On 4.2-dev tip b97995b007051b28d0f98bffc6f210da0aa9b866, git merge-base --is-ancestor afe0f1a755965f529745b93608ee766c78b2e6b5 b97995b007051b28d0f98bffc6f210da0aa9b866 returns 1, so the main fix is not in this branch.
  • The same failure also reproduces at earlier 4.2-dev commit cc056261a8fb977aeaffec3bea4bbd85a342fdca; this is not a regression introduced in the last 24 hours. This issue tracks the still-affected 4.2-dev branch.

Branch Name

4.2-dev

Commit ID

b97995b007051b28d0f98bffc6f210da0aa9b866

Other Environment Information

  • macOS arm64
  • Fresh local deployment: 1 CN, 1 TN, 1 LogService
  • SQL executed through the MySQL TCP protocol against the real mo-service
  • Build toolchain recorded by the build: Go 1.26.4

Steps to Reproduce

DROP DATABASE IF EXISTS issue_group_42;
CREATE DATABASE issue_group_42;
USE issue_group_42;

CREATE TABLE t(
  id INT PRIMARY KEY,
  e ENUM('a','b'),
  s SET('x','y')
);
INSERT INTO t VALUES
  (1,'a','x'),
  (2,'a','x,y'),
  (3,'b','y');

-- Control: row-level numeric semantics work.
SELECT id,e,e+0,s,s+0 FROM t ORDER BY id;

-- Each of these grouped queries fails independently.
SELECT e+0 AS ord,COUNT(*) AS cnt FROM t GROUP BY e ORDER BY e+0;
SELECT s+0 AS bits,COUNT(*) AS cnt FROM t GROUP BY s ORDER BY s+0;

The control returns the expected numeric values:

id  e  e+0  s    s+0
1   a  1    x    1
2   a  1    x,y  3
3   b  2    y    2

Actual Behavior

The grouped ENUM query fails:

ERROR 20203 (HY000): invalid argument cast to int, bad value a

The grouped SET query fails independently:

ERROR 20203 (HY000): invalid argument cast to int, bad value x

There is no declared empty ENUM label, so this is not the deliberately excluded ambiguous-empty-label case described in PR #28751.

Expected Behavior

Numeric conversion after grouping must preserve the same ENUM ordinal and SET bitmap semantics as row-level conversion:

-- ENUM
ord  cnt
1    2
2    1

-- SET
bits  cnt
1     1
2     1
3     1

Additional information

Activity

  1. added
    kind/bug
    on Nov 16, 2026
  2. XuPeng-SH commented on Nov 16, 2026

    @XuPeng-SH
    ContributorAuthor

    Cross-version verification using the same standalone SQL against freshly built, real mo-service instances (MySQL protocol, fresh data directories):

    Version Commit Result
    v4.2.8 10d204b8763f19b2b37ba2147d1d4c1a7828d6d4 Reproduced: grouped ENUM fails on label a; grouped SET fails on label x. Row-level e+0 / s+0 works.
    4.2-dev b97995b007051b28d0f98bffc6f210da0aa9b866 Reproduced as originally reported.
    origin/main f491aaab4519b29313c5747d3ce3b3f84e865c71 Passes: ENUM returns (ord=1,cnt=2),(2,1); SET returns (bits=1,cnt=1),(2,1),(3,1).

    The current main fix is effective. This is also present in released v4.2.8; it is not only a regression on the newest 4.2-dev commits.

  3. added 2 commits that reference this issue on Nov 17, 2026
    fc6c7fe
    8c77e14
  4. XuPeng-SH commented on Nov 17, 2026

    @XuPeng-SH
    ContributorAuthor

    QA 交接(4.2-dev,不代表验收通过)

    #32841 已于 2026-11-17 09:19:27 UTC 合入 4.2-dev,merge SHA 8c77e14665f054b9065a1cc2789017f7b9fc98c5。本 issue 的 grouped ENUM/SET 数值来源语义修复交 @Ariznawlll 验证,保持 open。已核 issue 全部评论及关联修复讨论;main 早已修复不等于 release 当时已修复,现在以本次 release merge 为依据。

    作者报告真实服务 grouped ENUM/SET BVT 84/84 两轮、扩展 scalar correlated BVT 89/89 两轮、plan/直接消费者测试及静态检查通过。旧 repeated NOW/CURRENT_DATE 反例随后由 5265c9 修复,后续审查明确关闭该发现并独立执行单 CN SQL;不把旧 head 反例当最终 head 反例。本次巡检未本地执行测试,未宣称多 CN/原现场全量验收。

    请核对 issue 原 SQL 的 ENUM ordinal、SET bitmap、分组前后数值一致性及 NULL/非可逆转换、prepared 重复执行;关联 scalar 改动应核空结果 NULL、基数和稳定函数复用。nested no-FROM scalar numeric arithmetic 仍是独立的基线限制,不声称本 PR 一并修复。#32823 也是此 issue 的 release 关联记录,本次按 issue 去重只交接一次。

  5. Ariznawlll commented on Nov 18, 2026

    @Ariznawlll
    Collaborator

    QA 复验通过,按验收范围关闭。

    环境:4.2-dev @ 72c43e9305d8355c940075e414f30eaf2e4112a6(含修复 #32841,merge 8c77e14,亦含同源 #32823),实例内 git_version() 确认。

    验证(MOTR 用例 issue_32819_grouped_enum_set_numeric,record 2/2 + verify 2/2 PASS):

    • grouped ENUM 保留序数(ordinal)数值语义、grouped SET 保留位图(bitmap)数值语义;
    • 空标量来源不产生行、不做非法数值转换;
    • 与非分组路径的数值一致。

    交付:https://github.com/matrixorigin/motr/pull/359(commit 0c75105)。

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

Metadata

Metadata

Assignees

Labels

kind/bugneeds-triage

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions