diff --git a/src/main/org/firebirdsql/jdbc/AbstractResultSet.java b/src/main/org/firebirdsql/jdbc/AbstractResultSet.java index f3cc167af5..f26c81c0e8 100644 --- a/src/main/org/firebirdsql/jdbc/AbstractResultSet.java +++ b/src/main/org/firebirdsql/jdbc/AbstractResultSet.java @@ -143,7 +143,7 @@ public AbstractResultSet(FBConnection connection, rowUpdater = new FBRowUpdater(connection, rowDescriptor, this, cached, listener); } catch (FBResultSetNotUpdatableException ex) { fbStatement.addWarning(FbExceptionBuilder - .forException(JaybirdErrorCodes.jb_concurrencyResetReadOnlyReasonNotUpdatable) + .forWarning(JaybirdErrorCodes.jb_concurrencyResetReadOnlyReasonNotUpdatable) .toFlatSQLException(SQLWarning.class)); rsConcurrency = ResultSet.CONCUR_READ_ONLY; } diff --git a/src/test/org/firebirdsql/jdbc/TestFBResultSet.java b/src/test/org/firebirdsql/jdbc/TestFBResultSet.java index a4adc2f136..9aedfb4a5a 100644 --- a/src/test/org/firebirdsql/jdbc/TestFBResultSet.java +++ b/src/test/org/firebirdsql/jdbc/TestFBResultSet.java @@ -20,6 +20,7 @@ import org.firebirdsql.common.FBJUnit4TestBase; import org.firebirdsql.gds.ISCConstants; +import org.firebirdsql.gds.JaybirdErrorCodes; import org.junit.*; import org.junit.rules.ExpectedException; @@ -33,7 +34,10 @@ import static org.firebirdsql.common.DdlHelper.executeDDL; import static org.firebirdsql.common.FBTestProperties.*; import static org.firebirdsql.common.JdbcResourceHelper.closeQuietly; +import static org.firebirdsql.common.matchers.SQLExceptionMatchers.fbMessageStartsWith; import static org.firebirdsql.common.matchers.SQLExceptionMatchers.sqlStateEquals; +import static org.hamcrest.CoreMatchers.allOf; +import static org.hamcrest.CoreMatchers.notNullValue; import static org.junit.Assert.*; public class TestFBResultSet extends FBJUnit4TestBase { @@ -788,6 +792,23 @@ public void testUpdatableResultSetNoPK() throws Exception { } } + @Test + public void testUpdatableStatementResultSetDowngradeToReadOnlyWhenQueryNotUpdatable() throws Exception { + executeCreateTable(connection, CREATE_TABLE_STATEMENT); + executeCreateTable(connection, CREATE_TABLE_STATEMENT2); + + try (Statement stmt = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); + ResultSet rs = stmt.executeQuery("select * from test_table t1 left join test_table2 t2 on t1.id = t2.id")) { + + SQLWarning warning = stmt.getWarnings(); + assertThat(warning, allOf( + notNullValue(), + fbMessageStartsWith(JaybirdErrorCodes.jb_concurrencyResetReadOnlyReasonNotUpdatable))); + + assertEquals("Expected downgrade to CONCUR_READ_ONLY", ResultSet.CONCUR_READ_ONLY, rs.getConcurrency()); + } + } + @Test public void testGetExecutionPlan() throws Exception { executeCreateTable(connection, CREATE_TABLE_STATEMENT);