Skip to content

[Bug]: COM_STMT DOUBLE metadata decimals=0 causes ODBC to round floating-point results #26682

Closed

Description

@iamlinjunhong

Is there an existing issue for the same bug?

  • I have checked the existing issues.

ODBC umbrella issue: #26677

Branch Name

m-25908

Commit ID

35252dd

The running server reports 8.0.30-MatrixOne-v25908.

Other Environment Information

  • Hardware parameters: Apple Silicon ARM64, 10 logical CPUs
  • OS type: macOS 15.5, Darwin 24.5.0
  • Deployment: fresh local launch with etc/launch/launch.toml
  • Client: MatrixOne ODBC derived from MySQL Connector/ODBC 9.7.0 through unixODBC 2.3.14 and MySQL client library 9.7.1

Actual Behavior

Floating-point values lose their fractional part when selected through an ODBC prepared statement.

Inserted values:

12.3
-15.7
3.5

ODBC result:

12
-16
4

The MatrixOne native MySQL command-line client query returns the original fractional values.

Native debugger evidence from the Connector/ODBC server-side prepared statement path:

field.type       = MYSQL_TYPE_DOUBLE
field.decimals   = 0
field.length     = 53
field.name       = num0

result bind type = MYSQL_TYPE_STRING
buffer length    = 24
returned value   = "12"
returned length  = 2

Connector/ODBC intentionally asks mysqlclient to fetch prepared FLOAT and DOUBLE columns as character data for consistency with text results. Because MatrixOne reports decimals=0 in COM_STMT result metadata, conversion rounds the native value to zero decimal places before ODBC receives it.

This is a data correctness issue for ODBC and any prepared-statement client that requests string conversion based on MySQL metadata.

Expected Behavior

Prepared statement result metadata for FLOAT and DOUBLE must preserve the scale behavior required by the MySQL protocol and client libraries. Reading the values as SQL_C_DOUBLE or SQL_C_CHAR must return 12.3, -15.7, and 3.5 without rounding to integers.

Steps to Reproduce

Create data:

CREATE DATABASE IF NOT EXISTS test;
DROP TABLE IF EXISTS test.odbc_double_probe;
CREATE TABLE test.odbc_double_probe(v DOUBLE);
INSERT INTO test.odbc_double_probe VALUES (12.3),(-15.7),(3.5);

Confirm the native text query:

SELECT v FROM test.odbc_double_probe ORDER BY v;

Then prepare and execute the same SELECT through Connector/ODBC 9.7, bind the result as SQL_C_DOUBLE, and fetch all rows. The values are rounded to -16, 4, and 12.

The upstream Connector/ODBC test my_basics.t_bug107307 reproduces the same failure against MatrixOne.

Additional information

A defensive MatrixOne ODBC workaround can bind native MYSQL_TYPE_FLOAT and MYSQL_TYPE_DOUBLE buffers when the server identifies as MatrixOne, bypassing string conversion based on the incorrect decimals metadata. The server metadata still needs correction for other MySQL protocol clients.

Suggested regression coverage:

  • COM_STMT_PREPARE and COM_STMT_EXECUTE metadata for FLOAT and DOUBLE columns.
  • Native numeric and string result bindings.
  • Positive, negative, fractional, zero, NULL, very small, and very large values.
  • Text protocol and binary prepared protocol parity.
  • ODBC SQL_C_DOUBLE and SQL_C_CHAR fetches.

Activity

  1. self-assigned this
    on Aug 4, 2026
  2. added
    ai-easy
    on Aug 6, 2026
  3. Repository owner unassigned on Aug 10, 2026
  4. ghost assigned on Aug 10, 2026
  5. slyunnn commented on Aug 10, 2026

    @slyunnn

    Extended verification for #26682 (2026-08-10)

    Follow-up to the ODBC prepared-statement metadata report: verified FLOAT/DOUBLE decimals metadata and prepared-query
    value behavior after #26709.

    Verification environment

    • MatrixOne branch: main
    • MatrixOne commit: fa0ea95aa77b59a2947159baab31e7215d040e93
      fix(plan): support subqueries in left and right join ON clauses (#26763)
    • Fix under verification: 3639aac46 fix(frontend): report unspecified floating-point decimals (#26709)
    • MOTR branch: test/issue-26682-prepared-double-decimals
    • MOTR commit: 49e6657f2ab678af9724dd2d784659e5e5c2f0f1

    What was covered

    • Frontend binary-protocol tests passed:
      • unspecified FLOAT/DOUBLE metadata reports decimals = 0x1f
      • explicit FLOAT/DOUBLE display scales retain their declared scale
      • numeric prepared aggregates report unspecified DOUBLE metadata correctly
    • MOTR regression passed: 18/18 statements.
      • positive, negative, zero, and NULL FLOAT/DOUBLE values
      • regular SELECT result values
      • prepared table query results
      • parameterized prepared query results
      • prepared CAST parameter results

    Findings

    • fix(frontend): report unspecified floating-point decimals #26709 correctly uses MySQL's DECIMAL_NOT_SPECIFIED sentinel (0x1f) for FLOAT and DOUBLE without an explicit
      display scale.
    • Explicitly scaled FLOAT/DOUBLE columns still report their configured scale.
    • The reproduced fractional values (12.3, -15.7, 3.5) remain unchanged through the SQL prepared-query paths.
    • No regression was found on the latest main branch.

    BVT / topology note

    • MOTR validation ran against an isolated local single-node MatrixOne service.
    • No external ODBC-driver integration was rerun locally; the COM_STMT wire metadata itself is directly covered by the
      frontend binary-protocol unit tests.

    Test-file changes

    • Added issue_26682_prepared_double_decimals.test to pin SQL-level FLOAT/DOUBLE prepared-query behavior.
    • Added the matching .result file as the recorded expected output.
    • No MatrixOne service source code was changed.

    Suggested resolution

    Merge the MOTR regression PR and close #26682 as fixed by #26709.

  6. assigned and unassigned on Aug 10, 2026
  7. assigned and unassigned on Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

ai-easyarea/compatibilitykind/bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions