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

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 2.4.2, 2.6.2
    • 2.7.0
    • JDBC compatibility
    • None
    • 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

            diego dupin Diego Dupin
            janci Tomas Janco
            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.