Repository navigation
Description
Description
Prepared INSERTs into a MySQL SET column reject normal label strings such as
a or a,b by trying to convert them to an unsigned integer. Numeric SET
indexes still work. Literal SQL, Connector/J client-prepared statements, and
MySQL server-prepared statements accept the same label values.
The failure affects both MySQL binary-protocol prepared statements and SQL
PREPARE / EXECUTE.
Environment
- Branch:
main - Commit:
47e022e10f2dbdf5f6b440417f8be80908027e63 - Deployment: local
mo-service, 1 Log / 1 TN / 1 CN - Connector/J: 8.0.33 and 8.0.15
- JDBC server path:
useServerPrepStmts=true,cachePrepStmts=false,
emulateUnsupportedPstmts=false - Control: MySQL 8.0.46
Steps to reproduce
create database prepared_set_repro;
use prepared_set_repro;
create table t(id int primary key, tags set('a','b','c'));JDBC binary prepared statement:
try (PreparedStatement ps = connection.prepareStatement(
"insert into t(id,tags) values (?,?)")) {
ps.setInt(1, 1);
ps.setString(2, "a,b");
ps.executeUpdate();
}SQL prepared statement:
prepare p from 'insert into t(id,tags) values (?,?)';
set @id = 2, @tags = 'a,b';
execute p using @id, @tags;Actual behavior
Both prepared paths fail without inserting a row:
SQLState HY000 / error 20203
invalid argument cast to uint64, bad value a,b
setString("a") fails in the same way. Binding integer 3, or the numeric
string "3", succeeds and stores a,b.
Expected behavior
Prepared INSERT should apply normal MySQL SET assignment semantics and store
label strings such as a and a,b. MySQL 8.0 accepts both values through the
same binary and SQL prepared paths.
Stability and controls
- MatrixOne binary server-prepared reproduction: 3/3 with Connector/J 8.0.33.
- MatrixOne SQL
PREPAREreproduction: 3/3. - Connector/J 8.0.15: same MatrixOne failure in 3/3 runs.
- MatrixOne
useServerPrepStmts=false: label INSERT succeeds in 3/3 runs. - MatrixOne literal
INSERT ... 'a,b': succeeds. - MySQL 8.0.46 server/client prepared and SQL prepared controls: all succeed in
3/3 runs. - Failed executions leave no partial row; the connection remains usable.
- ENUM label INSERT is a passing control.
Code analysis
MatrixOne represents a SET column with a uint64 storage type plus its member
definition. The special assignment conversion is selected in
pkg/sql/plan/make.go (funcCastForSetType) from the prepare-time expression
type. In this path the late-bound string reaches numeric index conversion,
which is consistent with the exact cast to uint64 error and with integer
bindings succeeding. The fix should preserve label conversion for string
bindings while retaining numeric-index semantics.
Regression coverage
Add real binary-protocol and SQL prepared regressions for single and multiple
SET labels, numeric indexes, NULL, invalid labels, repeated rebinding, batch
INSERT, and recovery after a rejected value. Keep literal/client-prepared and
MySQL-compatible stored-value controls.
Related
- [Bug]: binary prepared ENUM/YEAR covering-index queries fail with unsupported type #26873 concerns ENUM/YEAR covering-index extraction, not SET assignment.
- [Bug]: server-prepared ParameterMetaData reports NULL for all parameters #27328 concerns input parameter metadata, not SET value conversion.
Activity
Ariznawlll commentedon Aug 25, 2026
补充在最新
main的 SQLPREPARE/EXECUTE复现:e866c535f5723fca6a8522c8338f7277e4b9e40fmo-service,1 Log / 1 TN / 1 CN,临时全新数据目录3/3。每轮失败后表中只保留
2 | x,z和3 | x,z,说明失败写入没有部分落盘;随后SELECT 1也正常,服务保持可用。该结果与本 issue 的 INSERT 路径结论一致。Ariznawlll commentedon Aug 25, 2026
测试版本
原问题验证
以 SET('a','b') 列和参数值 a,b 验证,两个驱动各连续执行 3 轮:
Happy Path 覆盖
Unhappy Path 覆盖
白盒验证
不适用。本次通过 JDBC 服务端 PREPARE 外部接口复现;本 issue 既有 uint64 转换路径分析可解释该错误。
回归测试
未新增回归用例。该路径尚未修复,不能将标签字符串失败固化为成功基线。
测试证据
两代 Connector/J 各 3 轮,共 6/6 轮稳定复现;文字 SQL、客户端 PREPARE 和数值索引路径均作为对照执行。
测试结论
测试不通过。
XuPeng-SH commentedon Oct 22, 2026
This report is now tracked together with #27332. The canonical issue retains explicit acceptance cases for the behavior described here. This is an administrative duplicate/consolidation closure only; the underlying defect is not claimed fixed. The original description and discussion remain available on this issue.