Skip to content

[Bug]: CONV dispatches DECIMAL, BOOL, and temporal vectors to convString and panics #28461

Closed

Description

@Ariznawlll

Is there an existing issue for the same bug?

  • I have checked the existing issues.

No issue was found for CONV() dispatching fixed-width values to its string executor. #28392 covers numeric-prefix parsing after a valid string argument has already reached CONV().

Branch Name

main

Commit ID

a9d3b8b857c44f1249e682c91d4d62a914eb7d20

Other Environment Information

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

Actual Behavior

CONV() accepts any first-argument type during function binding, but its executor handles only character, integer, unsigned integer, and FLOAT/DOUBLE vectors explicitly. DECIMAL, BOOL, and temporal vectors fall through to convString, which interprets fixed-width vector storage as varlena and raises an internal panic:

SELECT CONV(CAST(15.5 AS DECIMAL(4,1)),10,16);
SELECT CONV(TRUE,10,16);
SELECT CONV(DATE '2024-05-06',10,16);
SELECT CONV(CAST('2024-05-06 12:34:56' AS DATETIME),10,16);
SELECT CONV(CAST('12:34:56' AS TIME),10,16);

Each statement returns error 20101 beginning with:

internal error: panic unsafe slice cast ...

and exposes a Go stack rooted at:

GenerateFunctionStrParameter
convString
Conv

MySQL 8.3 returns, respectively, F, 1, 7E8, 7E8, and C.

All five constant forms and DECIMAL/BOOL/DATE/DATETIME/TIME column forms were repeated three times. Constants panic during constant folding; columns panic during pipeline execution. A SELECT 1 health check succeeds after every group, so the process and connection remain available.

The prepared-marker path has the related type-loss form rather than a panic:

PREPARE s FROM 'SELECT CONV(?,10,16)';
SET @v=TRUE;
EXECUTE s USING @v;
-- MatrixOne: 0
-- MySQL:     1

Expected Behavior

The binder and executor must agree on the permitted first-argument types. MySQL-compatible numeric/temporal values should be converted without an internal error; unsupported types must be cast explicitly or rejected before execution rather than being passed to a string-vector accessor.

Steps to Reproduce

CREATE DATABASE codex_conv_types;
USE codex_conv_types;
CREATE TABLE t(
  id INT PRIMARY KEY,
  d DECIMAL(6,2), b BOOLEAN, dt DATE, dtt DATETIME, tm TIME
);
INSERT INTO t VALUES
  (1,15.5,TRUE,'2024-05-06','2024-05-06 12:34:56','12:34:56'),
  (2,NULL,NULL,NULL,NULL,NULL);

SELECT id,CONV(d,10,16) FROM t ORDER BY id;
SELECT id,CONV(b,10,16) FROM t ORDER BY id;
SELECT id,CONV(dt,10,16) FROM t ORDER BY id;
SELECT id,CONV(dtt,10,16) FROM t ORDER BY id;
SELECT id,CONV(tm,10,16) FROM t ORDER BY id;

Controls

  • Integer, unsigned integer, FLOAT/DOUBLE, and string input paths remain usable.
  • CONV(CAST(dt AS CHAR),10,16) and CONV(YEAR(dt),10,16) return 7E8 in both engines.
  • NULL propagation is correct after a supported argument reaches the executor.
  • The same MatrixOne instance remains healthy after the error.

Activity

  1. added this to the MO-202609 milestone on Sep 9, 2026
  2. added theissue type on Sep 9, 2026
  3. self-assigned this
    on Sep 9, 2026
  4. XuPeng-SH commented on Sep 11, 2026

    @XuPeng-SH
    Contributor

    Implemented in #28650. CONV now dispatches fixed-width typed vectors safely, supports the required BOOL/DECIMAL/temporal semantics, propagates NULL, and cleanly rejects unsupported JSON/UUID inputs instead of reaching a varlena accessor. The prepared BOOL/DECIMAL/temporal path is covered and the standalone server remained healthy after rejection tests.

  5. Ariznawlll commented on Sep 12, 2026

    @Ariznawlll
    CollaboratorAuthor

    已在最新官方 main efb2c5084957ac90273a3f625668fc6a784562c4 验证。

    • 原始场景:表列 DECIMAL、BOOL、DATE、DATETIME、TIME 进入 CONV/BIN 不再走错误的 convString 路径或 panic。
    • Happy path:typed column 查询返回稳定结果,DECIMAL 15.50 的 CONV(...,10,16) 为 F,BOOL/时态的 BIN/CONV 均可执行。
    • 边界控制:后续字符串前缀、prepared CHAR、EXPORT_SET 查询均可继续运行,连接未中断。
    • 自动化:已加入 MOTR PR (aoe)[daily-update]: correct the memory node size #165,issue_28210_28211_28392_28454_28456_28460_28461_functions;三轮复跑 12/12 case、252/252 statements 一致通过。

    测试通过。

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

Metadata

Metadata

Assignees

Labels

area/compatibilitykind/bug

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions