You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug] prepared statement execution panics after column ADD followed by RENAME #25600
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:
dropdatabase if exists pddl;
createdatabasepddl;
use pddl;
createtablet (id intprimary 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;
altertable t add column extra int;
execute ps using @id;
altertable 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
fix: invalidate prepared statements on newer table versions (#25670)
Ariznawlll commentedon Jul 14, 2026
已在最新
main上按 issue SQL 顺序验证 prepared statement + ADD/RENAME。验证版本
0977fc07c51067ce76b769c7853d7374cb2fccecgit_version():0977fc07c实际过程与结果
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 路径未再复现。
Ariznawlll commentedon Jul 14, 2026
已将本 issue 的黑盒回归加入
matrixorigin/motr#48。MOTR 用例
14_issue_regression.issue_25600_prepared_add_rename_panicissue_25600_prepared_add_rename_panic.test黑盒过程与断言
VARCHAR列并 PREPARE SELECT;x;ADD COLUMN后再次 EXECUTE,仍检查返回x;RENAME COLUMN payload TO payload2后执行旧 prepared statement;unsafe slice castpanic;payload2='x',确认表数据没有被破坏。运行结果
在 MO
main@0977fc07c51067ce76b769c7853d7374cb2fccec上连续 3 轮均通过,整套并发回归也通过。fix: invalidate prepared statements on newer table versions (matrixor…
fix: invalidate prepared statements on newer table versions (matrixor…
fix: invalidate prepared statements on newer table versions (matrixor…