Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
2.4.2, 2.6.2
-
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.