This is an automated email from the ASF dual-hosted git repository. jsorel pushed a commit to branch geoapi-4.0 in repository https://gitbox.apache.org/repos/asf/sis.git
commit 87cfdd0ab05265d32f29163c140e47d2ad2c4659 Author: jsorel <johann.so...@geomatys.com> AuthorDate: Fri Jun 14 16:30:33 2024 +0200 Add SQL Dialect supportsReadOnlyUpdate flag, not supported by SQLite --- .../org/apache/sis/metadata/sql/privy/Dialect.java | 22 +++++++++++++++------- .../sis/storage/sql/feature/FeatureStream.java | 4 +++- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/sql/privy/Dialect.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/sql/privy/Dialect.java index a8215496c4..8c09d25b8e 100644 --- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/sql/privy/Dialect.java +++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/sql/privy/Dialect.java @@ -34,7 +34,7 @@ public enum Dialect { * * @see DatabaseMetaData#supportsANSI92EntryLevelSQL() */ - ANSI(null, false, true, true), + ANSI(null, false, true, true, true), /** * The database uses Derby syntax. This is ANSI, with some constraints that PostgreSQL does not have @@ -43,31 +43,31 @@ public enum Dialect { * * <a href="https://issues.apache.org/jira/browse/DERBY-6445">DERBY-6445</a> */ - DERBY("derby", false, true, false), + DERBY("derby", false, true, false, true), /** * The database uses HSQL syntax. This is ANSI, but does not allow {@code INSERT} statements inserting many lines. * It also have a {@code SHUTDOWN} command which is specific to HSQLDB. */ - HSQL("hsqldb", false, true, true), + HSQL("hsqldb", false, true, true, true), /** * The database uses PostgreSQL syntax. This is ANSI, but provided an a separated * enumeration value because it allows a few additional commands like {@code VACUUM}. */ - POSTGRESQL("postgresql", true, true, true), + POSTGRESQL("postgresql", true, true, true, true), /** * The database uses Oracle syntax. This is ANSI, but without {@code "AS"} keyword. */ - ORACLE("oracle", false, true, true), + ORACLE("oracle", false, true, true, true), /** * The database uses SQLite syntax. This is ANSI, but with several limitations. * * @see <a href="https://www.sqlite.org/omitted.html">SQL Features That SQLite Does Not Implement</a> */ - SQLITE("sqlite", false, false, false); + SQLITE("sqlite", false, false, false, false); /** * The protocol in JDBC URL, or {@code null} if unknown. @@ -106,18 +106,26 @@ public enum Dialect { */ public final boolean supportsJavaTime; + /** + * Whether the JDBC driver supports configuring readOnly mode on connection instances. + * This feature is not supported in SQLite. + */ + public final boolean supportsReadOnlyUpdate; + /** * Creates a new enumeration value for a SQL dialect for the given protocol. */ private Dialect(final String protocol, final boolean supportsTableInheritance, final boolean supportsAlterTableWithAddConstraint, - final boolean supportsJavaTime) + final boolean supportsJavaTime, + final boolean supportsReadOnlyUpdate) { this.protocol = protocol; this.supportsTableInheritance = supportsTableInheritance; this.supportsAlterTableWithAddConstraint = supportsAlterTableWithAddConstraint; this.supportsJavaTime = supportsJavaTime; + this.supportsReadOnlyUpdate = supportsReadOnlyUpdate; } /** diff --git a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/FeatureStream.java b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/FeatureStream.java index 4f9417a070..2189b94447 100644 --- a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/FeatureStream.java +++ b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/FeatureStream.java @@ -366,7 +366,9 @@ final class FeatureStream extends DeferredStream<Feature> { * @param connection the connection to configure. */ private void makeReadOnly(final Connection connection) throws SQLException { - connection.setReadOnly(true); + if (table.database.dialect.supportsReadOnlyUpdate) { + connection.setReadOnly(true); + } /* * Do not invoke `setAutoCommit(false)` because it causes the database to hold read locks, * even if we are doing only SELECT statements. On Derby database it causes the following