Skip to content

[Bug]: binary FLOAT prepared parameter in an integer comparison raises cast-to-int error #29464

Closed

Description

@XuPeng-SH

Reproduction

Discovered while deeply reviewing #29462 / #29429. This is separate from serialized composite-key bug #29463: a plain integer column with no index also fails.

Confirmed on clean pre-PR commit a99db843c7b4630a86883addc9424433d93fc2d2 using a real JDBC server-side prepared statement:

create table t(k int);
insert into t values (2), (3);

Use Connector/J with useServerPrepStmts=true, prepare select k from t where k > ? order by k, bind with PreparedStatement.setDouble(1, 2.5), and execute.

Actual: invalid argument cast to int, bad value 2.5.
Expected: one row, 3, without a conversion error. Equality with the same value should return no rows. Both k = ? and k + 0 = ? also raise this error on that commit.

Cause and fix under validation

The prepare-time integer CAST is provisional, but the execution admission detects text comparison specialization and overlooks FLOAT packets. The cached integer expression then consumes the decoded 2.5 transport text.

Working correction in #29462: collect numeric comparison parameter positions once per prepared-plan generation and route FLOAT bindings through the existing runtime specialization, preserving their numeric domain. No new runtime plan cache is added. Real binary/text protocol tests exercise equality, ranges and IN, primary/composite/secondary-key shapes, and later integer bindings on the same handle. Validation is in progress; this issue is not yet claimed fixed.

Activity

  1. self-assigned this
    on Sep 29, 2026
  2. added
    kind/bug
    severity/s0
    on Sep 29, 2026
  3. added a commit that references this issue on Sep 29, 2026
    a36da7f
  4. Ariznawlll commented on Oct 2, 2026

    @Ariznawlll
    Collaborator

    测试版本

    • 分支:main
    • Commit:d50a2d475a406829f67127fef7b2ad4abc1c1d3d
    • 部署方式:本地全新单 CN mo-service,独立数据目录;Go MySQL driver 的真实 COM_STMT 二进制协议
    • 测试日期:2026-10-02

    原问题验证

    按 issue 原始语义在上述 commit 重新执行并重复 3 次。真实 COM_STMT binary protocol 下 float64(2.5) 的范围查询返回 [3,4],等值为空,IN 返回 3;随后 int/NULL 重绑仍正常。

    Happy Path 覆盖

    覆盖 equality、range、IN 和连续三轮 statement reuse。

    Unhappy Path 覆盖

    覆盖 NULL、整数重绑和不命中值;参数类型切换后连接/statement 未被污染。

    白盒验证

    关联修复 #29462 已进入当前 main。同时将本 issue 的可公开观察契约固化为独立回归,避免只依赖实现细节或共享测试间接判断。

    回归测试

    测试证据

    • 精确测试版本:d50a2d475a406829f67127fef7b2ad4abc1c1d3d
    • 当前结果:真实 COM_STMT binary protocol 下 float64(2.5) 的范围查询返回 [3,4],等值为空,IN 返回 3;随后 int/NULL 重绑仍正常。
    • 回归代码与 golden result 已提交到 MOTR #209;本地全量 14_issue_regression 中观察到的旧 GOROOT/历史 golden/并发锁冲突属于既有无关失败,以上新增用例单独重跑均稳定通过。

    测试结论

    测试通过。

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

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions