Repository navigation
Description
Is there an existing issue for the same bug?
- I have checked the existing issues.
Searched open/all issues for:
"COM_STMT_PREPARE""binary protocol""mysql.connector""prepared=True""MySQL server has gone away" "prepared"
Related but not duplicate:
- [Tracking]: MySQL connector compatibility for Metabase and Power BI #24161 / [Compatibility] Power BI cannot connect to MatrixOne via MySQL connector #24162 track broad BI connector compatibility, but do not provide a minimal protocol-level prepared statement repro.
- [Bug]: Prepared statements don't error on division by zero in strict mode #23438 is closed and about SQL prepared division-by-zero behavior, not the MySQL binary prepared protocol.
Branch Name
main
Commit ID
51656deb6003
Other Environment Information
- MatrixOne:
select version()returns8.0.30-MatrixOne-v1.3.0 - MySQL comparison:
8.0.45 - Client:
mysql-connector-pythonin Python, usingcursor(prepared=True). - Text-protocol queries from the same connector work against MatrixOne.
Actual Behavior
Protocol-level prepared statements fail against MatrixOne. A simple select ? + ? using mysql-connector-python with cursor(prepared=True) returns:
DatabaseError 2006 (HY000): MySQL server has gone away
The same query succeeds against MySQL 8.0.45 and returns 3.
Control check against MatrixOne:
- mysql CLI text protocol works:
select version(), 1+2returns normally. mysql-connector-pythonnon-prepared cursor also works:cursor(prepared=False).execute('select %s + %s', (1, 2))returns3.
So this appears specific to the MySQL protocol prepared-statement path (COM_STMT_PREPARE / binary protocol), not a general connection or SQL execution failure.
Expected Behavior
Same as MySQL: protocol-level prepared statements should prepare and execute successfully. This is needed by MySQL-compatible drivers and applications that use server-side prepared statements.
Steps to Reproduce
import mysql.connector
# MySQL succeeds with the same code.
cn = mysql.connector.connect(
user='dump',
password='111',
host='127.0.0.1',
port=7002,
connection_timeout=5,
)
cur = cn.cursor(prepared=True)
cur.execute('select ? + ?', (1, 2))
print(cur.fetchall())
cur.close()
cn.close()MatrixOne result:
DatabaseError 2006 (HY000): MySQL server has gone away
MySQL 8.0.45 result:
[(3.0,)]
Additional information
This was found during Model 14 prepared-statement compatibility exploration. SQL-level PREPARE s FROM ... was tested separately; this issue is specifically for driver-level prepared statements using the MySQL binary protocol.
Activity
hiSandog commentedon Jul 6, 2026
A useful test here would cover both the normal
"COM_STMT_PREPARE"path and the edge case from this report. That should make it clear whether the fix belongs in input normalization/validation, configuration forwarding, or the lower-level execution path.fix: T_any param breaks DIV type cast, Decimal64 overflow, and ANY→UU…
fix: promote T_text ParamRef args to float64 for arithmetic operators (…
ck89119 commentedon Jul 23, 2026
Verified on the latest
mo/mainat1ac64a870e2c0a6344c1dc43a6d1dbf39c907385.The original reproduction no longer fails:
mysql-connector-python 9.4.0cursor(prepared=True)select ? + ?(1, 2)[(3.0,)]The connection remained healthy; there was no
DatabaseError 2006or disconnect duringCOM_STMT_PREPARE/COM_STMT_EXECUTE.Additional validation on the same
maincommit:TestIssue25753PreparedNumericProtocolLifecyclepassed. This exercises the real TCPCOM_STMT_PREPARE -> COM_STMT_EXECUTE -> COM_STMT_CLOSElifecycle, statement reuse, parameter transport types,NULL, conversion-error recovery, and closed-statement behavior.TestPreparedNumericContextParameterTypespassed, including the originalselect ? + ?planner case with both parameters resolved toDOUBLE.make buildpassed.96847b5a63642c45c541b96055e5320f9c04a295) and test(frontend): cover prepared numeric protocol lifecycle #25893 (c3a679182e0f73dae9c20174f1d592a8dbd81c0f) are both ancestors of the testedmo/maincommit.Conclusion: the issue is fixed on current
main. #25788 contains the numeric parameter-type fix, and #25893 provides the protocol-level regression coverage. This issue can be closed as fixed.Ariznawlll commentedon Jul 23, 2026
最新 main 验证结果:通过
测试版本:MatrixOne
main@ebd05ba52f0d08afb4225e7b4b2e97e8030c057d测试步骤
mysql-connector-python创建prepared=Truecursor。select ? + ?,读取结果。database/sql建立真实协议连接,连续执行 prepared statement 20 次,并在执行后检查连接仍可用。实际结果
[(3.0,)],连续 3 轮通过。回归用例
14_issue_regression.issue_25423_protocol_prepared_cursor5c7c1e5bbfa9f5f03c339a34fb931a4a2e2a946d结论:prepared cursor 的二进制协议执行已恢复正常。