[CONJ-855] Updatable view with calculated column can not be updated by ResultSet Created: 2021-02-10  Updated: 2021-05-12  Resolved: 2021-05-12

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

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

MariaDB Server version 10.5.8
also tested with MySQL Server version: 5.7.26


Attachments: Java Source File TestMariaDbUpdateView.java    

 Description   

When a view contains calculated column, the view is still updatable in MariaDb. However the JDBC driver considers this view as not updatable, because JDBC driver incorrectly considers all views that contain columns without database information as not updatable. The ResultSet from this view should be updatable, only the calculated column should not.

Even if this is not to be supported (yet), the query should fail by throwing more specific SQLFeatureNotSupportedException instead of generic SQLException.

Please see the example source code.
Expected result: the database field will be updated
Actual result: Exception is thrown

Exception in thread "main" java.sql.SQLException: ResultSet cannot be updated. The result-set contains fields without without any database information
	at org.mariadb.jdbc.internal.com.read.resultset.UpdatableResultSet.checkUpdatable(UpdatableResultSet.java:317)
	at org.mariadb.jdbc.internal.com.read.resultset.UpdatableResultSet.updateString(UpdatableResultSet.java:420)
	at org.mariadb.jdbc.internal.com.read.resultset.UpdatableResultSet.updateString(UpdatableResultSet.java:430)
	at TestMariaDbUpdateView.main(TestMariaDbUpdateView.java:24)



 Comments   
Comment by Diego Dupin [ 2021-02-10 ]

allright, in this specific case, driver must permits changing the not calculated column
Driver cannot retrieve metadata to permit view update, even if view is updatable in INFORMATION_SCHEMA.VIEWS.

This task will only changing SQLException to SQLFeatureNotSupportedException for some specific case like this one.

This will be part of next correction release.

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