Skip to content

[Bug] prepared statement execution panics after column ADD followed by RENAME #25600

Closed

Description

@Ariznawlll

Summary

Executing a SQL prepared statement after a column ADD followed by a column RENAME can panic with an unsafe slice cast.

Reproduction

At commit 7821d21c723372e45a8f65da3bbb896a157b1036:

drop database if exists pddl;
create database pddl;
use pddl;
create table t (id int primary key, payload varchar(20));
insert into t values (1, 'x');
prepare ps from 'select payload from t where id=?';
set @id = 1;
execute ps using @id;
alter table t add column extra int;
execute ps using @id;
alter table t rename column payload to payload2;
execute ps using @id;

The final EXECUTE returns ERROR 20101 internal error: panic unsafe slice cast: from length 4 is not enough for length 24. The stack includes pkg/container/vector/vector.go:2530 and pkg/vm/engine/disttae/local_disttae_datasource.go:887.

The same failure is reproducible on a normal table (no publication), so this appears to be a prepared-plan/DDL invalidation issue rather than a publication-only problem.

Expected

The prepared statement should be invalidated/replanned or return a normal schema error; it must not panic the server.

Activity

  1. added
    kind/bug
    ai-light
    and removed
    ai-light
    on Jul 11, 2026
  2. added this to the MO-202607 milestone on Jul 11, 2026
  3. added theissue type on Jul 11, 2026
  4. added
    severity/s0
    and removed on Jul 12, 2026
  5. added a commit that references this issue on Jul 13, 2026
    6b4e44c
  6. assigned and unassigned on Jul 14, 2026
  7. Ariznawlll commented on Jul 14, 2026

    @Ariznawlll
    CollaboratorAuthor

    已在最新 main 上按 issue SQL 顺序验证 prepared statement + ADD/RENAME。

    验证版本

    • Commit:0977fc07c51067ce76b769c7853d7374cb2fccec
    • git_version():0977fc07c
    • 验证时间:2026-07-14

    实际过程与结果

    • 初始 prepared VARCHAR 查询返回 x。
    • ADD COLUMN extra INT 后再次执行仍返回 x。
    • RENAME COLUMN payload TO payload2 后执行旧 statement,返回普通错误:column 't.payload' does not exist。
    • 整个过程中没有 ERROR 20101,没有 panic unsafe slice cast,服务保持可用。

    结论

    当前 main 会使引用旧列名的 prepared plan 失效,而不是继续使用错误的 vector/ordinal 做 unsafe slice cast。issue 中的生产代码 panic 路径未再复现。

    #25600 verification

  8. Ariznawlll commented on Jul 14, 2026

    @Ariznawlll
    CollaboratorAuthor

    已将本 issue 的黑盒回归加入 matrixorigin/motr#48。

    MOTR 用例

    黑盒过程与断言

    1. 创建 VARCHAR 列并 PREPARE SELECT;
    2. 首次 EXECUTE 检查返回 x;
    3. ADD COLUMN 后再次 EXECUTE,仍检查返回 x;
    4. RENAME COLUMN payload TO payload2 后执行旧 prepared statement;
    5. 允许返回正常的 column/schema error,但不允许出现历史上的 unsafe slice cast panic;
    6. 最后用 fresh SQL 检查 payload2='x',确认表数据没有被破坏。

    运行结果

    在 MO main@0977fc07c51067ce76b769c7853d7374cb2fccec 上连续 3 轮均通过,整套并发回归也通过。

    MOTR PR #48 black-box regression output

  9. added 3 commits that reference this issue on Sep 17, 2026
    3d70fc2
    2b8ff58
    b104169
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

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions