Defer prepared statement long data writes - #1810
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. Walkthrough
ChangesStatement execution
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to Prepared-statement long data is now validated before transmission and recovers protocol state after write failures. The covered behavior introduces no identified merge-blocking risk. Sequence Diagram(s)sequenceDiagram
participant writeExecutePacket
participant mysqlStmt
participant Connection
writeExecutePacket->>mysqlStmt: Validate arguments and packet size
writeExecutePacket->>Connection: Send COM_STMT_SEND_LONG_DATA
Connection-->>writeExecutePacket: Return write result
writeExecutePacket->>Connection: Send COM_STMT_EXECUTE
writeExecutePacket->>mysqlStmt: Reset after long-data write error
mysqlStmt->>Connection: Send COM_STMT_RESET
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Description
This pull request refactors the handling of "long data" parameters in prepared statement execution to ensure all arguments are validated before any data is sent to the MySQL server. This prevents partial writes and improves error handling. The changes also add comprehensive tests to verify correct behavior in various edge cases.
Prepared Statement Execution Improvements:
writeExecutePacketto collect long data parameters first, validate all arguments and packet size, and only write to the server after validation passes. This prevents partial long data writes if an argument is invalid or the packet is too large. [1] [2] [3] [4] [5]resetmethod tomysqlStmtto reset the statement on the server if a long data write fails, ensuring the server state remains consistent.Testing Enhancements:
packets_test.goto verify:mockConntest helper to support write error injection and tracking. [1] [2]These changes make prepared statement execution more robust and the codebase better tested.
Checklist