db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From be...@apache.org
Subject svn commit: r391153 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/sql/execute/ testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/
Date Mon, 03 Apr 2006 21:26:57 GMT
Author: bernt
Date: Mon Apr  3 14:26:55 2006
New Revision: 391153

URL: http://svn.apache.org/viewcvs?rev=391153&view=rev
Log:
DERBY-1172 incorrect error message in updateRow() after a commit on a held scroll insensitive
resultset. Submitted by Andreas Korneliussen

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/TableScanResultSet.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/HoldabilityTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURBaseTest.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/TableScanResultSet.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/TableScanResultSet.java?rev=391153&r1=391152&r2=391153&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/TableScanResultSet.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/TableScanResultSet.java
Mon Apr  3 14:26:55 2006
@@ -914,7 +914,17 @@
 				if (rlTemplate == null)
 					rlTemplate = scanController.newRowLocationTemplate();
 				rl = rlTemplate;
-				scanController.fetchLocation(rl);
+				try {
+					scanController.fetchLocation(rl);
+				} catch (StandardException se) {
+					if (se.getMessageId().equals(SQLState.AM_SCAN_NOT_POSITIONED)) {
+						
+						//Have a easier to understand error message than what 
+						//we get from store 
+						throw StandardException.
+							newException(SQLState.NO_CURRENT_ROW);
+					}
+				}
 			} else {
 				rl = null;
 			}

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/HoldabilityTest.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/HoldabilityTest.java?rev=391153&r1=391152&r2=391153&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/HoldabilityTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/HoldabilityTest.java
Mon Apr  3 14:26:55 2006
@@ -317,6 +317,60 @@
     }
 
     /**
+     * Test that updateRow() after a commit requires a renavigation 
+     * on a held forward only ResulTset.
+     */
+    public void testUpdateRowAfterCommitOnHeldForwardOnlyResultSet() 
+        throws SQLException
+    {
+        Statement s = con.createStatement(ResultSet.TYPE_FORWARD_ONLY, 
+                                          ResultSet.CONCUR_UPDATABLE);
+        ResultSet rs = s.executeQuery(selectStatement);
+        
+        if (rs.getConcurrency()==ResultSet.CONCUR_READ_ONLY) {
+            println("Test disabled");
+            return;
+        }
+        rs.next();
+        con.commit();
+        try {
+            rs.updateInt(2, -100);
+            rs.updateRow();
+            assertTrue("Expected updateRow() to throw exception", false);
+        } catch (SQLException e) {
+            assertEquals("Unexpected SQLState",
+                         INVALID_CURSOR_STATE_NO_CURRENT_ROW, e.getSQLState());
+        }
+    }
+
+    /**
+     * Test that updateRow() after a commit requires a renavigation 
+     * on a held scrollinsensitve ResulTset.
+     */
+    public void testUpdateRowAfterCommitOnHeldScrollInsensitiveResultSet() 
+        throws SQLException
+    {
+        Statement s = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, 
+                                          ResultSet.CONCUR_UPDATABLE);
+        ResultSet rs = s.executeQuery(selectStatement);
+        
+        if (rs.getConcurrency()==ResultSet.CONCUR_READ_ONLY) {
+            println("Test disabled");
+            return;
+        }
+        rs.next();
+        con.commit();
+        try {
+            rs.updateInt(2, -100);
+            rs.updateRow();
+            assertTrue("Expected updateRow() to throw exception", false);
+        } catch (SQLException e) {
+            assertEquals("Unexpected SQLState",
+                         INVALID_CURSOR_STATE_NO_CURRENT_ROW, e.getSQLState());
+        }
+    }
+
+    /**
      * Test that running a compress on a holdable scrollable updatable 
      * resultset will not invalidate the ResultSet from doing updates,
      * if the scan is initialized
@@ -494,7 +548,8 @@
         rs.updateRow();
         SQLWarning warn = rs.getWarnings();
         assertNotNull("Expected warning when updating deleted tuple", warn);
-        assertEquals("Unexpected SQL State on warning", "01001", 
+        assertEquals("Unexpected SQL State on warning", 
+                     CURSOR_OPERATION_CONFLICT, 
                      warn.getSQLState());        
         rs.clearWarnings();
         
@@ -504,7 +559,8 @@
         updateTuple(rs); 
         warn = rs.getWarnings();
         assertNotNull("Expected warning when updating deleted tuple", warn);
-        assertEquals("Unexpected SQL State on warning", "01001", 
+        assertEquals("Unexpected SQL State on warning", 
+                     CURSOR_OPERATION_CONFLICT, 
                      warn.getSQLState());
         con.commit();
         

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURBaseTest.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURBaseTest.java?rev=391153&r1=391152&r2=391153&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURBaseTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURBaseTest.java
Mon Apr  3 14:26:55 2006
@@ -286,4 +286,6 @@
     final static String RESULTSET_NOT_UPDATABLE_SQL_STATE = "XJ083";
     final static String LOCK_TIMEOUT_SQL_STATE = "40XL1";
     final static String LOCK_TIMEOUT_EXPRESSION_SQL_STATE = "38000";
+    final static String INVALID_CURSOR_STATE_NO_CURRENT_ROW = "24000";
+    final static String CURSOR_OPERATION_CONFLICT = "01001";
 }



Mime
View raw message