Bug #112213 BatchUpdateException.getUpdateCounts returns unexpected value -1

Submitted: 29 Aug 2023 16:31 Modified: 20 Oct 2023 16:41
Reporter: Wenqian Deng Email Updates:
Status: Duplicate Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:8.0.33, 8.1.0 OS:Any
Assigned to: CPU Architecture:Any

[29 Aug 2023 16:31] Wenqian Deng
Description:
According to JDBC doc, the array returned by BatchUpdateException.getUpdateCounts should be A number greater than or equal to zero/SUCCESS_NO_INFO(-2)/EXECUTE_FAILED(-3). 
However, in my test case, BatchUpdateException.getUpdateCounts returns -1, -3, which is confusing.

How to repeat:
@Test
public void test() throws SQLException {
    String url = "jdbc:mysql://localhost:3380/test?user=user&password=password&allowMultiQueries=true";
    Connection con = DriverManager.getConnection(url);

    Statement stmt = con.createStatement();
    stmt.execute("DROP TABLE IF EXISTS t0");
    stmt.execute("CREATE TABLE t0(c0 REAL SIGNED PRIMARY KEY NOT NULL) engine=InnoDB");
    stmt.execute("INSERT INTO t0 VALUES (1670697762)");

    Statement bstmt = con.createStatement();
    bstmt.addBatch("INSERT INTO t0 VALUES (1670697762)");
    bstmt.addBatch("INSERT INTO t0 VALUES (697762)");
    try {
        bstmt.executeBatch();
    } catch (BatchUpdateException e) {
        int[] res = e.getUpdateCounts();
        for (int r : res) {
            System.out.println(r);
        }
    }
}
[30 Aug 2023 7:32] MySQL Verification Team
Hello Wenqian Deng,

Thank you for the report and test case.
Verified as described.

regards,
Umesh Shastry
[20 Oct 2023 16:41] Filipe Silva
Duplicate of Bug#110325.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.056 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.