You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by kr...@apache.org on 2008/05/01 22:47:13 UTC
svn commit: r652656 - in /db/derby/code/branches/10.4/java:
engine/org/apache/derby/impl/sql/execute/ScrollInsensitiveResultSet.java
testing/org/apache/derbyTesting/functionTests/tests/lang/ResultSetsFromPreparedStatementTest.java
Author: kristwaa
Date: Thu May 1 13:47:13 2008
New Revision: 652656
URL: http://svn.apache.org/viewvc?rev=652656&view=rev
Log:
DERBY-3397: Derby 10.3.1.4 and 10.3.2.1 break scrollable result sets? Hibernate Query.setFirstResult and/or setMaxResults.
Ported fix (r650783) and regression test (r650786) from trunk to 10.4.
Patches contributed by Dag H. Wanvik and Kristian Waagan.
Modified:
db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/sql/execute/ScrollInsensitiveResultSet.java
db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ResultSetsFromPreparedStatementTest.java
Modified: db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/sql/execute/ScrollInsensitiveResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/sql/execute/ScrollInsensitiveResultSet.java?rev=652656&r1=652655&r2=652656&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/sql/execute/ScrollInsensitiveResultSet.java (original)
+++ db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/sql/execute/ScrollInsensitiveResultSet.java Thu May 1 13:47:13 2008
@@ -245,6 +245,7 @@
positionInSource = 0;
seenFirst = false;
seenLast = false;
+ maxRows = activation.getMaxRows();
openTime += getElapsedMillis(beginTime);
setBeforeFirstRow();
Modified: db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ResultSetsFromPreparedStatementTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ResultSetsFromPreparedStatementTest.java?rev=652656&r1=652655&r2=652656&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ResultSetsFromPreparedStatementTest.java (original)
+++ db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ResultSetsFromPreparedStatementTest.java Thu May 1 13:47:13 2008
@@ -2096,4 +2096,40 @@
public void testBigintGeneratedAlwaysAsIdentity() throws Exception {
testGeneratedIdentity("BIGINT","ALWAYS");
}
+
+ /**
+ * Tests that the {@code maxRows} setting takes effect, data is obtained
+ * from a table select.
+ */
+ public void testSetMaxRowsTable()
+ throws SQLException {
+ createTestTable("emp", ES+","+DNO+")", "emp_data");
+ PreparedStatement ps = prepareStatement("select * from emp_data",
+ ResultSet.TYPE_SCROLL_INSENSITIVE,
+ ResultSet.CONCUR_READ_ONLY);
+ // Just make sure we have enough rows in the result set first.
+ // Execute without explicitly specifying maxRows.
+ assertTrue(JDBC.assertDrainResults(ps.executeQuery()) >= 20);
+
+ // Specify maxRows
+ ps.setMaxRows(5);
+ JDBC.assertDrainResults(ps.executeQuery(), 5);
+ ps.setMaxRows(20);
+ JDBC.assertDrainResults(ps.executeQuery(), 20);
+ }
+
+ /**
+ * Tests that the {@code maxRows} setting takes effect, data is obtained
+ * from a value clause.
+ */
+ public void testSetMaxRowsValues()
+ throws SQLException {
+ PreparedStatement ps = prepareStatement("values 0,1,2,3,4,5,6,7,8,9",
+ ResultSet.TYPE_SCROLL_INSENSITIVE,
+ ResultSet.CONCUR_READ_ONLY);
+ ps.setMaxRows(10);
+ JDBC.assertDrainResults(ps.executeQuery(), 10);
+ ps.setMaxRows(2);
+ JDBC.assertDrainResults(ps.executeQuery(), 2);
+ }
}