Repository navigation
Description
Summary
On latest main (7e70bee98), after a binary-protocol prepared UPDATE updates a BLOB column, a binary-protocol prepared SELECT hex(b) can return empty strings for BLOB values, while the same data is correct when queried through the MySQL CLI / text protocol.
This was found during protocol-level prepared statement exploration with Go database/sql + go-sql-driver/mysql (db.Prepare, i.e. COM_STMT_PREPARE), comparing MySQL 8.0.45 and MatrixOne.
Environment
- MatrixOne: latest
mainat7e70bee98 - MySQL oracle: MySQL 8.0.45
- Driver:
github.com/go-sql-driver/mysql v1.8.1 - Path: binary-protocol prepared statement (
db.Prepare), not SQL-levelPREPARE ... FROM
Reproduce
Table/data setup:
drop database if exists pp_json_blob_seq;
create database pp_json_blob_seq;
use pp_json_blob_seq;
create table t (
id int primary key,
j json,
txt text,
b blob,
d decimal(12,4),
tm time(6),
status varchar(20),
key idx_status_d(status,d)
);
insert into t values
(1,'{"a":1,"b":"x"}','hello',x'414243',12.3456,'10:20:30.123456','new'),
(2,'{"a":2,"b":null}',null,null,null,null,'new'),
(3,null,'bye',x'00ff',-1.2500,'-01:02:03.000000','old');Run the following via Go database/sql prepared statements:
// Before update: prepared SELECT returns correct hex(b).
db.Prepare("select id, hex(b) from t order by id")
stmt, _ := db.Prepare("update t set d=?, tm=?, b=? where id=?")
stmt.Exec("88.1250", "08:08:08.000001", []byte{0x88, 0x12}, 2)
// After update: prepared SELECT returns wrong hex(b) on MO.
db.Prepare("select id,d,tm,hex(b) from t order by id")Expected
MySQL 8.0.45 returns:
before:
1 414243
2 NULL
3 00FF
after prepared UPDATE:
1 12.3456 10:20:30.123456 414243
2 88.1250 08:08:08.000001 8812
3 -1.2500 -01:02:03.000000 00FF
Actual on MatrixOne
Before the prepared UPDATE, the prepared SELECT is correct:
1 414243
2 NULL
3 00FF
After the prepared UPDATE, protocol prepared SELECT returns empty hex values for rows 1 and 2:
1 12.3456 10:20:30.123456 <empty>
2 88.1250 08:08:08.000001 <empty>
3 -1.2500 -01:02:03.000000 00FF
However, querying the same table through the MySQL CLI / text protocol returns the correct values on MO:
1 12.3456 10:20:30.123456 414243
2 88.1250 08:08:08.000001 8812
3 -1.2500 -01:02:03.000000 00FF
So the stored data appears correct; the wrong result is specific to the binary-protocol prepared SELECT path after a prepared UPDATE involving BLOB data.
Related issues
- [Bug]: protocol prepared UPDATE corrupts indexed readback for VARBINARY and BIGINT UNSIGNED #25437 covers a different protocol prepared UPDATE readback problem involving indexed/point predicates and
VARBINARY/BIGINT UNSIGNEDprojections. - [Bug]: Binary-protocol COM_STMT_PREPARE rejects REPLACE (missing replace_stmt in prepareable_stmt grammar) #25429 covers COM_STMT_PREPARE rejecting
REPLACEgrammar. - [Bug]: Prepared CTAS rejects parameter markers in SELECT expression #25425 covers prepared CTAS parameter marker rejection.
I did not find an existing issue for this BLOB/HEX prepared SELECT behavior.
Activity
ck89119 commentedon Jul 11, 2026
Verified end-to-end against the current
mainproduction code usingdatabase/sqlwithgo-sql-driver/mysqland protocol-level prepared statements.The issue is no longer reproducible. After executing the prepared update:
The subsequent prepared SELECT returns:
A direct text-protocol SELECT returns the same values.
The root cause is the binary-protocol TIME microsecond width bug fixed by commit
5fe5e46fcin #25448: the encoder previously wrote the 4-byte microsecond field as 8 bytes, shifting the client-side decode offset for subsequent columns such ashex(b). Therefore, this issue is already fixed on currentmain.Ariznawlll commentedon Jul 13, 2026
已在最新
main@2865ed6cc8a39727b8b274bb52b88fe441d0b30c重新做 protocol-level 端到端验证,结果通过。database/sql+go-sql-driver/mysql v1.8.1,interpolateParams=false,固定单物理连接。TIME(6)和 BLOB 后,同一个 prepared SELECT 连续执行 3 次;hex(b)依次为414243 / 8812 / 00FF。hex(b)同时放在TIME(6)前后,覆盖列解码 offset,两个投影值始终一致。确认 #25448 的 TIME 微秒宽度修复已覆盖本问题,当前 main 不再复现。