Skip to content

[Bug]: TIMESTAMP(date, time) two-argument overload is rejected #27649

Closed

Description

@Ariznawlll

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Branch Name

main

Commit ID

77c9ae7

Other Environment Information

- Deployment: isolated local single-CN service via MySQL protocol
- Test date: 2026-08-26
- Scope: public SQL compatibility validation; no fault injection

Actual Behavior

On the latest main commit, every two-argument TIMESTAMP(date, time) form is rejected during function resolution.

  • VARCHAR,VARCHAR literal: ERROR 20203: invalid argument function timestamp, bad value [VARCHAR VARCHAR]
  • DATE,TIME(6) column: ERROR 20203: invalid argument function timestamp, bad value [DATE TIME]
  • Prepared SQL SELECT TIMESTAMP(?, ?): PREPARE is rejected with ERROR 20203: invalid argument function timestamp, bad value [TEXT TEXT]

The three paths were each reproduced in 3 independent complete runs (3/3). The unary control SELECT TIMESTAMP('2024-01-15 12:30:00.123456') succeeded in all three runs. No server panic or hang occurred; the temporary table was still readable and cleanup completed.

Expected Behavior

Support MySQL-compatible TIMESTAMP(date, time) composition: accept date and time arguments and return the corresponding TIMESTAMP, with result precision handled according to the documented type rules. This is the remaining compatibility item split from #24504.

Steps to Reproduce

1. Run on main at 77c9ae710c991b219d1aabfb245cb9109dc5cd3c.
2. Execute:

SELECT TIMESTAMP('2024-01-15', '12:30:00.123456');

3. Execute a DATE/TIME column form:

CREATE TEMPORARY TABLE issue_timestamp_pair (d DATE, t TIME(6));
INSERT INTO issue_timestamp_pair VALUES ('2024-01-15', '12:30:00.123456');
SELECT TIMESTAMP(d, t) FROM issue_timestamp_pair;

4. Execute a prepared form:

PREPARE issue_timestamp_pair_stmt FROM 'SELECT TIMESTAMP(?, ?)';

All three forms are rejected with ERROR 20203 before query execution.

Additional information

Code analysis

The function registry lists only one-argument TIMESTAMP overloads (DATE, DATETIME, TIMESTAMP, VARCHAR, CHAR). There is no two-argument overload, so resolution fails before an execution path is selected.

Source:

functionId: TIMESTAMP,

Regression coverage after the fix

Extend test/distributed/cases/function/func_timestamp.test with literal VARCHAR,VARCHAR, DATE/TIME columns, prepared parameters, precision/NULL/invalid-input boundaries. Existing coverage is unary-only.

Related

Split from #24504. The original Feature Request is being closed because this remaining unsupported behavior is tracked independently here.

