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

MariaDB Java Client 3.3.1 - Java batched insrt on duplicate key does not work properly

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • None
    • 3.3.2
    • batch
    • None

    Description

      Hi, this issue might be related to CONJ-920.

      System setup

      • MariaDB Connector J 3.3.1
      • MariaDb 10.5.23
      • Java 8
      • HikariCP 4.0.3 JDBC connection pool

      Issue

      I'm trying to do a batch query with INSERT ON DUPLICATE KEY UPDATE statement and when inserting more than one row into a table where all keys already exist then the update performed properly but executeBatch() returns an array where all values are -2 instead of 2:
      expected [2,2,2] but was [-2,-2-2]

      However, if I insert only one row with the existing key then I get the correct value of 2.
      If I have two rows (one new one and the second one existing) then I get [-2,-2] instead of [2,1]

      In the case where all rows are new one works properly, and value 1 is returned for each row.

      I've tried ?useBulkStmts=false&useBulkStmtsForInserts=true and ?useBulkStmts=true&useBulkStmtsForInserts=true and got the same result.

      Is it supposed to work like that? To me it seems like a bug, I can not distinguish updates from inserts in this case.

      To summarize:

      • insert of multiple existing rows - produces [-2,-2,-2], expected [2,2,2]
      • insert of multiple mixed rows (new and existing) - produces [-2,-2,-2], expected [2,1,2]
      • insert of single existing row - produces [2] (as expected)
      • insert of multiple new rows - produces [1,1,1] (as expected)
      • insert of single new row - produces [1] (as expected)

      Attachments

        Issue Links

          Activity

            People

              diego dupin Diego Dupin
              Mysko Teodor Mysko
              Votes:
              0 Vote for this issue
              Watchers:
              3 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.