[CONJ-816] Table with primary key with DEFAULT function can not be inserted to: Current position is after the last row Created: 2020-08-10  Updated: 2020-09-23  Resolved: 2020-08-24

Status: Closed
Project: MariaDB Connector/J
Component/s: JDBC compatibility
Affects Version/s: 2.4.2, 2.6.2
Fix Version/s: 2.7.0

Type: Bug Priority: Major
Reporter: Tomas Janco Assignee: Diego Dupin
Resolution: Fixed Votes: 0
Labels: None
Environment:

platform independent


Attachments: Java Source File TestMariaDb.java    

 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.



 Comments   
Comment by Diego Dupin [ 2020-08-20 ]

There is no way to retrieve the generated uuid before 10.5 server version.
So this need to be implemented for 10.5 server, and need a better error than "Current position is after the last row" for server before 10.5

Generated at Thu Feb 08 03:18:31 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.