Uploaded image for project: 'MariaDB Connector/R2DBC'
  1. MariaDB Connector/R2DBC
  2. R2DBC-11

Batching on statement use parameters not added

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 0.8.4-rc
    • 1.0.0
    • batch
    • None

    Description

      from #8

      The MariaDB implementation of batch inserts with prepared statements currently requires at least one statement to not be part of a batch when doing batch inserts with prepared statements otherwise an error such as the following occurs:

      java.lang.IllegalArgumentException: Parameter at position 0 is not set
      	at org.mariadb.r2dbc.MariadbClientParameterizedQueryStatement.execute(MariadbClientParameterizedQueryStatement.java:132)
      	at org.mariadb.r2dbc.MariadbClientParameterizedQueryStatement.execute(MariadbClientParameterizedQueryStatement.java:34)
      	at io.micronaut.data.r2dbc.operations.DefaultR2dbcRepositoryOperations$DefaultR2dbcReactiveRepositoryOperations.lambda$persistAll$18(DefaultR2dbcRepositoryOperations.java:491)
      	at
      

      Looking at the validation logic in MariadbClientParameterizedQueryStatement it does this:

       
        public Flux<org.mariadb.r2dbc.api.MariadbResult> execute() {
       
          // valid parameters
          for (int i = 0; i < prepareResult.getParamCount(); i++) {
            if (parameters[i] == null) {
              throw new IllegalArgumentException(String.format("Parameter at position %s is not set", i));
            }
          }
       
          if (batchingParameters == null) {
      

      If you call add() for the last batch statement then all entries in parameters are null and they exist only in batchParameters. It seems to be that this check should only be executed if batchingParameters == null and the validation check should be moved inside the if statement.

      This differs to other implementations whereby you can call add() for each statement and execute them no problem. As a result of this I have to place a MariaDB specific hack into the code I am developing to allow batch inserts to execute across different implementations:

      Attachments

        Activity

          People

            diego dupin Diego Dupin
            diego dupin Diego Dupin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 3h
                3h
                Remaining:
                Time Spent - 0.25d Remaining Estimate - 1h
                1h
                Logged:
                Time Spent - 0.25d Remaining Estimate - 1h
                0.25d

                Git Integration

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