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/04/23 10:41:12 UTC

svn commit: r650786 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ResultSetsFromPreparedStatementTest.java

Author: kristwaa
Date: Wed Apr 23 01:41:11 2008
New Revision: 650786

URL: http://svn.apache.org/viewvc?rev=650786&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.
Added two simple regression tests.
Patch file: derby-3397-2a-junit_reg_test.diff

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ResultSetsFromPreparedStatementTest.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ResultSetsFromPreparedStatementTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ResultSetsFromPreparedStatementTest.java?rev=650786&r1=650785&r2=650786&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ResultSetsFromPreparedStatementTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ResultSetsFromPreparedStatementTest.java Wed Apr 23 01:41:11 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);
+    }
 }