Skip to content

[Bug]: EXPORT_SET misinterprets DECIMAL and truncates FLOAT bit masks #28463

Closed

Description

@Ariznawlll

Is there an existing issue for the same bug?

No existing issue covers the first bits argument of EXPORT_SET().

Branch Name

main

Commit ID

a9d3b8b857c44f1249e682c91d4d62a914eb7d20

Other Environment Information

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

Actual Behavior

EXPORT_SET(bits, ...) uses different and incorrect conversions for DECIMAL, FLOAT/DOUBLE, BOOL, and prepared values.

DECIMAL storage is used as an unscaled bit mask

SELECT
  EXPORT_SET(CAST(1.4   AS DECIMAL(4,1)),'Y','N','',4),
  EXPORT_SET(CAST(1.40  AS DECIMAL(4,2)),'Y','N','',4),
  EXPORT_SET(CAST(1.400 AS DECIMAL(5,3)),'Y','N','',4);
MatrixOne: NYYY, NNYY, NNNY
MySQL:     YNNN, YNNN, YNNN

The MatrixOne results correspond to masks 14, 140, and 1400: the stored DECIMAL coefficients. Merely changing scale changes the selected bits.

FLOAT/DOUBLE values are truncated instead of rounded

For DOUBLE values 1.4, 1.5, 1.9, and -1.5, MatrixOne uses masks 1, 1, 1, and -1. MySQL uses 1, 2, 2, and -2. This changes both positive and negative selected-bit results.

Boolean inputs are rejected

EXPORT_SET(TRUE,'Y','N','',4) is rejected with invalid argument function export_set; MySQL returns YNNN.

Prepared values lose their numeric category

With a fresh server-side statement on every run, DECIMAL/DOUBLE 1.5 produces YNNN in MatrixOne and NYNN in MySQL. TRUE produces NNNN in MatrixOne and YNNN in MySQL.

All scalar, column, CTAS, and prepared forms were reproduced three times.

The executor confirms the observed split:

  • FLOAT/DOUBLE getters call int64(val), which truncates.
  • Other accepted numeric types fall through to GenerateFunctionFixedTypeParameter[int64]; DECIMAL storage is then read without applying its scale.
  • The checker has no accepted Boolean numeric path.

Expected Behavior

The first bits argument should be converted to an integer numeric value before bit inspection. Equivalent DECIMAL values must be scale-invariant, fractional numeric values must follow MySQL's rounding rule for this argument, and Boolean values must map to 0/1.

Steps to Reproduce

CREATE DATABASE codex_export_set_bits;
USE codex_export_set_bits;
CREATE TABLE t(
  id INT PRIMARY KEY,
  d1 DECIMAL(4,1),
  d2 DECIMAL(5,2),
  f DOUBLE,
  b BOOLEAN
);
INSERT INTO t VALUES
  (1,1.4,1.40,1.4,TRUE),
  (2,1.5,1.50,1.5,FALSE),
  (3,1.9,1.90,1.9,NULL),
  (4,-1.5,-1.50,-1.5,NULL);

SELECT id,EXPORT_SET(d1,'Y','N','',4) FROM t ORDER BY id;
SELECT id,EXPORT_SET(d2,'Y','N','',4) FROM t ORDER BY id;
SELECT id,EXPORT_SET(f,'Y','N','',4) FROM t ORDER BY id;
SELECT id,EXPORT_SET(b,'Y','N','',4) FROM t ORDER BY id;

Controls

Activity

  1. added
    kind/bug
    on Sep 9, 2026
  2. added this to the MO-202609 milestone on Sep 9, 2026
  3. added theissue type on Sep 9, 2026
  4. added
    severity/s0
    and removed on Sep 16, 2026
  5. assigned and unassigned on Sep 27, 2026
  6. slyunnn commented on Sep 29, 2026

    @slyunnn

    Regression and extended verification for #28463 (2026-09-29)

    Verification Environment

    • MatrixOne source: latest local origin/main at b9013dc6bb058ec74935a62ac3a35f57d13c2f98 — Fix replay promotion CI regressions on main (#29426).
    • Runtime: a new local matrixorigin/matrixone:local image was rebuilt from the exact origin/main source archive and all verification containers were recreated from that image.
    • Topology: 2 CN / 1 TN / 1 Log service / Proxy.
    • SQL endpoints: Proxy 6001, CN1 16001, and CN2 16002; all three accepted TCP connections and completed the reported SQL. The original scenario was executed through each endpoint, not inferred from a health check.
    • Clients: MySQL CLI over TCP for SQL coverage; Go database/sql with go-sql-driver/mysql and interpolateParams=false for binary prepared statements (COM_STMT_PREPARE / COM_STMT_EXECUTE).
    • Compatibility control: local MySQL 8.3.0 executed the original column scenario and returned the same rows as MatrixOne.

    What Was Covered

    • OK Original DECIMAL(4,1), DECIMAL(5,2), and DECIMAL(5,3) scale-invariance scenario: 1.4, 1.40, and 1.400 all returned YNNN through Proxy, CN1, and CN2.
    • OK Original DOUBLE column scenario: 1.4, 1.5, 1.9, and -1.5 returned the expected masks YNNN, NYNN, NYNN, and NYYY on all three endpoints.
    • OK Original BOOLEAN column scenario: TRUE returned YNNN, FALSE returned NNNN, and NULL propagated as NULL on all three endpoints.
    • OK Extended happy-path and boundary coverage: 2.5, signed -2, UINT64 maximum, BIT(64), and NULL produced the expected bit masks.
    • OK Extended expression coverage: IF and CASE expressions with DECIMAL and DOUBLE inputs preserved the expected masks.
    • OK SQL prepared-statement reuse: one PREPARE template handled approximate 1.5, exact 2.5, string 1.5, and TRUE correctly through Proxy, CN1, and CN2.
    • OK Binary prepared statements: database/sql + go-sql-driver/mysql with interpolateParams=false returned NYNN for float64(1.5), YNNN for true, and YNNN for CAST(? AS DECIMAL(10,2)) with 1.40 through all three endpoints.
    • OK Unhappy path: EXPORT_SET(CAST('9223372036854775808' AS DECIMAL(20,0)), ...) was rejected on all three endpoints with ERROR 1690 / 22003 (data out of range).
    • OK Compatibility control: MySQL 8.3.0 returned the same original four-row DECIMAL / DOUBLE / BOOLEAN result matrix.
    • Not covered Restart/failover, concurrency, and large-workload behavior; they are outside this scalar type-coercion defect's contract.

    Findings

    • Related fix: 3f0a68bd8034d37e098765920f328985c308c9ff — refactor(sql): migrate bit-pattern integer parameters (#29231), merged by #29231. It centralizes type-domain coercion for bit-pattern integer parameters, including EXPORT_SET.
    • The original unscaled-DECIMAL, truncated DOUBLE, rejected BOOLEAN, and prepared-value category-loss behaviors were not reproduced.
    • Independent endpoint cases used isolated databases and ran in parallel. This is test-client parallelism only; no claim is made about MatrixOne engine worker parallelism.
    • Large-data regression is not required: the defect is deterministic scalar argument coercion and does not depend on row count, block/batch boundaries, memory/spill, skew, network transfer, or resource scale.

    MOTR / BVT Coverage

    • Existing BVT coverage is present in test/distributed/cases/function/bit_integer_parameter_coercion.sql and its result file. It covers the reported DECIMAL, DOUBLE, BOOLEAN, NULL, signed/unsigned boundaries, SQL prepared reuse, and generated-expression cases.
    • No MOTR change was needed, so there is no MOTR branch, recording/replay, or commit for this issue. No MatrixOne service source was modified.

    Final Conclusion

    Fixed. The reported EXPORT_SET type-coercion contract is verified on the latest origin/main runtime through Proxy 6001, CN1 16001, and CN2 16002, including real binary prepared-statement execution and a MySQL 8.3.0 compatibility control. Large-data regression is not required for the reasons above.

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

Metadata

Metadata

Assignees

Labels

kind/bugseverity/s0

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions