Skip to content

[Compatibility]: string numeric-result functions materialize incompatible width or signedness #28909

Closed

Description

@Ariznawlll

Problem

Several numeric-result string functions are materialized with incompatible width or signedness in MatrixOne Views and CTAS tables:

  • FIND_IN_SET becomes BIGINT UNSIGNED instead of signed INT;
  • STRCMP becomes TINYINT instead of signed INT;
  • CHAR_LENGTH becomes BIGINT UNSIGNED instead of signed BIGINT.

Reproduction

drop database if exists find_in_set_type_repro;
create database find_in_set_type_repro;
use find_in_set_type_repro;

create table src(id int primary key,needle varchar(20),csv varchar(100));
insert into src values
  (1,'b','a,b,,c'),
  (2,'','a,b,,c'),
  (3,'中','甲,中,乙'),
  (4,null,null);

create view v as
select id,
       find_in_set(needle,csv) pos,
       strcmp(needle,'a') cmp,
       char_length(csv) chars
from src;
create table ctas as select * from v;

select table_name,column_name,data_type,column_type,is_nullable,
       numeric_precision,numeric_scale
from information_schema.columns
where table_schema=database() and table_name in ('v','ctas')
order by table_name,ordinal_position;

MatrixOne result

In both the View and CTAS table:

  • pos is BIGINT UNSIGNED;
  • cmp is TINYINT;
  • chars is BIGINT UNSIGNED.

MySQL 8.0.45 result

In both the View and CTAS table:

  • pos and cmp are signed INT;
  • chars is signed BIGINT.

Scalar values agree when inputs use relations that both systems implement identically. Collation-sensitive value differences are tracked separately in #25096; this issue concerns the persisted numeric schema contract.

Protocol control

A direct constant expression is exposed through the wire protocol as LONGLONG by both systems, but MatrixOne sets the UNSIGNED flag and reports display length 64, while MySQL reports a signed numeric result with display length 3. View/CTAS inspection is the stable DDL-level reproduction above.

Incorrect signedness and width propagate into CTAS schemas, generated client models, and connectors that derive types from INFORMATION_SCHEMA.

Scope

Direct SQL, table columns, View, CTAS, PreparedStatement, empty element, missing value, UTF-8 input, and NULL are covered. Controls for LENGTH, OCTET_LENGTH, BIT_LENGTH, ASCII, ORD, LOCATE, INSTR, and POSITION materialize with compatible base types. Three independent executions produced identical results on each database.

Environment

  • MatrixOne: official main commit 0c3a04f390adaf6281fd592a49778ea5b1155e67
  • MySQL control: 8.0.45
  • Local single-node MatrixOne deployment

Activity

  1. added this to the MO-202609 milestone on Sep 15, 2026
  2. added theissue type on Sep 15, 2026
  3. changed the title [-][Compatibility]: FIND_IN_SET materializes as BIGINT UNSIGNED instead of INT[/-] [+][Compatibility]: string numeric-result functions materialize incompatible width or signedness[/+] on Sep 15, 2026
  4. Ariznawlll commented on Sep 15, 2026

    @Ariznawlll
    CollaboratorAuthor

    补充一个同类的数值结果元数据差异:CRC32(expr) 的值域虽然是 32 位无符号整数,但 MySQL 8.0.45 对非常量表达式声明 BIGINT UNSIGNED,MatrixOne 声明 INT UNSIGNED。

    CREATE TABLE src(v VARCHAR(10));
    INSERT INTO src VALUES ('x');
    CREATE VIEW vcrc AS SELECT CRC32(v) AS c FROM src;
    CREATE TABLE ccrc AS SELECT CRC32(v) AS c FROM src;
    
    SELECT table_name,column_name,data_type,column_type,numeric_precision
    FROM information_schema.columns
    WHERE table_schema=DATABASE() AND table_name IN ('vcrc','ccrc')
    ORDER BY table_name;

    MatrixOne 的 View 与 CTAS 均为 INT UNSIGNED、precision 10;MySQL 均为 BIGINT UNSIGNED、precision 20。校验值本身与 MySQL 一致,差异只在可观察的列元数据,属于本 issue 已描述的数值结果类型/宽度兼容性问题。

    该差异在两端各重复 3 次。验证版本:official main commit 0c3a04f390adaf6281fd592a49778ea5b1155e67;MySQL 8.0.45。

  5. self-assigned this
    on Sep 15, 2026
  6. Ariznawlll commented on Sep 15, 2026

    @Ariznawlll
    CollaboratorAuthor

    补充 UNCOMPRESSED_LENGTH(expr) 的可观察返回类型差异:对 View 与 CTAS 中的列表达式,MatrixOne 声明 INT(precision 10),MySQL 8.0.45 声明 BIGINT(precision 19)。有效输入的数值结果一致,差异只在结果列元数据,因此归入本 issue 的数值结果宽度兼容范围。

    验证语句覆盖 UNCOMPRESSED_LENGTH(COMPRESS(varchar_column)) 的 View、CTAS、NULL、空串、Unicode、VARBINARY 和 prepared 执行,并在两端各重复 3 次。

    验证版本:official main commit 0c3a04f390adaf6281fd592a49778ea5b1155e67;MySQL 8.0.45。

  7. slyunnn commented on Sep 22, 2026

    @slyunnn

    Regression result: Partially fixed.

    Environment: latest origin/main at 3727c5c5436ca136d7b0312f75bc223a11692a85 (fix(frontend): require alter role privilege for SHOW RULES (#29217)), rebuilt locally with make TYPECHECK=0 dev-build and deployed as 1 Log service / 1 TN / 2 CN / Proxy. Proxy :6001, CN1 :16001, and CN2 :16002 were independently exercised through go-sql-driver/mysql over the MySQL wire protocol. MySQL 8.0.45 was the compatibility control.

    PR #28915 / 8a4c84f4516d5098de9eef50b8afecc7524f37a2 fixes the persisted-schema part of this issue. The original View and CTAS reproduction now matches MySQL on all three MatrixOne endpoints:

    • FIND_IN_SET and STRCMP: signed INT / precision 10.
    • CHAR_LENGTH: signed BIGINT / precision 19.
    • The same verification also passed for the issue comments' CRC32: BIGINT UNSIGNED / precision 20, and UNCOMPRESSED_LENGTH: signed BIGINT / precision 19.
    • Empty element, missing value, UTF-8, empty-string, NULL, and valid-value controls matched MySQL. Existing BVT test/distributed/cases/function/func_bounded_result_metadata.test covers the persisted metadata contract.

    Remaining compatibility gap:

    • Reproduction: execute SELECT FIND_IN_SET('b', 'a,b'), STRCMP('a', 'b') as either text SQL or a real MySQL binary prepared statement.
    • MatrixOne: both result columns are exposed as signed INT / Go int32.
    • MySQL 8.0.45: both result columns are exposed as signed BIGINT / Go int64.
    • The mismatch reproduces through Proxy, CN1, and CN2. Values are correct; the remaining difference is observable result-set metadata and can affect protocol-derived client models.

    Please preserve the corrected signed INT persisted schema for Views/CTAS while making direct and binary prepared result-set metadata for these functions MySQL-compatible (LONGLONG / signed BIGINT, with no UNSIGNED flag). This remains within #28909; no duplicate issue was created.

    No large-data regression is needed because this is a per-expression metadata contract, independent of data volume, block/batch boundaries, memory/spill, skew, or concurrency. No MOTR case was added: a protocol assertion for the remaining gap would fail on current main and should accompany the product fix.

  8. slyunnn commented on Sep 23, 2026

    @slyunnn

    Regression and extended verification for #28909 (2026-09-23)

    Verification Environment

    • Source: latest origin/main at 66da3877e9e77f01083c4aac0cb9f94ab6e11fe6 — feat(sql): support EXCEPT ALL multiset subtraction (#29228).
    • Runtime: a no-cache local image build from that checkout, sha256:e3927aba7b94bc18185cc167a38a070b4c6070869d7bd08fccb591add9cb28c5; Proxy, CN1, and CN2 were confirmed to run that image.
    • Topology: local 1 Log service / 1 TN / 2 CN / Proxy, using a new isolated data root so no existing local cluster data was reset or changed.
    • Endpoints: Proxy :6001, CN1 :16001, and CN2 :16002 were each reachable and each executed the original DDL, direct SQL, and binary prepared-statement regression paths.
    • Client protocol: go-sql-driver/mysql over the MySQL wire protocol. Both text COM_QUERY and real COM_STMT_PREPARE / COM_STMT_EXECUTE were used. MySQL 8.0.45 was the compatibility control.
    • Related fixes: 8a4c84f4516d5098de9eef50b8afecc7524f37a2 / PR #28915 (fix compatibility for concat, prepared elt, and string numeric results) fixes persisted result schemas; 27ffab65a0f1c98752bb2fa5e852810cc6e12900 / PR #29233 (fix(frontend): preserve direct integer function wire metadata) fixes the direct and binary prepared result-set metadata.

    What Was Covered

    • OK Original View and CTAS reproduction through Proxy, CN1, and CN2: FIND_IN_SET and STRCMP materialized as signed INT with precision 10; CHAR_LENGTH materialized as signed BIGINT with precision 19, matching MySQL 8.0.45.
    • OK Persisted-schema extensions: CRC32 materialized as BIGINT UNSIGNED with precision 20, and UNCOMPRESSED_LENGTH(COMPRESS(...)) as signed BIGINT with precision 19, in both View and CTAS.
    • OK Happy path values: rows with ordinary ASCII and UTF-8 values returned matching FIND_IN_SET positions and CHAR_LENGTH values on all endpoints.
    • OK Boundary and unhappy controls: empty list member returned 3, missing member returned 0, UTF-8 member returned 2, STRCMP('a','a') returned 0, STRCMP('', 'a') returned -1, empty CHAR_LENGTH returned 0, and NULL returned NULL, matching MySQL.
    • OK Compatibility controls: View metadata for LENGTH, OCTET_LENGTH, BIT_LENGTH, ASCII, ORD, LOCATE, INSTR, and POSITION matched MySQL.
    • OK Direct text protocol: SELECT FIND_IN_SET('b','a,b'), STRCMP('a','b') exposed signed BIGINT / int64 on Proxy, CN1, and CN2, matching MySQL.
    • OK Binary prepared protocol: COM_STMT_PREPARE / COM_STMT_EXECUTE for FIND_IN_SET(?,'a,b') and STRCMP(?,'b') exposed signed BIGINT / int64 and returned 2 and -1 on all endpoints, matching MySQL.
    • Not covered: the special direct-result presentation is intentionally not applied to DISTINCT, grouping, set operations, enclosing expressions, star expansion, or forwarded derived/View columns. These query shapes are outside the original #28909 reproduction scope and were explicitly excluded by PR #29233.

    Findings

    The two-step repair is effective. PR #28915 corrected the logical result domain and persisted View/CTAS schemas; PR #29233 preserves MySQL-compatible signed LONGLONG presentation for direct projected FIND_IN_SET and STRCMP results without changing their internal signed INT execution vectors or persisted schemas.

    The focused embedded-cluster regression TestIssue28909DirectFunctionWireMetadata and frontend tests TestDirectIntegerBinaryRows, TestDirectIntegerResultClassification, and TestDirectIntegerPrepareWireMetadata passed.

    No large-data regression is needed. This is a per-expression schema and result-set metadata contract, independent of row count, block/batch boundaries, memory/spill, skew, network transfer, or concurrency. The small multi-row case is sufficient to verify value, NULL, and metadata propagation.

    MOTR / BVT Coverage

    • Existing BVT test/distributed/cases/function/func_bounded_result_metadata.test covers the persisted metadata contract.
    • Existing focused issue regression pkg/tests/issues/issue_28909_test.go covers direct and binary prepared wire metadata, parameter reuse, View/CTAS preservation, and schema rebuild behavior.
    • No MOTR change, issue branch, or daily-regression commit was needed because current upstream coverage already contains the required regression tests.
    • Endpoint cases were run serially because each creates and drops the same temporary schema. No MOTR parallel scheduler was used, and this is not an engine-parallelism stress test.

    Final Conclusion

    Fixed. The original #28909 View/CTAS width and signedness regression and its direct/binary prepared result-set metadata follow-up both match MySQL 8.0.45 on Proxy, CN1, and CN2. Large-data regression is not required for the stated per-expression metadata reason.

  9. Ariznawlll commented on Sep 23, 2026

    @Ariznawlll
    CollaboratorAuthor

    最新 main 验证通过,关闭。

    验证版本:16d8e5106caaedfe0a7296e4f628683e1b6a92b4,包含 PR #28915 与 #29233。

    TestIssue28909DirectFunctionWireMetadata 连续 3 次通过,覆盖:

    • direct SQL 与真实 prepared 查询的 FIND_IN_SET / STRCMP 对外元数据均为 signed BIGINT,值为 2 / -1;
    • prepared 参数重用、ALTER 后复用、NULL/UTF-8/缺失值;
    • View/CTAS 中持久化列仍保持预期 INT 域,不被 direct-wire 展示规则污染。

    核心验收是 MySQL wire result metadata,纯 SQL MOTR 无法读取列 type/flag,故定向产品集成测试是准确回归位置。

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