diff --git a/devdoc/jdp/jdp-2024-06-change-handling-of-result-set-forward-only-with-hold-cursors-over-commit.adoc b/devdoc/jdp/jdp-2024-06-change-handling-of-result-set-forward-only-with-hold-cursors-over-commit.adoc index 7c5c13b61..b5ed7edc9 100644 --- a/devdoc/jdp/jdp-2024-06-change-handling-of-result-set-forward-only-with-hold-cursors-over-commit.adoc +++ b/devdoc/jdp/jdp-2024-06-change-handling-of-result-set-forward-only-with-hold-cursors-over-commit.adoc @@ -2,8 +2,8 @@ == Status -* Draft -* Proposed for: Jaybird 6 +* Published: 2024-11-05 +* Implemented in: Jaybird 6 == Type diff --git a/src/main/org/firebirdsql/gds/JaybirdErrorCodes.java b/src/main/org/firebirdsql/gds/JaybirdErrorCodes.java index 4b892a835..7657e2e0a 100644 --- a/src/main/org/firebirdsql/gds/JaybirdErrorCodes.java +++ b/src/main/org/firebirdsql/gds/JaybirdErrorCodes.java @@ -56,6 +56,10 @@ public interface JaybirdErrorCodes { int jb_clumpletReaderUsageError = 337248262; int jb_invalidConnectionString = 337248263; int jb_concurrencyResetReadOnlyReasonNotUpdatable = 337248264; + /** + * @deprecated Jaybird no longer uses this error code + */ + @Deprecated(since = "6") int jb_resultSetTypeUpgradeReasonHoldability = 337248265; int jb_resultSetTypeDowngradeReasonScrollSensitive = 337248266; int jb_concurrencyResetReadOnlyReasonStoredProcedure = 337248267; diff --git a/src/main/org/firebirdsql/jdbc/FBResultSet.java b/src/main/org/firebirdsql/jdbc/FBResultSet.java index b276b98b7..edadfb0b1 100644 --- a/src/main/org/firebirdsql/jdbc/FBResultSet.java +++ b/src/main/org/firebirdsql/jdbc/FBResultSet.java @@ -118,7 +118,10 @@ public FBResultSet(AbstractStatement statement, FBObjectListener.@Nullable Resul behavior.isScrollable() && behavior.isCloseCursorsAtCommit() && !metaDataQuery && connection.isScrollableCursor(PropertyConstants.SCROLLABLE_CURSOR_SERVER) && stmt.supportsFetchScroll(); - boolean cached = metaDataQuery || behavior.isScrollable() && !serverSideScrollable; + boolean cached = + metaDataQuery + || behavior.isScrollable() && !serverSideScrollable + || behavior.isHoldCursorsOverCommit(); fields = createFields(cached, metaDataQuery); closeableFields = toCloseableFields(fields); diff --git a/src/main/org/firebirdsql/jdbc/ResultSetBehavior.java b/src/main/org/firebirdsql/jdbc/ResultSetBehavior.java index 2230eed73..4e4c6db0e 100644 --- a/src/main/org/firebirdsql/jdbc/ResultSetBehavior.java +++ b/src/main/org/firebirdsql/jdbc/ResultSetBehavior.java @@ -261,16 +261,7 @@ public static ResultSetBehavior of(int type, int concurrency, int holdability) t public static ResultSetBehavior of(int type, int concurrency, int holdability, Consumer warningConsumer) throws SQLException { int bitset = switch (type) { - case ResultSet.TYPE_FORWARD_ONLY -> { - if (holdability == ResultSet.HOLD_CURSORS_OVER_COMMIT) { - warningConsumer.accept( - FbExceptionBuilder.forWarning(JaybirdErrorCodes.jb_resultSetTypeUpgradeReasonHoldability) - .toSQLException(SQLWarning.class)); - // Upgrade to scrollable so we cache the result set to provide the holdable semantics - yield SCROLLABLE_BIT; - } - yield NO_BIT_SET; - } + case ResultSet.TYPE_FORWARD_ONLY -> NO_BIT_SET; case ResultSet.TYPE_SCROLL_INSENSITIVE -> SCROLLABLE_BIT; case ResultSet.TYPE_SCROLL_SENSITIVE -> { warningConsumer.accept( diff --git a/src/test/org/firebirdsql/jdbc/AutoCommitBehaviourTest.java b/src/test/org/firebirdsql/jdbc/AutoCommitBehaviourTest.java index 6846ccc70..c1acb6f1a 100644 --- a/src/test/org/firebirdsql/jdbc/AutoCommitBehaviourTest.java +++ b/src/test/org/firebirdsql/jdbc/AutoCommitBehaviourTest.java @@ -122,20 +122,18 @@ void testDifferentStatementExecution_ClosesResultSet(int resultSetType) throws E @ValueSource(ints = { ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.TYPE_FORWARD_ONLY }) void testHoldableDifferentStatementExecution_ResultSetRemainsOpen(int resultSetType) throws Exception { connection.setHoldability(ResultSet.HOLD_CURSORS_OVER_COMMIT); - // TYPE_FORWARD_ONLY is upgraded to TYPE_SCROLL_INSENSITIVE - final int expectedType = ResultSet.TYPE_SCROLL_INSENSITIVE; var stmt1 = connection.createStatement(resultSetType, ResultSet.CONCUR_READ_ONLY); - assertEquals(expectedType, stmt1.getResultSetType(), "stmt1.getResultSetType"); + assertEquals(resultSetType, stmt1.getResultSetType(), "stmt1.getResultSetType"); var stmt2 = connection.createStatement(resultSetType, ResultSet.CONCUR_READ_ONLY); - assertEquals(expectedType, stmt2.getResultSetType(), "stmt2.getResultSetType"); + assertEquals(resultSetType, stmt2.getResultSetType(), "stmt2.getResultSetType"); var rs1 = stmt1.executeQuery(SELECT_ALL_ID_TABLE); - assertEquals(expectedType, rs1.getType(), "rs1.getType"); + assertEquals(resultSetType, rs1.getType(), "rs1.getType"); assertNextRow(rs1); assertResultSetOpen(rs1, "Expected rs1 open"); var rs2 = stmt2.executeQuery(SELECT_ALL_ID_TABLE); - assertEquals(expectedType, rs2.getType(), "rs2.getType"); + assertEquals(resultSetType, rs2.getType(), "rs2.getType"); assertResultSetOpen(rs1, "Expected rs1 open"); diff --git a/src/test/org/firebirdsql/jdbc/FBTxPreparedStatementTest.java b/src/test/org/firebirdsql/jdbc/FBTxPreparedStatementTest.java index a2531fc43..25f1bb36d 100644 --- a/src/test/org/firebirdsql/jdbc/FBTxPreparedStatementTest.java +++ b/src/test/org/firebirdsql/jdbc/FBTxPreparedStatementTest.java @@ -227,7 +227,7 @@ void resultSetTypeConcurrencyHoldability(int type, int concurrency, int holdabil private static Stream resultSetTypeConcurrencyHoldability() { return Stream.of( Arguments.of(TYPE_FORWARD_ONLY, CONCUR_READ_ONLY, CLOSE_CURSORS_AT_COMMIT, TYPE_FORWARD_ONLY), - Arguments.of(TYPE_FORWARD_ONLY, CONCUR_READ_ONLY, HOLD_CURSORS_OVER_COMMIT, TYPE_SCROLL_INSENSITIVE), + Arguments.of(TYPE_FORWARD_ONLY, CONCUR_READ_ONLY, HOLD_CURSORS_OVER_COMMIT, TYPE_FORWARD_ONLY), Arguments.of(TYPE_SCROLL_INSENSITIVE, CONCUR_UPDATABLE, CLOSE_CURSORS_AT_COMMIT, TYPE_SCROLL_INSENSITIVE), Arguments.of(TYPE_SCROLL_INSENSITIVE, CONCUR_UPDATABLE, HOLD_CURSORS_OVER_COMMIT, diff --git a/src/test/org/firebirdsql/jdbc/ResultSetBehaviorTest.java b/src/test/org/firebirdsql/jdbc/ResultSetBehaviorTest.java index 54116533e..219ee6190 100644 --- a/src/test/org/firebirdsql/jdbc/ResultSetBehaviorTest.java +++ b/src/test/org/firebirdsql/jdbc/ResultSetBehaviorTest.java @@ -164,11 +164,9 @@ void testWithReadOnly(int type, int concurrency, int holdability) throws SQLExce static Stream testCases() { return Stream.of( testCaseBasic(TYPE_FORWARD_ONLY, CONCUR_READ_ONLY, CLOSE_CURSORS_AT_COMMIT), - testCaseTypeChange(TYPE_FORWARD_ONLY, CONCUR_READ_ONLY, HOLD_CURSORS_OVER_COMMIT, - TYPE_SCROLL_INSENSITIVE, JaybirdErrorCodes.jb_resultSetTypeUpgradeReasonHoldability), + testCaseBasic(TYPE_FORWARD_ONLY, CONCUR_READ_ONLY, HOLD_CURSORS_OVER_COMMIT), testCaseBasic(TYPE_FORWARD_ONLY, CONCUR_UPDATABLE, CLOSE_CURSORS_AT_COMMIT), - testCaseTypeChange(TYPE_FORWARD_ONLY, CONCUR_UPDATABLE, HOLD_CURSORS_OVER_COMMIT, - TYPE_SCROLL_INSENSITIVE, JaybirdErrorCodes.jb_resultSetTypeUpgradeReasonHoldability), + testCaseBasic(TYPE_FORWARD_ONLY, CONCUR_UPDATABLE, HOLD_CURSORS_OVER_COMMIT), testCaseBasic(TYPE_SCROLL_INSENSITIVE, CONCUR_READ_ONLY, CLOSE_CURSORS_AT_COMMIT), testCaseBasic(TYPE_SCROLL_INSENSITIVE, CONCUR_READ_ONLY, HOLD_CURSORS_OVER_COMMIT), testCaseBasic(TYPE_SCROLL_INSENSITIVE, CONCUR_UPDATABLE, CLOSE_CURSORS_AT_COMMIT),