Description
Is there an existing issue for the same bug?
- I have checked the existing issues.
Searched issues for:
"CREATE TABLE" "SELECT ?" "prepare""CTAS" "prepare""only prepare statement can use ? expr""create table" "as select" "prepared"
No exact duplicate was found.
Branch Name
main
Commit ID
51656deb6003
Other Environment Information
- MatrixOne:
select version()returns8.0.30-MatrixOne-v1.3.0 - MySQL comparison:
8.0.45 - SQL-level
PREPARE/EXECUTEthrough mysql client.
Actual Behavior
MatrixOne rejects parameter markers inside CTAS when the CTAS statement is prepared:
ERROR 20301 (HY000): invalid input: only prepare statement can use ? expr
ERROR 20400 (HY000): invalid state prepared statement 's_ctas_param' does not exist
Control checks on the same MatrixOne build:
prepare s_select from 'select ? as c'works.prepare s_ctas_no_param from 'create table t_no_param as select 1 as c'works.- Only
prepare s_ctas_param from 'create table t_param as select ? as c'fails.
MySQL supports the parameterized CTAS prepared statement and creates the table successfully.
Expected Behavior
Same as MySQL: parameter markers in the query expression of a prepared CTAS should be accepted and bound at EXECUTE time.
Steps to Reproduce
drop database if exists mysql_compat_prepare_ctas_min;
create database mysql_compat_prepare_ctas_min;
use mysql_compat_prepare_ctas_min;
select 'select_param' as q;
prepare s_select from 'select ? as c';
set @p=1;
execute s_select using @p;
deallocate prepare s_select;
select 'ctas_no_param' as q;
prepare s_ctas_no_param from 'create table t_no_param as select 1 as c';
execute s_ctas_no_param;
select * from t_no_param;
deallocate prepare s_ctas_no_param;
select 'ctas_param' as q;
prepare s_ctas_param from 'create table t_param as select ? as c';
set @p=1;
execute s_ctas_param using @p;
select * from t_param;
deallocate prepare s_ctas_param;MySQL result:
q
select_param
c
1
q
ctas_no_param
c
1
q
ctas_param
c
1
MatrixOne fails at the prepare s_ctas_param ... statement.
Additional information
A broader CTAS repeated-execute probe also showed MySQL can re-execute a prepared CTAS after dropping the target table and infer the CTAS column metadata from each execution parameter values. MatrixOne currently cannot reach that stage because the parameterized CTAS cannot be prepared.
Activity
Ariznawlll commentedon Jul 3, 2026
Additional coverage on latest main
49842fb04: the same prepared CTAS limitation also reproduces when the parameter marker is in the CTAS query predicate, not only in the SELECT expression.Repro:
MySQL 8.0.45 creates
ctas_preparedwith the twog=1rows. MatrixOne latest main rejects thePREPAREstatement with:So this issue covers CTAS parameter markers in the prepared SELECT subtree more broadly, including WHERE predicates.
Ariznawlll commentedon Jul 6, 2026
Additional prepared CTAS coverage on latest main
781161fabstill reproduces this issue with multiple parameter markers in the CTAS select list.Repro shape:
MySQL 8.0.45 creates
ctas_pand returns7 | hello.MatrixOne latest main rejects the prepared statement with:
No separate issue opened; this is another shape of the same prepared CTAS parameter-marker limitation tracked here.
Ariznawlll commentedon Jul 8, 2026
Revalidated as part of the remaining CTAS/view exploration on latest
mainatec01c62e4.The prepared CTAS limitation still reproduces with multiple parameter markers and mixed return types:
MySQL creates the table and returns:
MatrixOne still fails with:
Ariznawlll commentedon Jul 22, 2026
最新
main回归结果(2026-07-22):问题仍可复现。c0486a2446c84c6dd6bf142494fe85243877ddc58.0.30-MatrixOne-v1.3.08.0.45PREPARE ... FROM 'CREATE TABLE ... AS SELECT ... WHERE n >= 20'可正常创建并返回预期数据。PREPARE ... FROM 'CREATE TABLE ... AS SELECT ... WHERE n >= ?'在 MatrixOne 中返回ERROR 20301 (HY000): invalid input: only prepare statement can use ? expr,MySQL 可正常执行并返回预期数据。结论:最新
main尚未修复。fix(plan): support parameters in prepared CTAS (#26003)
jiangxinmeng1 commentedon Jul 23, 2026
fixed by #26003
Ariznawlll commentedon Jul 23, 2026
最新 main 验证结果:通过
测试版本:MatrixOne
main@ebd05ba52f0d08afb4225e7b4b2e97e8030c057d测试步骤
CREATE TABLE ... AS SELECT ...。COALESCE表达式以及删除后重新创建。实际结果
?参数的 CTAS 可以成功 PREPARE 和 EXECUTE。7。COALESCE和第二次重建均得到预期数据。回归用例
14_issue_regression.issue_25425_prepared_ctas_params5c7c1e5bbfa9f5f03c339a34fb931a4a2e2a946d结论:prepared CTAS 参数处理在最新 main 上正常,验证通过。
fix(plan): support parameters in prepared CTAS (matrixorigin#26003)
fix(plan): support parameters in prepared CTAS (matrixorigin#26003)
fix(plan): support parameters in prepared CTAS (matrixorigin#26003)