db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r421887 - in /db/derby/code/trunk/java: drda/org/apache/derby/impl/drda/DRDAConnThread.java testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURTest.java
Date Fri, 14 Jul 2006 12:20:01 GMT
Author: kahatlen
Date: Fri Jul 14 05:20:01 2006
New Revision: 421887

URL: http://svn.apache.org/viewvc?rev=421887&view=rev
Log:
DERBY-1481: Client driver: ResultSet.beforeFirst() gives protocol
error on scrollable, updatable result sets that are downgraded to
read-only

When the result set is downgraded from updatable to read-only because
the query generating the result set cannot produce an updatable result
set, the result set will be downgraded on the server side, and a
warning (SQLCARD) indicating the downgrade will be sent to the
client. Warnings on the server side are not cleared after they are
sent to the client causing the server to send the same warning several
times.

Positioning commands like ResultSet.beforeFirst() that do not return
any data also do not expect warnings to be returned. The protocol
error was being caused by this downgrade warning that was being sent
several times, one of them being in a response to a
ResultSet.beforeFirst() command.

The attached patch (derby-1481.diff) fixed the problem by clearing the
warnings after they are sent so that the same warning will not be sent
more than once.

The patch was contributed by Fernanda Pizzorno.

Modified:
    db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURTest.java

Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java?rev=421887&r1=421886&r2=421887&view=diff
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java (original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java Fri Jul 14
05:20:01 2006
@@ -6261,6 +6261,9 @@
 			
 			// Send ResultSet warnings if there are any
 			SQLWarning sqlw = (rs != null)? rs.getWarnings(): null;
+			if (rs != null) {
+				rs.clearWarnings();
+			}
 
 			// for updatable, insensitive result sets we signal the
 			// row updated condition to the client via a warning to be 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURTest.java?rev=421887&r1=421886&r2=421887&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURTest.java
Fri Jul 14 05:20:01 2006
@@ -1477,6 +1477,39 @@
         s.close();
     }
 
+    /**
+     * DERBY-1481 - ResultSet.beforeFirst() gives protocol error on scrollable,
+     * updatable result sets that are downgraded to read-only
+     * 
+     * Check that no exception is thrown when calling positioning methods on a
+     * result set that has been downgraded to read-only.
+     *
+     */
+    public void testDowngradeToScrollReadOnly() throws SQLException {
+        Statement s = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, 
+                                          ResultSet.CONCUR_UPDATABLE);
+        ResultSet rs = s.executeQuery("select * from t1 order by b");
+
+        // check that the ResultSet was downgraded
+        assertWarning(rs.getWarnings(), 
+                QUERY_NOT_QUALIFIED_FOR_UPDATABLE_RESULTSET);
+        
+        // call positioning methods
+        rs.next();
+        rs.next();
+        rs.previous();
+        rs.relative(1);
+        rs.absolute(3);
+        rs.relative(-1);
+        rs.first();
+        rs.last();
+        rs.beforeFirst();
+        rs.afterLast();
+        
+        // close result set and statement
+        rs.close();
+        s.close();
+    }
 
     /**
      * Get a cursor name. We use the same cursor name for all cursors.



Mime
View raw message