[CONJ-598] UpdateCount for prepared statements retrieved after closing the statement Created: 2018-04-30  Updated: 2021-02-25  Resolved: 2021-02-25

Status: Closed
Project: MariaDB Connector/J
Component/s: batch
Affects Version/s: 2.2.3, 1.7.3
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Robert Borys Assignee: Diego Dupin
Resolution: Fixed Votes: 0
Labels: None


 Description   

Look at: org.mariadb.jdbc.MariaDbPreparedStatementClient#executeBatch():

executeInternalBatch(size);
results.commandEnd();
return results.getCmdInformation().getUpdateCounts();

Calling commandEnd() before getUpdateCounts() (for CmdInformationBatch) causes the latter returning a value like [-2, -2, -2, ...] so no actual count is returned. But when you change the order (getUpdateCounts() before commandEnd()) then the first element of returned array contains actual update count.

I'm not sure whether that change would lead to other problems.

A similar situation is in executeLargeBatch().



 Comments   
Comment by Diego Dupin [ 2021-02-08 ]

Long time after task creation, but could you indicate the connection string option ?
this is probably because option `rewriteBatchedStatements` has been send.
getUpdateCounts -2 is a valid value ( = Statement.SUCCESS_NO_INFO) meaning that connector confirm that command execute successfully, but that the exact number of update count per batch is unknown.

Comment by Robert Borys [ 2021-02-20 ]

Hello. Unfortunately, I can't remember and I don't have access to affected code anymore.

As far as I remember we solved our issue by switching to MySQL Connector/J 8.0.x.

Comment by Diego Dupin [ 2021-02-25 ]

too bad.
you will have a less performant driver

closing issue then, since not reproduced

Generated at Thu Feb 08 03:16:56 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.