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

Table with primary key with DEFAULT function can not be inserted to: Current position is after the last row

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.4.2, 2.6.2
    • Fix Version/s: 2.7.0
    • Component/s: JDBC compatibility
    • Labels:
      None
    • Environment:
      platform independent

      Description

      When using JDBC interface to insert data into a table, where the primary key is not AUTO_INCREMENT but a column with DEFAULT UUID(), insertion fails with error: Current position is after the last row.

      See the atached source file for minimal example.

      The problem is in https://github.com/mariadb-corporation/mariadb-connector-j/blob/master/src/main/java/org/mariadb/jdbc/internal/com/read/resultset/UpdatableResultSet.java#L1081

      The condition is not satisfied for primary keys generated by DEFAULT UUID(), only by AUTO_INCREMENT primary keys. Therefore the primary key is not used for refreshing the row values (lines 1091-1104). Moreover, the call to refreshRawData() on line 1107 fails with exception:

      {{java.sql.SQLDataException: Current position is before the first row
      at org.mariadb.jdbc.internal.com.read.resultset.SelectResultSet.checkObjectRange(SelectResultSet.java:624)
      at org.mariadb.jdbc.internal.com.read.resultset.SelectResultSet.getObject(SelectResultSet.java:1158)
      at org.mariadb.jdbc.internal.com.read.resultset.UpdatableResultSet.refreshRawData(UpdatableResultSet.java:1299)
      at org.mariadb.jdbc.internal.com.read.resultset.UpdatableResultSet.insertRow(UpdatableResultSet.java:1107)
      at TestMariaDb.main(TestMariaDb.java:24)}}

      When trying to obtain the primary key value.

        Attachments

          Activity

            People

            Assignee:
            diego dupin Diego Dupin
            Reporter:
            janci Tomas Janco
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: