Bug #51004 | MultiQuery from Callable vs Prepared Statements - UpdateCounts are different | ||
---|---|---|---|
Submitted: | 8 Feb 2010 18:23 | Modified: | 25 Feb 2010 15:43 |
Reporter: | Sean Warner | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | Connector / J | Severity: | S3 (Non-critical) |
Version: | 5.1.10 | OS: | MacOS (10.3.9) |
Assigned to: | CPU Architecture: | Any | |
Tags: | CallableStatement, Connector J, jdbc, multiquery, MySQL, PreparedStatement, ResultSet, updatecount |
[8 Feb 2010 18:23]
Sean Warner
[8 Feb 2010 18:26]
Sean Warner
This is the Callable Statement Version
Attachment: UpdateCountA.java (text/plain), 6.43 KiB.
[8 Feb 2010 18:26]
Sean Warner
This is the Prepared Statement Version
Attachment: UpdateCountB.java (text/plain), 5.78 KiB.
[8 Feb 2010 18:27]
Sean Warner
Output from running UpdateCountA.java
Attachment: UpdateCountA - Output.txt (text/plain), 1.23 KiB.
[8 Feb 2010 18:28]
Sean Warner
Output from running UpdateCountB.java
Attachment: UpdateCountB - Output.txt (text/plain), 1.21 KiB.
[11 Feb 2010 1:23]
Mark Matthews
This is intended behavior. It's not a bug (at least not with the JDBC driver). MySQL doesn't return update counts from inside stored procedures to the client. They have to be SELECTed into output variables or returned as result sets by the author of the stored procedure.
[19 Feb 2010 7:27]
Tonci Grgin
Thanks Mark.
[25 Feb 2010 15:43]
Sean Warner
Mark Thank you for your response. My test classes and the text files showing their output clearly illustrate MySQL returning to the client update counts from inside stored procedures. 1. A single update count is ALWAYS returned by MySQL via the Connector J bridge regardless of the number, order or type of SQL statements in the stored procedure. 2. The update count is: 2.1 Zero, if the stored procedure contained no SQL statements that would produce an update count (Insert, Delete, Update). 2.2 Zero, if the last SQL statement in the stored procedure is a SELECT. 3. If the last SQL statement in the stored procedure is an Insert, Delete or Update then the single update count returned contains the number of rows inserted, deleted or updated by this last SQL statement regardless of how many, if any, such statements may have preceded it in the same stored procedure. The Connector J documentation should be updated to highlight this behaviour, even if it is not responsible for it. It should be clearly explained exactly why update counts from MySQL stored procedures don't work as they do from prepared statements and stated that they should not be relied on. Regards, Sean