Activity

  1. added this to the MO-202608 milestone on Aug 26, 2026
  2. added theissue type on Aug 26, 2026
  3. added
    kind/bug
    on Aug 26, 2026
  4. VioletQwQ-0 commented on Aug 27, 2026

    @VioletQwQ-0
    Collaborator

    QA handoff

    • 关联 PR:matrixorigin/matrixone#27722,已合并。
    • PR source exact head:900f28c66a5de7efebce91c6217766d07b69b73b;merge commit:c34f6ed28bc9587e9413d3d2468336fb82ff1407;当前 main:c34f6ed28bc9587e9413d3d2468336fb82ff1407。
    • QA required:yes。该 PR 改变用户可见的 TIMESTAMP(date, time) SQL 兼容语义,需部署环境验收。
    • 自动化证据:exact head 的 CHECK PR VALID、shared build、Ubuntu UT、SCA、UT coverage、Compose/Standalone BVT 及 Mergify merge queue 均为 PASS;PR review/线程门禁已通过并完成合并。
    • 环境边界:TKE BUILD MO DOCKER IMAGE 在 docker/setup-qemu-action 拉取 tonistiigi/binfmt:latest 时因 registry-1.docker.io 返回 EOF 失败,镜像构建及后续 TKE BVT/性能场景未开始;该失败是 registry/runner setup 症状,不是产品 SQL 终态证据。
    • 剩余场景:请在当前 main 上验证 DATE/DATETIME/TIMESTAMP/TIME 及字符、紧凑 DATETIME 输入的两参数结果,覆盖时区、正负跨日、NULL/非法值、上下界、FSP/元数据、prepared statement 和 CTAS;同时确认原有单参数 TIMESTAMP 语义不变。
    • 预期终态:PASS 必须包含版本或 commit、环境/拓扑、执行步骤和完整 SQL 结果,确认有效输入保留正确日期与时分秒、非法或越界输入为 NULL、FSP/可空性及单参数兼容性正确;FAIL 必须包含同样的版本/环境信息、失败步骤、终端结果和日志症状,issue 保持 OPEN。
    • Issue 作者 fresh login 为 Ariznawlll,按规则选择 tester:Ariznawlll。

    Issue 保持 OPEN,已添加 phase/testing,等待 tester 给出包含版本、环境和终态的明确 PASS 或 FAIL。

  5. Ariznawlll commented on Aug 28, 2026

    @Ariznawlll
    CollaboratorAuthor

    测试版本

    • 分支:main
    • commit:e5f26b66195373f9bff512ac9f428788d1c07e8c
    • 部署方式:macOS arm64,本地 standalone Log/TN/CN,使用该 SHA 构建的 mo-service,通过 MySQL 协议执行公开 SQL
    • 测试日期:2026-08-28

    原问题验证

    重新执行原始两参数 TIMESTAMP(date, time) 场景。TIMESTAMP('2024-01-15', '12:30:00.123456') 正确返回 2024-01-15 12:30:00.123456;DATE/TIME 列组合及 SQL PREPARE 两参数形式也均可正常执行,不再出现 ERROR 20203 ... bad value [VARCHAR VARCHAR]。新增回归用例连续执行 3/3 通过,随后单独复跑及所在套件执行也通过。

    Happy Path 覆盖

    1. 输入组合:字符 literal、DATE + TIME(6)、DATETIME(3) + TIME(0)、TIMESTAMP(3) + TIME(6),日期、时间和 FSP 均正确。
    2. 正负跨日:2024-01-02 + -25:00:00 返回 2023-12-31 23:00:00;2024-01-01 23:30:00 + 02:00:00 返回 2024-01-02 01:30:00。
    3. 紧凑输入:20240115120000.123456 和 123000 均按预期解析。
    4. SQL PREPARE:同一 statement 按 value、NULL、value 顺序复用,分别返回正确值、NULL 和正确值,deallocate 正常。
    5. CTAS 元数据:结果列分别为 DATETIME(6)、DATETIME(0)、DATETIME(1)、DATETIME(6),可空性均为 YES。
    6. 时区:会话从 +00:00 切换到 +08:00 后,TIMESTAMP 输入组合返回 2024-01-15 20:30:00.123456。
    7. 原单参数 TIMESTAMP('2024-01-15 12:30:00') 仍返回原值,兼容行为未改变。

    Unhappy Path 覆盖

    1. date 为 NULL、time 为 NULL:结果均为 NULL。
    2. 非法日期、非法时间及空字符串:结果均为 NULL,未出现解析 panic。
    3. 上界 9999-12-31 23:59:59.999999 + 1us 和下界 0001-01-01 - 1us:结果均为 NULL。
    4. prepared statement 在 NULL 执行后可继续使用有效参数,未残留错误参数状态。
    5. 多轮执行期间未发现 panic、hang 或服务异常退出,测试数据库及 prepared statement 均正常清理。

    白盒验证

    不适用。本 Issue 是公开 SQL 函数解析、执行及结果元数据问题,已通过真实 MySQL 协议端到端覆盖,无需故障注入。

    回归测试

    测试证据

    • 新增用例三轮:3/3 case、78/78 statements 通过。
    • 最终定向复跑:26/26 statements 通过。
    • 所在 14_issue_regression 全套:本用例 26/26 statements 通过。
    • 历史版本 b0ae66c0 可复现 ERROR 20203: invalid argument function timestamp, bad value [VARCHAR VARCHAR];上述 latest main 不再复现。

    测试结论

    测试通过。

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

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions