Uploaded image for project: 'MariaDB Connector/J'
  1. MariaDB Connector/J
  2. CONJ-630

No method returns update counts in batch mode

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Duplicate
    • 2.2.6
    • 2.3.0
    • batch
    • None
    • Java 8, Windows 10, MariaDB 10.2.13

    Description

      When executing a batch of UPDATE/DELETE statements using PreparedStatement.executeBatch(), there is no method that returns update counts.
      1) PreparedStatement.executeBatch() returns int[], but all values are -2 (meaning SUCCESS but not the real number of updated/deleted records)
      to get at least the total number of updated/deleted records, one can call:
      2) PreparedStatement.getUpdateCount() - returns -1
      3) PreparedStatement.getLargeUpdateCount() - returns -1
      Note that the same method (getLargeUpdateCount) returns the correct value with driver 2.1.0, which is our current workaround.
      Therefore we cannot upgrade the driver due to this bug!

      Attachments

        Issue Links

          Activity

            diego dupin Diego Dupin added a comment -

            By default, the driver now uses a new bulk command that executes batch a lot faster. The main default is that connector then just now the total results of the batch.

            Example for 3 inserts:
            before, connector know that 1 + 1 + 1 inserts where executed.
            now, the driver just knows the total results is 3 for the example, so connector return array of -2 (= SUCCESS_NO_INFO).

            If update results are important, this new fast batch can be disabled by setting the option "useBulkStmts" to false.

            diego dupin Diego Dupin added a comment - By default, the driver now uses a new bulk command that executes batch a lot faster. The main default is that connector then just now the total results of the batch. Example for 3 inserts: before, connector know that 1 + 1 + 1 inserts where executed. now, the driver just knows the total results is 3 for the example, so connector return array of -2 (= SUCCESS_NO_INFO). If update results are important, this new fast batch can be disabled by setting the option "useBulkStmts" to false.

            Please read the description carefully. I was talking about UPDATE/DELETE statements, NOT INSERT statements!
            Of course, when I execute 3 INSERT statements in a batch, unless this fails with some constraint violation, I know that the total count is 3 (I don't even need to check the result array whether it contains -2 in each bucket).

            However, let's say I execute these 3 statements as a batch (by calling PreparedStatement.executeBatch())
            UPDATE ORDER SET STATUS = 'DONE' WHERE STATUS = 'IN PROGRESS' (e.g. this one updates 10 rows)
            UPDATE ORDER SET STATS = 'CANCELLED' WHERE STATUS = OPEN' (e.g. this one updates 0 rows)
            UPDATE ORDER SET STATUS = 'REOPEN' WHERE STATUS = 'IN PROGRESS' (e.g. this one updates 5 rows)
            With the new driver and without setting any options, how to I get the individual update counts (10, 0, 5), or at least the total count (15) ??? As I wrote in the description, no usable method returns anything I could do that.
            Note that with driver 2.1.0 the getLargeUpdateCount() would return 15, with latest driver it will return -1.
            Performance is very important but cannot go agaist usability.

            How do I set the useBulkStmts option?

            Roderick Radek Wikturna added a comment - Please read the description carefully. I was talking about UPDATE/DELETE statements, NOT INSERT statements! Of course, when I execute 3 INSERT statements in a batch, unless this fails with some constraint violation, I know that the total count is 3 (I don't even need to check the result array whether it contains -2 in each bucket). However, let's say I execute these 3 statements as a batch (by calling PreparedStatement.executeBatch()) UPDATE ORDER SET STATUS = 'DONE' WHERE STATUS = 'IN PROGRESS' (e.g. this one updates 10 rows) UPDATE ORDER SET STATS = 'CANCELLED' WHERE STATUS = OPEN' (e.g. this one updates 0 rows) UPDATE ORDER SET STATUS = 'REOPEN' WHERE STATUS = 'IN PROGRESS' (e.g. this one updates 5 rows) With the new driver and without setting any options, how to I get the individual update counts (10, 0, 5), or at least the total count (15) ??? As I wrote in the description, no usable method returns anything I could do that. Note that with driver 2.1.0 the getLargeUpdateCount() would return 15, with latest driver it will return -1. Performance is very important but cannot go agaist usability. How do I set the useBulkStmts option?

            I've just discoverd, by complete chance, that CONJ-642 (fixed in 2.3.0) solves this problem.
            Shouldn't this issue be then closed?

            Roderick Radek Wikturna added a comment - I've just discoverd, by complete chance, that CONJ-642 (fixed in 2.3.0) solves this problem. Shouldn't this issue be then closed?
            diego dupin Diego Dupin added a comment -

            closing since solved by CONJ-642

            diego dupin Diego Dupin added a comment - closing since solved by CONJ-642

            People

              diego dupin Diego Dupin
              Roderick Radek Wikturna
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.