Skip to content

[Compatibility]: prepared TIME arithmetic rejects numeric parameters #28963

Closed

Description

@XuPeng-SH

Reproduction

On current main / PR #28957 head:

CREATE TABLE t1(t TIME(3));
INSERT INTO t1 VALUES (0.001), (34.5);
PREPARE s1 FROM 'SELECT t * ? FROM t1';
SET @p = 10;
EXECUTE s1;

The prepared expression fails during binding with:

invalid argument operator *, bad value [TIME TEXT]

The equivalent ordinary SQL expression SELECT t * 10 FROM t1 succeeds and returns the expected fractional values.

Scope

This is separate from #28953's historical decimal-literal normalization regression and from the regression-coverage update in #28957. The current base's prepared parameter inference/coercion path treats the parameter as TEXT and does not resolve it against the TIME operand for arithmetic. Determine the intended prepared/runtime type contract before changing the binder or arithmetic resolver, then add ordinary and prepared regression coverage.

Related: #28953, #28957.

Activity

  1. self-assigned this
    on Sep 16, 2026
  2. added
    kind/bug
    on Sep 16, 2026
  3. Ariznawlll commented on Sep 20, 2026

    @Ariznawlll
    Collaborator

    测试版本

    原问题验证

    在 MySQL 协议 prepared-statement 路径验证 TIME 与数值算术。TIME(0) 及 TIME(6) 参数在有符号整数、DECIMAL、浮点参数下均返回正确结果;同一 prepared statement 更换参数类型后结果正确,连续执行 3 次通过。

    覆盖范围

    1. SQL PREPARE/EXECUTE 和二进制协议 prepared statement。
    2. TIME(0) 与 TIME(6)。
    3. 有符号整数、DECIMAL 和 DOUBLE 参数。

    边界与异常路径

    1. NULL 参数保持 NULL 语义。
    2. 溢出参数返回预期转换错误,不会复用前一次执行的结果或状态。

    自动化回归

    • motr#193 新增 issue_28963_prepared_time_arithmetic.test。
    • MOTR 目标集连续运行 3 轮,共 33/33 成功;MySQL 协议 Go 集成测试也通过。

    测试结论

    测试通过。

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

Metadata

Metadata

Assignees

Labels

kind/bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions